akhauriyash/Code-Regression huggingface dataset:
import collections

n = int(input())
a = list(map(int, input().split()))

plus = []
minus = []

for i in a:
    minus.append(i-1)
    plus.append(i+1)

all_l = a + minus + plus
ans = collections.Counter(all_l)
print(ans.most_common(1)[0][1])

Measured memory_bytes: 30664
open Scanf
open Printf
open Array

let max_i64,(++),i64 = Int64.(max_int,add,of_int)

let () = scanf " %d" @@ fun l ->
  let a = init l (fun _ -> scanf " %d" @@ fun v -> v) in
  let dp = make_matrix (l+1) 5 max_i64 in
  let f typ v = i64 @@
    match typ with
    | 0 | 4 -> (* zero *)
      v
    | 1 | 3 -> (* even >= 2 *)
      if v=0 then 2
      else if v mod 2 = 0 then 0 else 1
    | 2 | _ -> (* odd *)
      if v mod 2 = 1 then 0 else 1
  in
  let update i j v =
    dp.(i).(j) <- min dp.(i).(j) v
  in
  for k=0 to 4 do
    dp.(0).(k) <- 0L;
  done;
  for i=1 to l do
    for k=0 to 4 do
      for j=k to 4 do
        update i j @@ dp.(i-1).(k) ++ f j a.(i-1)
      done
    done
  done;
  (* iter (fun b ->
    iter (printf "%2Ld ") b;
    print_newline ()
  ) dp; *)
  printf "%Ld" @@ fold_left min max_i64 dp.(l)




Measured memory_bytes: 41024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[a[i]-1] == i+1){
            ans++;
        }
    }
    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<pii,int>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

ll x,nw;

int main(){
//	cout<<fixed<<setprecision(10);
//	freopen("input.txt", "r", stdin);
//	freopen("astar.out","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>x;
    rep(i,1,30000000){
    	nw = nw*10+7;
    	if(nw>=x){
    		nw%=x;
    		if(!nw)return cout<<i<<endl,0;
		}
	}
	cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(){
    int n; cin>>n;
    
    int dp[110][4][4][4]; //[ここまでの方法の数][三文字前][二文字前][一文字前]
    
    dp[0][3][3][3] = 1; //探索時、i==1の時に　”+1だけ” するため
    
    //0...A, 1...C, 2...G, 3...T とする
    for(int i=1; i<=n; i++){//i文字目までの方法
        rep(j,4){//3文字前
            rep(k,4){//2文字前
                rep(l,4){//1文字前
                    //i文字目をXとする
                    if(j==0 and k==1 and l==2)continue; //ACGX その前の三文字がACGはだめ！
                    if(j==0 and k==2 and l==1)continue; //AGCX
                    if(j==2 and k==0 and l==1)continue; //GACX
                    
                    rep(m,4){//Xの四通り
                        
                        if(j==0 and l==2 and m==1)continue; //A?GC
                        if(j==0 and k==2 and m==1)continue; //AG?C
                        if(k==0 and l==1 and m==2)continue; //?ACG
                        if(k==0 and l==2 and m==1)continue; //?AGC
                        if(k==2 and l==0 and m==1)continue; //?GAC
                        
                        dp[i][k][l][m] += dp[i-1][j][k][l]; //OK!!!!!
                        dp[i][k][l][m] %= mod; //忘れずに余りを求めておく
                        
                    }
                }
            }
        }
    }
    
    int ans = 0; //答え
    
    //dp[n][0...3][0...3][0...3]を全て足す！
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans += dp[n][i][j][k];
                ans %= mod; //余りを求める
            }
        }
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in(), h = in(), w = in();
	ll ans = 0;
	REP(i, n) {
		ll a = in(), b = in();
		if (a >= h && b >= w)++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_not_found(void) {
	int x[140] = { 0 };
	string s;
	int num=0;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		x[s[i]]++;
	}
	for (int i = 97; i < 97 + 26; i++) {
		if (x[i] == 0) {
			num = i;
			break;
		}
	}
	if (num == 0) cout << "None" << endl;
	else          printf("%c\n", num);

}

int main()
{
	b_not_found();
    return 0;
}


Measured memory_bytes: 3856
#include<cstdio>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int f[8] = {}, c = 0;
	for(int i = 0; i < n; i++){
		int a; scanf("%d", &a);
		if(a >= 3200) c++;
		else f[a / 400] = 1;
	}
	int s = count(f, f + 8, 1);
	printf("%d %d\n", max(1, s), s + c);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int helper(int n)
{
	int temp=0;
	while(n)
	{
		temp += n%10;
		n /= 10;
	}
	return temp;
}
int main()
{
      int n,a,b;cin>>n>>a>>b;
      int count=0;
      for(int i=1;i<=n;i++)
      {
      	int q=helper(i);
      	if(q>=a && q<=b)
      	{
      		count+=i;
      		
      	}
      }
      cout<<count;
       return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int cntg = 0;
  int cntp = 0;
  int cnty = 0;
  int cntw = 0;
  cin >> n ;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "G") {
      cntg = 1;
    }
    else if (s == "Y") {
      cnty = 1;
    }
    else if (s == "P") {
      cntp = 1;
    } 
    else {
      cntw = 1;
    }
  }
  int res = cntg + cntw + cnty + cntp;
  if (res == 1) {
    cout << "One" << endl;  
  }
  else if (res == 2) {
    cout << "Two" << endl;  
  }
  else if (res == 3) {
    cout << "Three" << endl;  
  }
  else if (res == 4) {
    cout << "Four" << endl;  
  }
 
}

Measured memory_bytes: 3604
n, k = map(int, input().split())
s = input()

key = [0]
for i in range(1, n):
  if s[i] != s[i-1]:
    key.append(i)
key.append(n)

m, r = 0, len(key)-1
ans = 0
while True:
  if m == 0 and s[0] == "0":
    p = m+2*k
    if ans < key[min([p, r])] - key[m]:
      ans = key[min([p, r])] - key[m]
    m += 1
  else:
    p = m+2*k+1
    if ans < key[min([p, r])] - key[m]:
      ans = key[min([p, r])] - key[m]
    m += 2
  if p >= r:
    break

print(ans)

Measured memory_bytes: 7236
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

void solve(){
	int  n;
	cin >> n;
	string s;
	cin >> s;
	int red = 0;
	int white = 0;
	int inv = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R')red++;
		else white ++;
		if(i > 0){
			if(s[i] == 'R' && s[i - 1] == 'W') inv++;
		}
	}
	if(red == 0 || white == 0 || inv == 0){
		cout << "0\n";
		return ;
	}
	int ans = 0;
	int left = 0, right = n - 1;
	while(left < right){
		if(s[left] == 'W' && s[right] == 'R'){
			ans++;
			left++;
			right--;
		}
		else if(s[left] == 'R') left++;
		else if(s[right] == 'W')right--;
	}
	cout << ans << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main() {
	long long int a;
	cin >> a;
	int counter = 0;
	while (a > 1) {
		counter++;
		if (a % 3 == 0) {
			a /= 3;
		} else {
			a /= 3;
			a++;
		}
	}
	cout << counter << endl;
	return 0;
}

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

using namespace std;

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

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H)
		cout << "Yes\n";
	else cout << "No\n";

	return 0;
} // br1



Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <cmath>

#define rep(a, b) for(int a  = 0; a < b; a++)
#define repr(a, b) for(int a = b; a >= 0; a++)

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int size = (N + 1) / 2;
    int count[size];
    rep(i, (N + 1) / 2) count[i] = 0;
    if (N % 2 == 0) {
        rep(i, N) {
            if (A[i] % 2 != 1) {
                cout << 0 << endl;
                return 0;
            }
            int index = A[i] / 2;
            if (0 > index || index >= size) {
                cout << 0 << endl;
                return 0;
            }
            count[index] += 1;
            if (count[index] > 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        long long ans = 1;
        rep(i, N / 2) {
            ans *= 2;
            ans %= 1000000007;
        }
        cout << ans << endl;
    } else {
        rep(i, N) {
            if (A[i] % 2 == 1) {
                cout << 0 << endl;
                return 0;
            }
            int index = A[i] / 2;
            if (0 > index || index >= size) {
                cout << 0 << endl;
                return 0;
            }
            count[index] += 1;
            if (index == 0) {
                if (count[0] > 1) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            if (count[index] > 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        long long ans = 1;
        rep(i, N / 2) {
            ans *= 2;
            ans %= 1000000007;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

class UnionFind{
public:
	vector<int>T;
	vector<int>p;
	UnionFind(int n){
		T.resize(n);
		p.resize(n);
		for(int i=0;i<n;i++){
			p[i]=i;
		}
	}
	
	int getParent(int n){
		if(p[n]==n)return n;
		return getParent(p[n]);
	}
	bool isSame(int n,int m){
		return getParent(n)==getParent(m);
	}
	void unite(int n,int m){
		int rx=getParent(n);
		int ry=getParent(m);
		p[rx]=ry;
	}
};
	
int main(){
	init();
	ll H,W;cin>>H>>W;
	ll ans=INF;
	
	//vertical
	if(H%3==0)ans=min(ans,0LL);
	else ans=min(ans,W);
	
	//side
	if(W%3==0)ans=min(ans,0LL);
	else ans=min(ans,H);
	
	ll h=H/3;
	ll _h=H-h;
	ll S=h*W;
	for(int i=0;i<=W;i++){
		ll S1=_h*i;
		ll S2=_h*(W-i);
		ll num=max(S,max(S1,S2))-min(S,min(S1,S2));
		ans=min(ans,num);
	}
	
	h=H/3+1;
	_h=H-h;
	S=h*W;
	for(int i=0;i<=W;i++){
		ll S1=_h*i;
		ll S2=_h*(W-i);
		ll num=max(S,max(S1,S2))-min(S,min(S1,S2));
		ans=min(ans,num);
	}
	
	
	swap(H,W);
	
	
	h=H/3;
	_h=H-h;
	S=h*W;
	for(int i=0;i<=W;i++){
		ll S1=_h*i;
		ll S2=_h*(W-i);
		ll num=max(S,max(S1,S2))-min(S,min(S1,S2));
		ans=min(ans,num);
	}
	
	h=H/3+1;
	_h=H-h;
	S=h*W;
	//cout<<h<<S;
	for(int i=0;i<=W;i++){
		ll S1=_h*i;
		ll S2=_h*(W-i);
		//cout<<S1<<S2<<endl;
		ll num=max(S,max(S1,S2))-min(S,min(S1,S2));
		ans=min(ans,num);
	}
	
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inv2 500000004

long long modpow(long long n, long long r) {
    n %= mod, r %= (mod-1);
    if (!n) return 0;
    long long ret = 1; long long tmp = n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

auto getdiv = [&](long long n) {
    vector<long long> g;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            g.emplace_back(i);
            if (n != i * i) g.emplace_back(n / i);
        }
    }
    sort(g.begin(), g.end());
    return g;
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n, k; cin >> n >> k;
    auto g = getdiv(n);
    int sz = g.size();
    vector<long long> w(sz, 0);
    auto f = [&](long long x) {
        return modpow(k, (x+1)/2);
    };
    for (int i = 0; i < sz; i++) {
        w[i] += f(g[i]); w[i] %= mod;
        for (int j = i+1; j < sz; j++) {
            if (g[j] % g[i] == 0) {
                w[j] += mod - w[i];
                w[j] %= mod;
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < sz; i++) {
        if (g[i] % 2 == 0) w[i] = w[i] * inv2 % mod;
        ans += w[i] * g[i] % mod;
    }
    cout << ans % mod << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1000000000;

int main() {
  while(1){
    int w,h;
    cin>>w>>h;
    if (!w) break;
    vector<vector<vector<int>>> graph(h, vector<vector<int>>(w));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w-1; ++j) {
        int f;
        cin >> f;
        if (f == 0) {
          graph[i][j].push_back(i*w+j+1);
          graph[i][j+1].push_back(i*w+j);
        }
      }
      if (i != h - 1) {
        for (int j = 0; j < w; ++j) {
          int f;
          cin >> f;
          if (f == 0) {
            graph[i][j].push_back((i+1)*w+j);
            graph[i+1][j].push_back(i*w+j);
          }
        }
      }
    }
    queue<int> q;
    q.push(0);
    vector<int> dist(w*h, INF);
    dist[0] = 1;
    while (!q.empty()) {
      int e = q.front();
      q.pop();
      int i = e / w;
      int j = e % w;
      for (int to : graph[i][j]) {
        if (dist[to] > dist[e] + 1) {
          dist[to] = dist[e] + 1;
          q.push(to);
        }
      }
    }
    if (dist[w*h-1] == INF) {
      cout << 0 << endl;
    } else {
      cout << dist[w*h-1] << endl;
    }
  }
  return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    LL index = 0;
    LL x = 0;
    LL count = 0;
    REP(i, s.size()) {
        if(s[i] == 'W') {
            x += i;
            count++;
        }
    }
    LL y = (count - 1)*count/2;
    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 640
l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())


for _ in range(n):
    b, f, r, v = map(int,input().split())
    l[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {l[i][j][k]}', end='')
        print()
    if i != 3: print('#' * 20)


Measured memory_bytes: 5640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);

//main function
int main() {
    char s[10], stack[10];
    int p = 0, i;
    stin(s);

    REP(i,10) {
        stack[i] = 'C';
    }

    REP(i,strlen(s)) {
        if (s[i] == '0') {
            stack[p] = '0';
            p++;
        } else if (s[i] == '1') {
            stack[p] = '1';
            p++;
        } else if (s[i] == 'B') {
            if (p > 0) {
                p--;
            }
        }
//        printf("p = %d, s = %s\n", p, stack);
    }

    REP(i,p) {
        printf("%c", stack[i]);
    }
    printf("\n");

    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}


Measured memory_bytes: 128
from sys import stdin
def main():
    n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i in range(0, n - 1):
        for j in range(i + 1, n):
            ans += d[i] * d[j]
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] alps = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        char[] s = sc.next().toCharArray();
        for(char c : alps){
            boolean bool = false;
            for(int i = 0; i < s.length; i++){
                if(s[i] == c){
                    bool = true;
                    break;
                }
            }
            if(!bool){
                System.out.println(new String(s) + c);
                return;
            }
        }
        ArrayList<Character> cl = new ArrayList<Character>();
        for(int i = 25; i > 0; i--){
            cl.add(s[i]);
            if(s[i] - s[i-1] > 0){
                Collections.sort(cl);
                for(char c : cl){
                    if(s[i-1] - c < 0){
                        s[i-1] = c;
                        String ans = new String(Arrays.copyOfRange(s,0,i));
                        System.out.println(ans);
                        return;
                    } 
                }
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 23764
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
sortedA = sorted(A)

count = 1
oddA = []
for i in range(len(sortedA)):
    if i+1==len(sortedA):
        if count%2==1:
            oddA.append(sortedA[i])
        count = 1
    else:
        if sortedA[i]==sortedA[i+1]:
            count += 1
        else:
            if count%2==1:
                oddA.append(sortedA[i])
            count = 1

print(len(oddA))

Measured memory_bytes: 8904
#include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll q[maxn],p[maxn],r[maxn];
bool cmp(int x, int y){
    return x>y;
}
int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;++i)
        cin>>q[i];
    for(int i=1;i<=b;++i)
        cin>>p[i];
    for(int i=1;i<=c;++i)
        cin>>r[i];
    sort(q+1,q+a+1,cmp);
    sort(p+1,p+b+1,cmp);
    sort(r+1,r+c+1,cmp);
    ll ans=0;
    for(int i=1;i<=x;++i)
        ans+=q[i];
    for(int j=1;j<=y;++j)
        ans+=p[j];
    int i=x,j=y;
    for(int k=1;k<=c;++k){
        if(i>0&&j>0){
            if(r[k]>=q[i]&&r[k]>=p[j]){
                if(r[k]-q[i]>r[k]-p[j]){
                    ans=ans-q[i]+r[k];
                    i--;
                }
                else{
                    ans=ans-p[j]+r[k];
                    j--;
                }
            }
            else if(r[k]>=q[i]){
                ans=ans-q[i]+r[k];
                i--;
            }
            else if(r[k]>=p[j]){
                ans=ans-p[j]+r[k];
                j--;
            }
            else break;
        }
        else if(i>0){
            if(r[k]>=q[i]){
                ans=ans-q[i]+r[k];
                i--;
            }
            else break;
        }
        else if(j>0){
            if(r[k]>=p[j]){
                ans=ans-p[j]+r[k];
                j--;
            }
            else break;
        }
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
  int i,j,k,n;
  while(scanf("%d",&n)!=EOF){
    int count=0;
    for (i=0;i<=9;i++){
      for (j=0;j<=9;j++){
        for (k=0;k<=9;k++){
          if ((0<=n-i-j-k) && (n-i-j-k<=9)){
            count++;
          }
        }
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int A, B, a, b;
    std::cin >> A >> B;
    a = 12.5 * A+0.5;
    b = 10 * B;
    if (std::abs(a - b + 0.5) <= 10)
    {
        std::cout << std::max(a, b) << std::endl;
    }
    else
    {
        std::cout << -1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    int d = 0;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];

    int ans = 1;
    for(int i=0; i<n; i++){
        d += v[i];
        if(d <= x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from random import randrange

def eratosthenes(size):
    table = [True] * (size + 1)
    table[0] = table[1] = True
    for i in range(2, int(round(pow(size+1, 0.5)))):
        if not table[i]:
            continue
        for j in range(i + i, size+1, i):
            table[j] = False
    return table

def miller_rabin(n, k=20):
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    d = n - 1
    while d & 1 == 0:
        d >>= 1
    for _ in range(k):
        a = randrange(1, n)
        y = pow(a, d, n)
        t = d
        while (t != n - 1) and (y != 1) and (y != n - 1):
            y = pow(y, 2, n)
            t <<= 1
        if (y != n - 1 ) and ((t & 1) == 0):
            return False
    return True

if __name__ == "__main__":
    N = int(input())
    print(sum(map(miller_rabin, [int(input()) for _ in range(N)])))

Measured memory_bytes: 11956
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n, x, a[100010];
	long long cnt = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			if (a[i] >= x) {
				cnt += a[i] - x;
				a[i] = x;
				cnt += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				cnt += a[i] + a[i + 1] - x;
				a[i + 1] = x - a[i];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



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

    ll n; cin>>n; ll ans;
    vll a(n); REP(i,n) cin>>a[i];
    ll sum=accumulate(ALL(a),0LL);
    ans=sum;
    ll sub=0;
    REP(i,n){
        sub+=a[i];
        ans =min(abs(sub-abs(sum-sub)), ans);

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll dpos[100005][20]={0};
int main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  vec.push_back(0);
  for(int i=1;i<=n;i++){
    ll x;
    cin>>x;
    vec.push_back(x);
  }
  ll L;
  cin>>L;
  for(int i=1;i<=n;i++){
    ll npos=upper_bound(vec.begin(),vec.end(),vec[i]+L)-vec.begin();
    npos--;
    if(npos<=i||npos>n) dpos[i][0]=-1;
    else dpos[i][0]=npos;
  }
  for(int k=1;k<20;k++){
    for(int i=1;i<=n;i++){
      if(dpos[i][k-1]==-1) dpos[i][k]=-1;
      else dpos[i][k]=dpos[dpos[i][k-1]][k-1];
    }
  }

  ll q;
  cin>>q;
  for(int i=0;i<q;i++){
    ll a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    ll lb=0,rb=n+5;
    while(rb-lb>1){
      ll mid=(lb+rb)/2;
      ll max_goal=a;
      for(int k=0;k<20;k++){
        if(((mid>>k)&1)==1){
          max_goal=dpos[max_goal][k];
          if(max_goal==-1) max_goal=n;
        }
      }
      if(max_goal>=b) rb=mid;
      else lb=mid;
    }
    cout<<rb<<endl;
  }
}


Measured memory_bytes: 17396
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>>
#define vll vector <pair<ll,ll>>
#define vi vector <int>
#define vl vector <ll>
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;



int main()
{
    IOS;

  string s,t;
  cin>>s>>t;

  int n=s.length();
  int m=t.length();


int dp[3001][3001]={0};


  f1(i,m){
    f1(j,n){
      if(s[j-1]==t[i-1]){
        dp[i][j]=max(dp[i-1][j],1+dp[i-1][j-1]);
      }else{
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      }
    }
  }

  int i=m,j=n;
vector <char> ans;
  while(dp[i][j]!=0){
    if(dp[i][j]==dp[i][j-1])
     j--;
     else if(dp[i][j]==dp[i-1][j])
     i--;
     else{
       ans.push_back(t[i-1]);
       i--;
       j--;
     }
  }

  int k=ans.size();
  k--;
  for(int i=k;i>=0;i--) cout<<ans[i];
    return 0;
    }


Measured memory_bytes: 35712
#include <stdio.h>
int main(){
	int A1;
	int A2;
	int A3;
	int total;
	
	scanf ("%d %d %d",&A1, &A2, &A3);

	total = A1+A2+A3;
	if (total >= 22) {
		printf ("bust\n");
	}
	else {
		printf("win\n");
	}
	
	
	
	return 0;
}

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

int main() {
   int n,a,b[7];
   while (cin >> n && n>0) {
	  for (a=0;a<7;a++) b[a]=0; 
	  for (;n>0;n--) {
		  cin >> a;
		  if (a>59) b[6]++; else b[a/10]++;
	  }
	  for (a=0;a<7;a++) cout << b[a] << endl;
  }  
return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;

public class Main
{
  	int n, sum = 0;
  	int[] w;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      w = new int[n];
      for (int i = 0; i < n; i++)
        sum += (w[i] = in.nextInt());
      int min = 1+sum;
      for (int i = 1; i < n; i++)
      {
        int s1 = 0;
        for (int j = 0; j < i; j++)
          s1 += w[j];
        min = Math.min(min, Math.abs((sum-s1)-s1));
      }
      out.println(min);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}


Measured memory_bytes: 23252
N, M = map(int, input().split())
A, B = [], []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
ans = 'No'
end = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        temp = []
        for k in range(M):
            temp.append(A[i+k][j:j+M])
        if temp == B:
            ans = 'Yes'
            end = 1
            break
    if end == 1:
        break
print(ans)

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

int main()
{
    int x;
    cin >> x;
   	int j;

   	bool isPrime = false;
   	int i = x;
   	while( !isPrime)
   	{
   		for(j = 2; j <= sqrt(i); j++)
   		{
   			if(i % j == 0)
   				break;
   		}
   		if(j == (int)sqrt(i) + 1)
   		{
   			isPrime = true;
   			break;
   		}
   		i ++;
   	}
   	cout << i << endl;
}

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

int main(){
    int N,M;
    cin>>N>>M;
    
    vector<int> H(N);
    vector<bool> F(N,true);
    
    for(int i=0;i<N;++i)cin>>H[i];
    
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        --a;--b;
        
        if(H[a]>H[b])F[b]=false;
        else if(H[a]<H[b])F[a]=false;
        else F[a]=F[b]=false;
    }
    
    int ans=count(F.cbegin(),F.cend(),true);
    cout<<ans<<endl;
}


Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const int INF = 0x7FFFFFFF;
const double PI = acos(-1);
const double EPS = 1e-10;

int main(){
  int n,t,a;
  cin >> n >> t >> a;
  vi h(n);
  REP(i,n) cin >> h[i];
  int st = (t-a) * 1000;
  int i,b,c;
  int ans = 0;
  b = INF;
  for ( i = 0; i < n; i++) {
    c = abs(st-6*h[i]);
    if (b > c) {
      b = c;
      ans = i;
    }
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int digit(ll n) {
	int res = 1;
	while (n >= 10) {
		n /= 10;
		res++;
	}
	return res;
}

int main() {
	ll N;
	cin >> N;
	ll a = digit(N); // Nの桁数
	ll b = 1;
	for (int i = 0; i < a - 1; i++) b *= 10;
	ll c = N / b; // Nの最高位の数

	if ((N + 1) % b == 0 ) cout << 9 * (a-1)+c; // N = c999...99
	else {
		cout << 9 * (a - 1) + c - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string S;
int main() {
	cin >> S;
	for (int i = 0; i < S.length(); i++) {
		if (i % 2 == 0) {
			if (S[i] != 'h') {
				cout << "No";
				return 0;
			}
		}
		else {
			if (S[i] != 'i') {
				cout << "No";
				return 0;
			}
		}
	}
	if (S[S.length() - 1] != 'i') {
		cout << "No";
		return 0;
	}

	cout << "Yes";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;
typedef unsigned long long ull;

#define F first
#define S second
#define en end()
#define bg begin()
#define rev reverse
#define mp make_pair
#define pb push_back
#define y1 y1234567890
#define um unordered_map
#define all(x) x.bg, x.en
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 55;

ll dp[N][2];
int n, p, a[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	cin >> n >> p;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	dp[0][0] = 1;

	for (int i = 1; i <= n; i++) {
		dp[i][0] += dp[i - 1][0];
		dp[i][1] += dp[i - 1][1];
		dp[i][(0 + a[i]) % 2] += dp[i - 1][0];
		dp[i][(1 + a[i]) % 2] += dp[i - 1][1];
	}

	cout << dp[n][p];

	return 0;
}


Measured memory_bytes: 384
n = int(input())

dp = [float("inf")] * (n + 1)

dp[0] = 0

for i in range(n):
    six = 1
    while i + six <= n:
        dp[i + six] = min(dp[i + six], dp[i] + 1)
        six *= 6

    nine = 1
    while i + nine <= n:
        dp[i + nine] = min(dp[i + nine], dp[i] + 1)
        nine *= 9

print(dp[n])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a >= k)
	{
	    cout << k;
	    return 0;
	}
	else if(a+b >= k)
	{
	    cout << a;
	    return 0;
	}
	else
	{
	    cout << a - (k - b - a);
	    return 0;
	}
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

// a/b - 1/c
// ac/bc - b/bc
// (ac-b) / bc

inline pll sub(pll a, pll b) {
  pll ret = {a.first * b.second - a.second * b.first, a.second * b.second};
  ll g = __gcd(abs(ret.first), abs(ret.second));
  ret.first /= g;
  ret.second /= g;
  return ret;
}

void solve() {
  ll k;
  cin >> k;
  for(int h = 1; h <= 3500; h++) {
    for(int n = h; n <= 3500; n++) {
      pll curr = {4, k};
      curr = sub(curr, {1, h});
      curr = sub(curr, {1, n});
      if(curr.first == 1) {
        cout << h << " " << n << " " << curr.second << "\n";
        return;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr int M = 80;
    int h, w; cin >> h >> w;
    
    auto x = make_v(h, w, 0);

    REP(i, h)REP(j, w) {
        int a; cin >> a;
        x[i][j] += a;
    }

    REP(i, h)REP(j, w) {
        int b; cin >> b;
        x[i][j] -= b;
    }

    const int N = M * M * 3;

    auto dp = make_v(h + 1, w + 1, N * 2, false);
    dp[0][0][x[0][0] + N] = dp[0][0][-x[0][0] + N] = true;

    REP(i, h)REP(j, w)REP(k, N * 2) {
        if (!dp[i][j][k]) continue;

        if (i + 1 < h) {
            dp[i + 1][j][k - x[i + 1][j]] = dp[i + 1][j][k + x[i + 1][j]] = true;
        }

        if (j + 1 < w) {
            dp[i][j + 1][k - x[i][j + 1]] = dp[i][j + 1][k + x[i][j + 1]] = true;
        }
    }

    int ans = numeric_limits<int>::max();

    REP(k, N * 2) {
        if (dp[h - 1][w - 1][k]) {
            ans = min(ans, abs(k - N));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31744
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int a[10];
int main()
{
	int a1,a2,a3,b1,b2,b3;
	read(a1);read(b1);
	read(a2);read(b2);
	read(a3);read(b3);
	a[a1]++;a[b1]++;
	a[a2]++;a[b2]++;
	a[a3]++;a[b3]++;
	for (int i=1;i<=4;i++)
		if (a[i]==0||a[i]>2) return puts("NO"),0;
	puts("YES");
	return 0;
}









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

using namespace std;

vector <int> Solve(int n, int u, int v)
{
    vector <int> res;
    if (n == 0) return res = {u, v};
    if ((u>>n) == (v>>n)) {
        int Z = (1<<n) & u;
        vector <int> vec = Solve(n-1, u^Z, v^Z);
        vector <int> _vec = Solve(n-1, vec[0], vec[1]);
        res.push_back(vec[0]^Z);
        for (int i : _vec) res.push_back(i^(1<<n)^Z);
        for (int i = 1; i < vec.size(); i++) res.push_back(vec[i]^Z);
    }
    else {
        int Z = (1<<n) & u, ZZ = Z^(1<<n);
        vector <int> vec = Solve(n-1, u^Z, __builtin_popcount(u^Z)&1^1);
        vector <int> _vec = Solve(n-1, __builtin_popcount(v^ZZ)&1^1, v^ZZ);
        for (int i : vec) res.push_back(i^Z);
        for (int i : _vec) res.push_back(i^ZZ);
    }
    return res;
}
int main()
{
    int n, a, b; cin >> n >> a >> b;
    if ((__builtin_popcount(a)&1) == (__builtin_popcount(b)&1)) return cout << "NO\n", 0;
    cout << "YES\n";
    vector <int> ans = Solve(n - 1, a, b);
    for (int i : ans) cout << i << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 1628
LL = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

kk = ARGF.gets.chomp.to_i

puts LL[kk - 1]


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 

int ceil(int a, int m){
    // division of a and m
    if(a % m == 0){
        return a/m; 
    }
    else{
        return a/m + 1; 
    }
}

vector<int> sort(vector<int> arr){
    sort(arr.begin(), arr.end()); 
    return arr; 
}

int minInVector(vector<int> arr){
    int mins = 1e9; 
    for(int i = 0; i<arr.size(); i++){
        mins = min(mins, arr[i]); 
    }
    return mins; 
}

int maxInVector(vector<int> arr){
    int maxs = -1; 
    for(int i = 0; i<arr.size(); i++){
        maxs = max(maxs, arr[i]); 
    }
    return maxs; 
}

bool checkElement(vector<int> arr, int k){
    for(int i = 0; i<arr.size(); i++){
        if(arr[i] == k){
            return true; 
        }
    }
    return false; 
}


void solve(){
int n,x,t;
cin >> n >> x >> t; 
cout << ceil(n,x) * t; 
}

char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 



int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL); 

/*
For array arr use the following preamble to sort
int diff = sizeof(arr)/sizeof(arr[0]); 
sort(arr, arr + diff); 

*/

solve(); 


}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n;
    cin>>n;

    int preva,a;
    cin>>preva;//先頭の値
    int f = -1;
    int ans = 1;

    rep(i,0,n-1){
        cin >> a;
        if((f==0 && preva>a) || (f==1 && preva<a)){
            f=-1;
            ans++;
        }else if(f==-1 && preva != a){
            f = (preva<a)?0:1;
            //増加は0,減少は1
        }
        preva=a;
    }
    cout<<ans<<endl;
}


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

using namespace std;


int main () {

	ios_base :: sync_with_stdio (0); cin.tie (NULL);

	map <string, int> mp;

	mp["SUN"] = 7;
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;

	string s;
	cin >> s;

	if (s == "SUN") {
		cout << 7 << '\n';
		return 0;
	}

	cout << abs(mp["SUN"] - mp[s]) << '\n';


	return 0;
}





Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::VecDeque;
const INF: usize = 999999999999;

fn main() {
    input! {
        h:usize,w:usize,
        sh:Usize1,sw:Usize1,
        gh:Usize1,gw:Usize1,
    }
    let mut v = vec![vec![true; w]; h];
    let mut table = vec![vec![INF; w]; h];
    for r in 0..h {
        input! {
            s:Chars
        }

        for (i, &x) in s.iter().enumerate() {
            if x == '#' {
                v[r][i] = false;
            }
        }
    }
    let mut q = VecDeque::new();
    q.push_front((sh, sw, 0));
    while !q.is_empty() {
        let (y, x, c) = q.pop_front().unwrap();
        if table[y][x] <= c {
            continue;
        }
        table[y][x] = c;
        for i in -2..=2_isize {
            for j in -2..=2_isize {
                let walk = i.abs() == 0 && j.abs() == 1 || j.abs() == 0 && i.abs() == 1;
                let fy = i + y as isize;
                let fx = j + x as isize;
                if fy < 0 || fy >= h as isize || fx < 0 || fx >= w as isize {
                    continue;
                }
                let fy = fy as usize;
                let fx = fx as usize;
                if !v[fy][fx] {
                    continue;
                }
                if walk {
                    q.push_front((fy, fx, c));
                } else {
                    q.push_back((fy, fx, c + 1));
                }
            }
        }
    }
    if table[gh][gw] == INF {
        println!("-1");
    } else {
        println!("{}", table[gh][gw]);
    }
}


Measured memory_bytes: 14868
#include <iostream>

using namespace std;

bool c[10];

bool check(int value){
	while(value>0){
		if(c[value%10]){
			return true;
		}else{
			value /= 10;
		}
	}
	return false;
}

int main(void){
	int n,k,d[12],i;
	cin >> n >> k;
	for(i=0; i<10; i++){
		c[i] = false;
	}
	for(i=0; i<k; i++){
		cin >> d[i];
		c[d[i]]=true;
	}
	while(check(n)){
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]

def chk(upper, left):
    for i in range(m):
        for j in range(m):
            if a[i+upper][j+left] != b[i][j]:
                return False
    return True

f = False
for upper in range(n-m+1):
    for left in range(n-m+1):
        if chk(upper, left):
            print('Yes')
            f = True
            break
    if f:
        break
if not f:
    print('No')


Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// 2回の操作で最大11点獲得できる
	// 11で除算した商をaとして、余りで場合分け
	// 余りが0 : 2*a
	// 余りが1〜6 : 2*a + 1
	// 余りが7〜11 : 2*a + 2
  ll x;
	cin >> x;
	if(x % 11 == 0){
		cout << x / 11 * 2 << endl;
  }else	if(x % 11 <= 6){
    cout << x / 11 * 2 + 1 << endl;
	}else{
		cout << x / 11 * 2 + 2 << endl;
	}	
}

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

int main() {
    string w;
    cin>>w;
    sort(w.begin(),w.end());

    bool jdg=true;

    rep(i,0,w.size()){
        int cnt=0;
        rep(j,0,w.size()){
            if(w[i]==w[j]){
                cnt++;
            }
        }
        if(cnt%2!=0){
            jdg=false;
            break;
        }
    }
    if(jdg){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


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

int main()
{
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(s.size()>k)
	{
		for(int i=0;i<k;i++)
		   cout<<s[i];
		cout<<"...";
	}
	else
	{
		for(int i=0;i<s.size();i++)
		cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 3620