akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

lol dp[1005][10005], n;
lol a[1005], b[10005];

lol f(lol idx, lol hp)
{
    if(hp <= 0) return 0;
    if(idx > n) return INF;
    lol &sol = dp[idx][hp];
    if(sol != -1) return sol;
    return sol = min(f(idx+1, hp), f(idx, hp - a[idx])+b[idx]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lol result{0};
    lol h; cin >> h >> n;
    FOR(i, 1, n)
    {
        cin >> a[i] >> b[i];
    }
    memset(dp, -1, sizeof(dp));
    result = f(1, h);

    cout << result << '\n';
    return 0;
}

Measured memory_bytes: 82628
#include <iostream>

typedef long long ll;

const int MAX_N = 100005;
const ll MOD = 1000000007;
ll dp[MAX_N][13];

int main(){
   std::string S;
   std::cin >> S;

   int N = S.size();
   dp[0][0] = 1;
   for(int i=0; i<N; ++i){
      int dig = -1;
      if(S[i] != '?') dig = S[i] - '0';

      for(int j=0; j<10; ++j){
	 if(dig!=-1 && dig!=j) continue;
	 for(int k=0; k<13; ++k)
	    dp[i+1][(k*10 + j)%13] += dp[i][k];
      }
      for(int j=0; j<13; ++j)
	 dp[i+1][j] %= MOD;
   }

   ll ans = dp[N][5];
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
int main(){
  int i;
  int l[100];
  int n;
  int value;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  value=bubble(l,n);
  for(i=0;i<n;i++){
    printf("%d",l[i]);
    if(i<n-1)printf(" ");
    else printf("\n");
  }
  printf("%d\n",value);
  return 0;
}
int bubble(int l[],int n){
  int i;
  int j;
  int temp;
  int cnt=0;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(l[j]<l[j-1]){
	temp=l[j];
	l[j]=l[j-1];
	l[j-1]=temp;
	cnt++;
      }
    }
  }
  return cnt;
}



Measured memory_bytes: 2084
import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

Measured memory_bytes: 42992
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    from functools import reduce

    # 最小公倍数
    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)

    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)

    n = ni()
    a = na()

    lcm = a[0]
    for i in a:
        lcm = lcm // math.gcd(lcm, i) * i
    lcm %= MOD

    ans = 0
    for ai in a:
        ans += lcm * pow(ai, MOD - 2, MOD) % MOD
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11416
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,now=-1;
ll ans=1; 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	scanf("%d",&n);
	char s1[n],s2[n];
	scanf("%s%s",s1,s2);
	for(int i=0;i<n;i++){
		if(s1[i]==s2[i]){
			if(now==-1)
			ans*=3;
			else if(now==0)
			ans*=2;
			now=0;
		}
		else{
			if(now==-1)
			ans*=6;
			else if(now==0)
			ans*=2;
			else if(now==1)
			ans*=3;
			now=1;
			i++;
		}
		ans%=MOD;
	}
	printf("%lld\n",ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>


int first_digit(int value) {
	return (value < 10) ? value : first_digit(value / 10);
}
int last_digit(int value) {
	return value % 10;
}


int main(void) {
	int n; std::cin >> n;
	std::vector<std::vector<long long int>> count(10, std::vector<long long int>(10, 0));
	for (auto i = 1; i <= n; ++i) {
		count[first_digit(i)][last_digit(i)]++;
	}
	long long int result = 0;
	for (auto i = 1; i < 10; ++i) for (auto j = 1; j < 10; ++j) {
		result += count[i][j] * count[j][i];
	}
	std::cout << result << std::endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int dp[N][3];
int a[3][N];

int main() {
#ifdef purple_bro
    freopen("in.txt","r",stdin);
#endif
    int n;

    scanf("%d", &n);

    for (int i = 1; i <= n; i++)
        scanf("%d%d%d", &a[0][i], &a[1][i], &a[2][i]);

    int ans = 0;

    for (int i = 0; i < 3; i++)
        dp[1][i] = a[i][1];

    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k)
                    continue;
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[k][i]);
            }
        }
    }

    for (int i = 0; i < 3; i++)
        ans = max(ans, dp[n][i]);

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(void){

    int N,K,i;
    cin >> N >> K;
    vector<int> h(100001,1000000001);
    for(i = 0;i < N;i++){
        cin >> h.at(i);
    }
    sort(h.begin(),h.end());
    int min = h.at(K-1) - h.at(0);
    for(i = 0;i < N-K+1 ;i++){
        if((h.at(i+K-1) - h.at(i)) < min){
            min = h.at(i+K-1) - h.at(i);
        }
    }

    cout << min;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

ll pof(ll base, ll top){
    if(top == 0) return 1;
    if(top == 1) return base;
    ll ans = pof(base,top/2);
    ans = ans*ans;
    if(top&1) ans *= base;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x; cin >> x;
    ll po[301];
    for(ll i = 0; i<=300; i++){
        po[i] = pof(i,5);
    }
    int a,b;
    F0R(i,0,300){
        F0R(j,0,300){
            if(po[i]-po[j] == x){
                a = i; b = j;
//                cerr << a << " " << b << po[a] << " " << po[b] << " " << po[a] - po[b] << endl;
            }
            if(po[i]+po[j] == x){
                a = i; b = -j;
//                cerr << "1 " << a << " " << b << po[a] << " " << po[b] << " " << po[a] + po[b] << endl;
            }
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n;
int main()
{
	cin>>n;
	if(n==1){
		cout<<"Hello World";
	}else{
		int a,b;
		cin>>a>>b;
		cout<<a+b;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000;
i64 ps[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, q;
    cin >> n >> q;
    vi64 st;
    st.pb(n);
    forn(i, q) {
        i64 x;
        cin >> x;
        while (!st.empty() && st.back() > x) st.pop_back();
        st.pb(x);
    }
    int K = st.size();
    vi64 muls(K);
    muls[K - 1] = 1;
    ford(i, K) {
        if (!i) {
            ps[st[i]] += muls[i];
            break;
        }
        i64 t = muls[i];
//        muls[i] += t * (st[i + 1] / st[i]);
        i64 z = st[i];
        st[i] = 2e18;
        while (z > st[0]) {
            int i = lower_bound(all(st), z) - st.begin() - 1;
            muls[i] += t * (z / st[i]);
            z %= st[i];
        }
        ps[z] += t;
    }
    ford(i, n) ps[i] += ps[i + 1];
    for1(i, n) cout << ps[i] << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>

typedef long long ll;

const int N = 2e5 + 5;

int n, cntbc;
char s[N];
ll ans;

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = n; i >= 1; i--)
		if (s[i] == 'A') ans += cntbc;
		else if (s[i] == 'C' && s[i - 1] == 'B') cntbc++;
		else if (s[i] == 'C' || (s[i] == 'B' && s[i + 1] != 'C')) cntbc = 0;
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k, q;
	cin >> n >> k >> q;
	
	vector<int> a(q), cnt(n + 1, 0);
	for(int i = 0; i < q; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		if( q - cnt[i] < k ) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10**7)

N, K = map(int,input().split())
MOD = 10**9+7

combination = [[-1]*(N+1) for i in range(N+1)]

def comb(n, k):
    if n < k:
        return 0
    elif k == n or k == 0:
        return 1
    elif k == 1:
        return n
    elif combination[n][k] != -1:
        return combination[n][k]
    else:
        combination[n][k] = (comb(n-1,k-1)+comb(n-1,k))%MOD
        return combination[n][k]

for i in range(1,K+1):
    print(comb(N-K+1,i)*comb(K-1,i-1)%MOD)
    

Measured memory_bytes: 123740
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
using namespace std;
map<string,int> Mp;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		Mp[s]++;
	}
	int ans=0;
	for(map<string,int>::iterator it=Mp.begin();it!=Mp.end();it++){
		ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 19260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string s;
    cin >> s;
    
    int len = s.length();
    int count_0 = 0, count_1 = 0;
    rep(i, len){
        if(s.at(i)=='0') count_0++;
        else count_1++;
    }

    cout << 2*min(count_0, count_1) << endl;
    return 0;
}

Measured memory_bytes: 512
import math
def main():
  N=int(input())
  X=list(map(int,input().split()))
  x_mean=round(sum(X)/len(X))
  sumX=0
  for i in range(len(X)):
    sumX=sumX+(X[i]-x_mean)**2
  print(sumX)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char name[5],name1[5];
    scanf("%s",name);
    getchar();
    scanf("%s",name1);
    if(name[1]!=name1[1])
    {
        printf("NO\n");
        return 0;
    }
    if(name[0]!=name1[2])
    {
        printf("NO\n");
        return 0;
    }
    if(name[2]!=name1[0])
    {
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(void){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  // Use rotation matrix
  int x3 = x2+(y1-y2);
  int y3 = y2-(x1-x2);
  int x4 = x1-(y2-y1);
  int y4 = y1+(x2-x1);

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N = iRaw()
    As = isRaw()
    Vs = [1]
    sumA = sum(As)
    for d in range(N+1):
        if As[d] > Vs[d]:
            print(-1)
            return -1
        sumA-=As[d]
        Vs+=[min((Vs[d]-As[d])*2,sumA)]
    print(sum(Vs[:N+1]))

main()


Measured memory_bytes: 85932
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
int d;

int main()
{
  while(cin >> n, n){
    int sum = 0;
    int mn = INF;
    int mx = -INF;
    rep(i, n){
      cin >> d;
      sum += d;
      minup(mn, d);
      maxup(mx, d);
    }

    cout << (sum - mx - mn) / (n - 2) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;


int main()
{
    int N;
    cin >> N;
    vector<int> p(N+1);
    for( int i = 1; i <= N; ++i ) cin >> p[i];

    int ans = 0;
    for( int i = 1; i <= N; ++i ){
        if( p[i] == i ){
            ++ans;
            ++i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int k; cin >> k;
  ll num = 7;
  rep(i,k){
    if(num % k == 0){
      cout << i+1;
      return 0;
    }
    num *= 10;
    num += 7;
    num %= k;
  }
  cout << -1;
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        int min = arr[0];
        int max = arr[0];

        for(int j = 0; j < N; j++) {
            if(min >= arr[j]) {
                min = arr[j];
            }
            if(max <= arr[j]) {
                max = arr[j];
            }
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 21460
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
a=list(map(int,input().split()))
i=1
for j in range(len(a)):
    if(a[j]==i):
        i+=1
if(1 not in a):
    print(-1)
else:
    print(n-i+1)
        

Measured memory_bytes: 26012
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
p = list(map(float, readline().split()))
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1 - p[i])
print(sum(dp[-1][n // 2 + 1:]))


Measured memory_bytes: 253576
#include<bits/stdc++.h>
#define a 99999
main(){
while(true){
int x[a],n,i,j,k,l,m,y[a],b,c,d,p[a],minx;
scanf("%d", &n);
if(n==0){break;}
for(i=0;i<n;i++){scanf("%d", &y[i]);p[i]=x[i]=y[i];}
c=0;d=0;m=n;d=m;
minx=a;
for(i=0;i<n;i++){
for(j=1;j<=3;j++){
if(i>=1&&y[i-1]!=j&&y[i+1]!=j){goto z;}
p[i]=x[i]=j;b=1;d=n;
while(true){c=0;
for(k=0;k<m;k++){
if(p[k]==p[k+1]){b++;}
else{
if(b >= 4){
for(l=k+1;l<m;l++){p[l-b]=p[l];}
d -= b;c++;
for(l=d;l<m;l++){p[l]=0;}
}
b=1;}   
m=d;}
if(c==0){break;}
else{c=0;}
}
minx=std::min(minx,m);x[i]=y[i];
for(int k=0;k<n;k++){p[k]=y[k];}
z:;
}
}
printf("%d\n",minx);}
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;

int Tc;

int change(char ch){
  if(ch=='A')return 11;
  if('2'<=ch&&ch<='9')return ch-'0';
  else return 10;
}

int main(){
  cin>>Tc;
  while(Tc--){
    char a,b;
    cin>>a>>b;
    vector<int> v,t;
    v.push_back(change(a));
    v.push_back(change(b));
    for(int i=0;i<8;i++){
      cin>>a;
      t.push_back(change(a));
    }
    int ans=v[0]+v[1];
    if(ans==22)v[0]=1,ans=12;

    for(int i=0;i<8;i++){
      bool flg=false;
      for(int j=0;j<(int)v.size();j++)if(v[j]==11)flg=true;
      if(ans<=16 || (ans==17&&flg) ){
	v.push_back(t[i]);
	ans+=t[i];
	for(int j=0;j<(int)v.size();j++){
	  if(ans>21 && v[j]==11){
	    ans-=10;
	    v[j]=1;
	  }
	}
      }else break;
    }
    if(ans==21&&v.size()==2){
      cout<<"blackjack"<<endl;
    }else if(ans>21){
      cout<<"bust"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int H1, M1, H2, M2, K;
	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
	printf("%d\n", 60 * (H2 - H1) + (M2 - M1) - K);

	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long 

int n, dp[100005],arr[100005];

int recur( int index)
{

    //base case
    if (index == n - 1) return 0;
    if (index >= n) return INT_MAX;

    // look up
    if (dp[index] != -1) return dp[index];

    //recursive case

    int left = recur(index + 1) + abs(arr[index] - arr[index + 1]);

    int right = INT_MAX;
    if (index + 2 < n) right = recur(index + 2) + abs(arr[index] - arr[index + 2]);

    return dp[index] = min(left, right);
}

int32_t main()
{
    fast 
    cin >> n;

    memset(dp,-1,sizeof dp);

    for (int i = 0; i < n; i++) cin >> arr[i];

    cout << recur(0);

    return 0;

}

Measured memory_bytes: 9856
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c[200];
	while(cin>>a>>b){
	for(int i=0;i<200;i++)
		c[i]=0;
	c[a]++,c[b]++;
	while(true){
		cin>>a>>b;
		if(a==0&&b==0)
			break;
		c[a]++,c[b]++;
	}
	bool t=true;
	for(int i=3;i<200;i++){
		if(c[i]%2==1)
			t=false;
	}
	if(c[1]%2!=1||c[2]%2!=1)
		t=false;
	if(t==true)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
	}
    return 0;
}
 

Measured memory_bytes: 1152
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N;
    cin>>N;
    vector<int> divisor(1001,0);
    //1000までの階乗の約数
    //前処理？
    for(int i=1;i<=N;i++){
        int A=i,d=2;
        while(A!=1&&d<=A){
            if(A%d==0){
                A/=d;
                divisor[d]++;
            }
            else d++;
        }
    }

    ll ANS=1;
    REP(i,1,N+1){
        ANS*=(divisor[i]+1);
        ANS%=INF;
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int h, w, k; read(h, w, k);
	vector<string> v(h);
	rep(i, 0, h) read(v[i]);

	int ans = 0;
	rep(m1, 0, 1 << h)
		rep(m2, 0, 1 << w) {
			int cnt = 0;
			rep(i, 0, h) {
				rep(j, 0, w) {
					if (!(m1 & (1 << i)) && !(m2 & (1 << j)) &&
							v[i][j] == '#') cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	write(ans);
}


Measured memory_bytes: 3652
(defun solver ()
  (let* ((n (read)) (d (read)) (x (read))
         (ai (make-array n :fill-pointer 0))
         (sum x))
    (loop repeat n do
          (vector-push (read) ai))
    (loop for i from 0 below n do
          (incf sum (1+ (truncate (1- d) (aref ai i)))))
    (format t "~a~%" sum)))

(solver)


Measured memory_bytes: 16612
s = input()

i = 0
while i < len(s):
  i_init = i
  border_right = 0
  a = [0]*2
  while s[i] == 'R':
    a[i%2] += 1
    i += 1
    border_right = i
  while i < len(s) and s[i] == 'L':
    a[i%2] += 1
    i += 1
  for j in range(i_init, border_right-1):
    print(0, end=" ")
  print(a[(border_right-1)%2], a[border_right%2], end=" ")
  for j in range(border_right+1, i):
    print(0, end=" ")

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string n;
  cin>>n;
  if (n.find("7") != string::npos) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3596
# import time

# starttime=time.clock()

A,B,C =input().split()
a=int(A)
b=int(B)
c=int(C)
# print(a+c)
 
if a>b:
    temp = a
    a = b
    b = temp
if b>c:
    temp = b
    b = c
    c = temp
if (a+b)==c:
    print("Yes")
#     endtime = time.clock()
#     print(endtime-starttime)
else:
    print("No")
#     endtime = time.clock()
#     print(endtime-starttime)
#      


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    cout << 6 - a - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    string S;
    int K;
    cin >> S >> K;
    ll ans = 0;
    bool check = true;
    rep(i, S.size()-1) {
        if (S[i] != S[i+1]) {
            check = false;
            break;
        }
    }
    //全部同じ文字の場合
    if (check) {
        cout << S.size()*K/2 << endl;
        return 0;
    }
    char S1 = S[0];
    ll cnt1 = 1;
    rep2(i, 1, S.size()) {
        if (S[i] == S1) {
            cnt1++;
        }
        else {
            break;
        }
    }
    char S2 = S[S.size()-1];
    ll cnt2 = 1;
    for (int i = S.size()-2; i>=0; i--) {
        if (S[i] == S2) {
            cnt2++;
        }
        else {
            break;
        }
    }
    ll cnt = 0;
    ll res = 0;
    char next;
    rep(i, S.size()) {
        if (i == 0) {
            next = S[0];
            res += 1;
            continue;
        }
        if (S[i] == next) {
            res++;
        }
        else {
            cnt += res/2;
            next = S[i];
            res = 1;
        }
        if (i == S.size()-1) {
            cnt += res/2;
        }
    }
    if (S1 == S2) {
        cout << cnt*K - (cnt1/2 + cnt2/2 - (cnt1+cnt2)/2)*(K-1) << endl;
    }
    else {
        cout << cnt*K << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+c==2*b){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	string S;
	cin >> S;

	int ans = 0;
	for(int i = 0; i < 4; ++i){
		if(S[i] == '-') ans--;
		else ans++;
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 200003;
int n, m, len, x, y, cur;
char s[N], t[N];
int main(){
	scanf("%d%d%d%d%d%s%s", &n, &m, &len, &x, &y, s, t);
	cur = x;
	for(Rint i = 0;i < len;i ++){
		if(s[i] == 'U') -- cur;
		if(cur == 0){puts("NO"); return 0;}
		if(t[i] == 'D' && cur < n) ++ cur;
	}
	cur = x;
	for(Rint i = 0;i < len;i ++){
		if(s[i] == 'D') ++ cur;
		if(cur == n + 1){puts("NO"); return 0;}
		if(t[i] == 'U' && cur > 1) -- cur;
	}
	cur = y;
	for(Rint i = 0;i < len;i ++){
		if(s[i] == 'L') -- cur;
		if(cur == 0){puts("NO"); return 0;}
		if(t[i] == 'R' && cur < m) ++ cur;
	}
	cur = y;
	for(Rint i = 0;i < len;i ++){
		if(s[i] == 'R') ++ cur;
		if(cur == m + 1){puts("NO"); return 0;}
		if(t[i] == 'L' && cur > 1) -- cur;
	}
	puts("YES");
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int H,W;
	while (cin >> H >> W, H||W) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for (iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n) {
    while(n--) {
      int s,t;
      cin >> s >> t;
      vector<int> a;
      if(s<=5) {
	if(s<=t) {
	  while(s<=t) a.push_back(s++);
	} else {
	  while(s>=t) a.push_back(s--);
	}
      } else {
	if(t>=6 && s>t) {
	  while(s!=0) {
	    a.pb(s);
	    if(s>=6 && s<=9) s++;
	    else s--;
	    if(s==10) s=5;
	  }
	  while(s<=t) a.push_back(s++);	  
	} else {
	  while(1) {
	    a.pb(s);
	    if(s==t) break;
	    if(s>=6 && s<=9) s++;
	    else s--;
	    if(s==10) s=5;
	  }
	}
      }
      rep(i,a.size()) {
	if(i!=0) cout << " ";
	cout << a[i];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1216
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2002

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct rect {
	int min_w, max_w;
	int min_h, max_h;
	void update(int w, int h) {
		min_w = min(min_w, w); max_w = max(max_w, w);
		min_h = min(min_h, h); max_h = max(max_h, h);
	}
};

int h, w;
vector<vector<char>> bag;
vector<vector<char>> tmp;
vector<char> layer;	
map<char, rect> rects;

void fill_rect(char type) {
	rect rt = rects[type];
	for(int y = rt.min_h; y <= rt.max_h; ++y) {
		for(int x = rt.min_w; x <= rt.max_w; ++x) {
			tmp[y][x] = type;
		}
	}
	return;
}

bool is_safe() {
	rep(y, h) {
		rep(x, w) {
			if(tmp[y][x] != bag[y][x]) return false;
		}
	}
	return true;
}

int main() {
	int T;
	cin >> T;
	rep(i, T) {
		cin >> h >> w;
		bag.assign(h, vector<char>(w, '.'));
		rects.clear(); layer.clear();
		rep(y, h) {
			rep(x, w) {
				cin >> bag[y][x];
				if(bag[y][x] == '.') continue;
				if(rects.count(bag[y][x]) == 0) {
					rects[bag[y][x]] = {x, x, y, y};
					layer.push_back(bag[y][x]);
				} else {
					rects[bag[y][x]].update(x, y);
				}
			}
		}

		bool ok = false;
		sort(ALL(layer));
		do {
			tmp = bag;
			rep(i, layer.size()) {
				fill_rect(layer[i]);
			}
			if(is_safe()) { ok = true; break; }
		} while(next_permutation(ALL(layer)));
		
		cout << ((ok) ? "SAFE" : "SUSPICIOUS") << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
n = int(input())
a_n = list(map(int, input().split()))

a_n = sorted(a_n, reverse=True)

res = 0
for i in range(len(a_n)):
    if i % 2 == 0:
        res = res + a_n[i]
    else:
        res = res - a_n[i]
print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> Au(N);
    vector<int> Ab(N);
    for(int i = 0; i < N; i++){
        cin >> Au[i];
    }
    for(int i = 0; i < N; i++){
        cin >> Ab[i];
    }

    vector<int> sumAu(N);
    vector<int> sumAb(N);

    sumAu[0] = Au[0];
    for(int i = 0; i < N-1; i++){
        sumAu[i+1] = sumAu[i] + Au[i+1];
    }

    sumAb[N-1] = Ab[N-1];
    for(int i = N-1; i > 0; i--){
        sumAb[i-1] = sumAb[i] + Ab[i-1];
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        chmax(ans, sumAu[i]+sumAb[i]);
    }

    cout << ans << endl;

    
    return 0;
}



Measured memory_bytes: 256
def add_divisors(n, divisors):
    primes = [
        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
        43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
    ]
    for prime in primes:
        while True:
            if n % prime == 0:
                if prime in divisors.keys():
                    divisors[prime] += 1
                else:
                    divisors[prime] = 1
                n /= prime
            else:
                break

divisors = {}
n = int(input())
for i in range(1,n+1):
    add_divisors(i, divisors)

c74_ = 0

c24_ = 0
c2_23 = 0

c14_ = 0
c4_13 = 0

c4_ = 0
c2_3 = 0

for k in divisors.keys():
    if divisors[k] >= 74:
        c74_ += 1

    if divisors[k] >= 24:
        c24_ += 1
    elif divisors[k] >= 2:
        c2_23 += 1

    if divisors[k] >= 14:
        c14_ += 1
    elif divisors[k] >= 4:
        c4_13 += 1

    if divisors[k] >= 4:
        c4_ += 1
    elif divisors[k] >= 2:
        c2_3 += 1

ans = 0

# 75
if c74_ >= 1:
    ans += c74_

# 3*25
if c24_ >= 2:
    ans += c24_ * (c24_ - 1)
if c2_23 >= 1 and c24_ >= 1:
    ans += c2_23 * c24_

# 5*15
if c14_ >= 2:
    ans += c14_ * (c14_ - 1)
if c4_13 >= 1 and c14_ >= 1:
    ans += c4_13 * c14_

# 3*5*5
if c4_ >= 3:
    ans += c4_ * (c4_ - 1) * (c4_ - 2) // 2
if c2_3 >= 1 and c4_ >= 2:
    ans += c2_3 * c4_ * (c4_ - 1) // 2

print(ans)


Measured memory_bytes: 3064
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 10**18
for i in range(N - K + 1):
    x1 = X[i]
    x2 = X[i + K - 1]
    if x1 * x2 >= 0:
        dist = max(abs(x1), abs(x2))
    else:
        dist = min(abs(x1), abs(x2)) + abs(x1 - x2)
    ans = min(ans, dist)
print(ans)

Measured memory_bytes: 14384
#include <stdio.h>
#include <string.h>

int main (void)
{
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    if(b-a+1>=2*k)
    {
        for(int i=0;i<k;i++)
        {
            printf("%d\n",a+i);
        }
        for(int i=k-1;i>=0;i--)
        {
            printf("%d\n",b-i);
        }
    }else{
        for(int i=a;i<=b;i++)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}


Measured memory_bytes: 1700
#include<iostream>
using namespace std;

int main()
{
	long long N,a[109990],i,b[109000],m;
	while(cin>>N)
	{
		for(i=1;i<=N;i++)
		{
			cin>>a[i];
			m=a[i];
			b[m-1]=i;
		}
		for(i=0;i<N;i++)
		{
			cout<<b[i]<<" ";
		}
	}
}

Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
signed main() {
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); ) {
		if (s[i] != 'A') {
			i++;
			continue;
		}
		vector<int>v;
		int j = i;
		while ((j < s.size() && s[j] == 'A') || (j < s.size() - 1 && s[j] == 'B' && s[j + 1] == 'C')) {
			if (s[j] == 'A') {
				v.push_back(1);
				j++;
			}
			else {
				v.push_back(2);
				j += 2;
			}
		}
		int sum = 0;
		for (int i = v.size() - 1; i >= 0; i--) {
			if (v[i] == 2) {
				sum++;
			}
			else {
				ans += sum;
			}
		}
		i = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2680
#include <stdio.h>

long GCD(long a, long b){
  long dividend, divisor;
  if (a >= b) {
    dividend = a;
    divisor = b;
  } else {
    dividend = b;
    divisor = a;
  }
  long remainder;
  while (1) {
    if (divisor == 1) {
      return 1;
    }
    remainder = dividend % divisor;
    if (remainder == 0) {
      break;
    } else {
      dividend = divisor;
      divisor = remainder;
    }
  }
  return divisor;
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long t[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &t[i]);
  }
  long answer = t[0];
  for (long i = 1; i < n; i++) {
    answer = answer/GCD(answer,t[i])*t[i];
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

const int MAX_A = 1e6;

int main(){
   int N;
   std::cin >> N;
   std::vector<int> A(N);
   bool dp[MAX_A+1];
   std::fill(dp, dp+MAX_A+1, true);
   for(int i=0; i<N; ++i){
      std::cin >> A[i];
   }
   std::sort(A.begin(), A.end());

   int ans = 0;
   for(int i=0; i<N; ++i){
      if(i<N-1 && A[i]==A[i+1]) {
	 dp[A[i]] = false;
	 continue;
      }
      int x = A[i] * 2;
      while(x<=MAX_A){
	 dp[x] = false;
	 x += A[i];
      }
      if(dp[A[i]]) ++ans;
   }

   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string str;
        cin >> str;
        sort(all(str));
        mp[str]++;
    }
    ll ans = 0;
    for (auto e : mp) ans += (ll)e.S * (e.S - 1) / 2;
    out(ans);
}


Measured memory_bytes: 11264
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int func(int b[], int n)
{
	int s = 0;
	for(int i=0;i<n-1;i++)
	{
		s = s+abs(b[i]-b[i+1]);
	}
	return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 //   freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
    int x;
    cin>>x;
    if(x==7||x==5||x==3)
    	cout<<"YES";
    else
    	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char a[100][100];
int main()
{
	ll h,w;
	cin>>h>>w;
	bool sign=false;

	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]=='#')
			{
				if( a[i+1][j]=='.' && a[i][j+1]=='.'&&a[i-1][j]=='.'&&a[i][j-1]=='.'){
					sign=true;
			
				}
			}
		}
	}


	if(sign)
		puts("No");
	else 
		puts("Yes");
		
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a >= 10 || b >= 10){
        System.out.println(-1);
    }else{
        System.out.println(a*b);
    }
    
    
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  char s;cin>>s;
  if('a'<=s&&s<='z'){
    s='a';
  }else{
    s='A';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3032