akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int w, h; cin >> w >> h, w | h; )
	{
		VI hor( w ), ver( h );
		FOR( tmp, hor )
		{
			cin >> tmp;
		}
		FOR( v, ver )
		{
			cin >> v;
		}

		int res = accumulate( ALL( hor ), 0 );
		vector<bool> used( w, false );
		REP( i, 0, h )
		{
			int found = -1;
			REP( j, 0, w )
			{
				if ( !used[j] && hor[j] == ver[i] )
				{
					found = j;
				}
			}

			if ( found == -1 )
			{
				res += ver[i];
			}
			else
			{
				used[ found ] = true;
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int H, W, M;
	cin >> H >> W >> M;
	
	vi row(H,0), col(W,0);
	vpi bomb(M);
	
	for(int i=0; i<M; ++i) {
		int h, w;
		cin >> h >> w;
		--h, --w;
		bomb[i]={h,w};
		++row[h];
		++col[w];
	}
	
	int mxRow=0, mxCol=0;
	for(auto x : row) mxRow = max(mxRow, x);
	for(auto x : col) mxCol = max(mxCol, x);
	
	ll cntMxRow=0, cntMxCol=0, cntBoth=0;
	for(auto x : row) cntMxRow += (x==mxRow);
	for(auto x: col) cntMxCol += (x==mxCol);
	for(auto x : bomb) cntBoth += (row[x.f]==mxRow && col[x.s]==mxCol);
	
	if(cntMxRow*cntMxCol > cntBoth) cout << mxRow + mxCol << '\n';
	else cout << mxRow + mxCol -1 << '\n';
	
	return 0;
}


Measured memory_bytes: 7928
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  map<ll, ll> m;
  set<ll> s;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    m[a[i]]++;
    s.insert(a[i]);
  }
  ll ans = 0;
  for (auto i : s) {
    ans = max(ans, m[i - 1] + m[i] + m[i + 1]);
  }
  cout << ans << endl;
  return 0;
}

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

const double EPS = 1e-9;
const int MOD = 256;

int I[257];
int R[257];
int O[257];

int main() {
	int N;

	while (cin >> N && N) {
		for (int i = 1; i <= N; i++) {
			cin >> I[i];
		}

		int ansS, ansA, ansC;
		double ansH = 100000000.0;

		for (int S = 0; S <= 15; S++) {
			for (int A = 0; A <= 15; A++) {
				for (int C = 0; C <= 15; C++) {

					double H = 0;
					R[0] = S;
					memset(O, 0, sizeof(O));

					for (int i = 1; i <= N; i++) {
						R[i] = (A * R[i - 1] + C) % MOD;
						O[(I[i] + R[i]) % MOD]++;
					}

					for (int i = 0; i < 256; i++) {
						if (O[i] != 0) H -= (O[i] / (double)(N)* log(O[i] / (double)(N)));
					}

					if (H + EPS < ansH) {
						ansH = H;
						ansS = S;
						ansA = A;
						ansC = C;
					}
				}
			}
		}

		cout << ansS << ' ' << ansA << ' ' << ansC << endl;
	}

	return 0;
}

Measured memory_bytes: 3368
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

ll mod=924844033, dp[2010][2010][2]={}, ep[4010][2010]={}, frac[2010];

int main(void){
    int N, K;
    cin >> N >> K;
    dp[0][0][0]=dp[0][0][1]=1;
    for(int i=0; i<=2000; ++i){
        for(int j=0; j<=i; ++j){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0]) %= mod;
            (dp[i+1][j+1][0] += dp[i][j][1]) %= mod;
        }
    }
    ep[0][0]=1;
    for(int i=0; i<K*2; ++i){
        int num=(N-i/2-1)/K;
        for(int j=0; j+(num+1)/2<=N; ++j){
            for(int k=0; k<=(num+1)/2; ++k){
                (ep[i+1][j+k] += (ep[i][j]*dp[num][k][0])%mod) %= mod;
            }
        }
    }
    frac[0]=1;
    for(int i=1; i<=N; ++i) frac[i]=(frac[i-1]*i)%mod;
    ll ans=frac[N];
    for(int i=1; i<=N; ++i){
        if(i%2==1){
            (ans += mod-(frac[N-i]*ep[K*2][i])%mod) %= mod;
        }
        else{
            (ans += (frac[N-i]*ep[K*2][i])%mod) %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 126080
#include <stdio.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) (aa<bb)?aa:bb
#define max(aa,bb) (aa<bb)?bb:aa
//#define gcd(aa,bb) return (!bb)?aa:gcd(bb,aa%bb)

int main(){
	int n,sum=0;
	scanf("%d",&n);
	int d[n];
	Fori(n)scanf("%d",&d[i]);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin

a, b = stdin.readline().rstrip().split()
counter = 0

c = int(a)
d = int(b)

for i in range (d - c + 1):
    
    digit_1 = str(i + c)[:1]
    digit_2 = str(i + c)[1:2]
    digit_3 = str(i + c)[3:4]
    digit_4 = str(i + c)[4:5]
  
    if(digit_1 == digit_4 and digit_2 == digit_3):
        counter += 1

print(counter)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int,int> P;
int n,w;
int a[334],b[334];
int dp[334][314159];
signed main(){
	cin>>n>>w;
	rep(i,n)cin>>a[i]>>b[i];
	dp[0][a[0]]=b[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=w;j++){
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			dp[i][j+a[i]]=max(dp[i][j+a[i]],dp[i-1][j]+b[i]);
		}
	}
	int ans=0;
	for(int i=0;i<=w;i++)ans=max(ans,dp[n-1][i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 243968
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

N, Q = map(int, input().split())

un = UnionFind(N)

for i in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        un.union(u-1, v-1)
    else:
        print('1' if un.is_same(u-1, v-1) else '0')


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

#define llint long long int
#define MOD 1000000007

using namespace std;

// a^n (mod p)
llint mod_pow(llint a, llint n, llint p)
{
    if (n == 0)
    {
        return 1;
    }
    else if (n % 2 == 0)
    {
        llint d = mod_pow(a, n / 2, p);

        return (d * d) % p;
    }
    else
    {
        return (a * mod_pow(a, n - 1, p)) % p;
    }
}
int main()
{
    llint N;

    cin >> N;

    llint ans = mod_pow(10, N, MOD) - 2 * mod_pow(9, N, MOD) + mod_pow(8, N, MOD);

    ans = ((ans % MOD) + MOD) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X,Y,Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << ln;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200001

void QSort(int x[ ], int left, int right)
{
    int i, j,temp;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */
    	temp = x[i];
    	x[i] = x[j];
    	x[j] = temp;
        i++;                       /* 次のデータ */
        j--;
    }
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

int main(int argc, char const *argv[]){
	int n,i,a,k,s[N]={0},c=0,j=0,tmp;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		s[a-1]++;
	}
	QSort(s,0,n-1);
	for(i=n-k-1;i>=0;i--){
		c+=s[i];
		if(s[i]==0)
			break;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 896
def main():
  X, N = map(int, input().split()) # スペース区切り入力
  p = [int(x) for x in input().split()]
  a = 1
  
  if N == 0:
    print(X)
  else:
    if X in p:
      while True:
        if X - a in p and X + a in p:
          a += 1
          continue
        elif X - a in p:
          print(X + a)
          break
        else:
          print(X - a)
          break
    else:
      print(X)

    
if __name__ == '__main__':
  main()

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define INF 1e9
int tree[1000000];
int n = 300001;
void update(int l,int v)
{
	tree[l+n] =v;
	for(int i=l+n;i>0;i=i>>1)
		tree[i>>1] = max(tree[i],tree[i^1]);
}
int query(int l,int r)
{
	int res=0;
	for(l=l+n,r=r+n;l<r;l>>=1,r>>=1)
	{
		if(l&1) res = max(res,tree[l++]);
		if(r&1) res = max(res,tree[--r]);
	}
	return res;
}
signed main()
{
	io;
	int s,k;
	cin >>s >>k;
	int a[s];
	rep(i,0,s) cin >> a[i];

	memset(tree,0,sizeof(tree));
	for(auto it:a)
	{
		int c = query(max((ll)0,it-k),min(it+k,(ll)300000)+1);
		update(it,c+1);
	}
	cout << query(0,n);

	
}
 


Measured memory_bytes: 13784
#include <cstdio>
#include <vector>
int N,A[105],lst[105],H[105],Z[105],E[105];
std::vector<int> V;
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;++i) if (scanf("%d",A+i),A[i]>i) return puts("-1"),0;
	for (int i=1;i<=N;++i) lst[i]=H[A[i]],H[A[i]]=i;
	for (int i=1,j;i<=N;++i){
		for (j=i;j;--j) if (H[j]){
			for (int k=1;k<j;++k) if (Z[k]>H[j]) goto LABEL;
			for (int k=j+1;k<i;++k) if (Z[k]<H[j]) goto LABEL;
			break;LABEL:;
		}
		if (!j) return puts("-1"),0;
		V.push_back(j);
		for (int k=1;k<i;++k) E[k]=Z[k];
		for (int k=1;k<j;++k) Z[k]=E[k];
		Z[j]=H[j],H[j]=lst[H[j]];
		for (int k=j;k<i;++k) Z[k+1]=E[k];
	}
	for (int x:V) printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip> 
#include <vector>
#include <queue>

using namespace std;


int main()
{
	ios_base :: sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector < vector < int > > g(n, vector < int >());
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector < int > p(n, -1);
	p[0] = 0;
	queue < int > q;
	q.push(0);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto u : g[v]) {
			if (p[u] == -1) {
				p[u] = v + 1;
				q.push(u);
			}
		}
	}
	for (int i = 1; i < n; i++) {
		if (p[i] == -1) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << p[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 10140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N,K;
	int[] D;
	boolean[] notUse;
	public void solve() {
		N = nextInt();
		K = nextInt();
		D = new int[K];
		notUse = new boolean[10];
		for(int i = 0;i < K;i++){
			D[i] = nextInt();
			notUse[D[i]] = true;
		}

		for(int i = N;i <= 100000;i++){
			int j = i;
			boolean flag = true;
			while(j > 0){
				if(notUse[j % 10]){
					flag = false;
					break;
				}
				j /= 10;
			}
			if(flag){
				out.println(i);
				break;
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8020
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

LL N,M,a,b,c,d;

int main(){
    cin>>a>>b>>c>>d>>N;
    LL b0_5=min(a*2,b);
    LL b1=min(b0_5*2,c);
    LL b2=min(b1*2,d);
    LL ans=0;
    if(N%2==1){
        ans+=b1;
    }
    ans+=N/2*b2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static long[][][] dp;
	static int[] arr;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		dp = new long[n + 1][n + 1][a * n + 1];
		for (long[][] first : dp) {
			for (long[] second : first) {
				Arrays.fill(second, -1);
			}
		}
		long total = 0;
		for (int i = 1; i <= n; i++) {
			total += dfs(n, i, i * a);
		}
		System.out.println(total);
	}
	
	static long dfs(int x, int y, int total) {
		if (x < 0 || y < 0 || total < 0) {
			return 0;
		}
		if (dp[x][y][total] != -1) {
			return dp[x][y][total];
		}
		if (x == 0) {
			if (y == 0 && total == 0) {
				dp[x][y][total] = 1;
				return 1;
			} else {
				dp[x][y][total] = 0;
				return 0;
			}
		}
		long ans = dfs(x - 1, y, total) + dfs(x - 1, y - 1, total - arr[x - 1]);
		dp[x][y][total] = ans;
		return ans;
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n, k;
	cin >> n >> k;

	// (n+1)Ck + nC(k+1) + ... + (n+1)C(n+1)
	//=(n+1)C(n-k+1) + nC(n-k) + ... + (n+1)C(0)

	ll ans = 0;
	for(ll i = k; i <= n + 1; ++i)
	{
		ans = (ans + (long long)((n+1) * i) % MOD - (long long)(i * i) % MOD + 1) % MOD;
	}

	if (ans < 0)
	{
		ans += MOD;
	}

	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
    int N,a,x,b,min=inf,count;
    scanf("%d",&N);
    for(int i=1;i<=N/2;i++){
        a=i;
        b=N-a;
        count=0;
        while(a!=0){
            x=a%10;
            count+=x;
            a/=10;
        }
        while(b!=0){
            x=b%10;
            count+=x;
            b/=10;
        }
        if(count<min)
            min=count;
    }
    cout<<min;





    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	REP(i, n) { cin >> a[i]; a[i]--; }
	REP(i, n) { cin >> b[i]; }
	REP(i, n - 1) { cin >> c[i]; }

	int ans = 0;
	REP(i, n)
	{
		ans += b[a[i]];
		if (i > 0)
		{
			if (a[i - 1] + 1 == a[i])
				ans += c[a[i - 1]];
		}
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		VI S(M), C(M);
		REP(i, M) cin>>S[i]>>C[i];
		ll tenN = 1;
		REP(i, N) tenN*=10;
		ll ans = -1;
		REP(n, tenN) {
			string s = to_string(n);
//			DD(s);
			if(s.size()==N) {
				ll ok = 1;
				REP(i, M) {
					if(s[S[i]-1]-'0' != C[i]) ok=0;
				}
				if(ok) {ans=n;break;}
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long x = in.nextLong();
		long y = in.nextLong();
		int s = 1;
		while(true) {
			x *= 2;
			if(x <= y) s++;
			else break;
		}
		System.out.println(s);
	}
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll X;
bool prime[100005];

int main(){
    cin >> X;
    FOR(i,2,100005)
    {
      if(!prime[i]){
        if(i>=X){cout << i << endl;return 0;}
        prime[i]=true;
        for(int j=i;j<100005;j+=i)prime[j]=true;
      }
    }
    return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
c = []
for _ in range(n):
    a, b = map(int, input().split())
    c.append((a, b))
c.sort(key=lambda x: x[0])
total = 0
for (a, b) in c:
    total += b
    if total >= k:
        print(a)
        break

Measured memory_bytes: 18192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  ll m = max(h, w);
  cout << (n + m - 1) / m << endl;
}

Measured memory_bytes: 256
/*By pigeatshit*/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <map>
#define LL long long
#define reset(c,x) memset (c, x, sizeof (c))
#define PN printf("\n")
#define NN int n;scanf("%d", &n)
#define NM int n,m;scanf("%d%d", &n, &m)
#define NMK int n,m,k;scanf("%d%d%d", &n, &m, &k)

using namespace std;

int h, w;

char pos[20][20];

int path[50];
int p;

int banx[] = {0,0,1,-1};
int bany[] = {1,-1,0,0};

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

int getdir(char c)
{
    if(c == 'U') return 0;
    if(c == 'D') return 1;
    if(c == 'L') return 2;
    if(c == 'R') return 3;
    return -1;
}

int dfs(int x, int y, int dir, int num)
{
    if(num == 0) return 1;
    for(int i = 0; i < 4; i++)
    {
        if(dx[i] == banx [dir] && dy[i] == bany[dir]) continue;
        int xx = x+dx[i], yy = y+dy[i];
        while(xx >= 0 && yy >= 0 && xx < w && yy < h)
        {
            if(pos[yy][xx] == 'o')
            {
                pos[y][x] = '.';
                path[p++] = i;
                int res = dfs(xx, yy, i, num-1);
                if(res) return 1;
                p--;
                pos[y][x] = 'o';
                break;
            }
            else
            {
                xx += dx[i];
                yy += dy[i];
            }
        }
    }
    return 0;
}


int main()
{
    reset(path, 0);
    p = 0;
    scanf("%d%d",&h,&w);
    for(int i = 0; i < h; i++)
        scanf("%s",pos[i]);

    int dir = -1;
    int x,y;
    int num = 0;
    for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
    {
        if(pos[i][j] == 'o') num++;
        if(pos[i][j] != '.' && pos[i][j] != 'o')
        {
            dir = getdir(pos[i][j]);
            x = j; y = i;
        }
    }

    int flag = dfs(x,y,dir,num);

    for(int i = 0; i < p; i++)
    {
        if(path[i] == 0) printf("U");
        if(path[i] == 1) printf("D");
        if(path[i] == 2) printf("L");
        if(path[i] == 3) printf("R");
    }
    PN;
    return 0;
}

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

int main(void) {
  int L, R;
  std::vector<int> list;
  std::cin >> L;
  std::cin >> R;
  if (R-L >= 2019) {
    std::cout << 0 << std::endl;
  } else {
    for (int i = L; i < R; i++) {
      for (int j = i+1; j <= R; j++) {
        if (i >= j) {
          continue;
        }
        list.push_back(((i%2019)*(j%2019))%2019);
      }
    }
    std::cout << *std::min_element(list.begin(), list.end()) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 9580
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int a[5][5];
int b[105];

signed main(){
    IOS;
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    while (n--) {
        int x;
        cin >> x;
        b[x] = 1;
    }
    for (int i = 1; i <= 3; i++) {
        int c = 0;
        for (int j = 1; j <= 3; j++) {
            c += b[a[i][j]];
        }
        if (c == 3) return cout << "Yes", 0;
    }
    for (int j = 1; j <= 3; j++) {
        int c = 0;
        for (int i = 1; i <= 3; i++) {
            c += b[a[i][j]];
        }
        if (c == 3) return cout << "Yes", 0;
    }
    if (b[a[1][1]] && b[a[2][2]] && b[a[3][3]]) cout << "Yes";
    else if (b[a[3][1]] && b[a[2][2]] && b[a[1][3]]) cout << "Yes"; 
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n, h, w;
    cin >> n >> h >> w;

    int ans {};
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;

        if (a >= h && b >= w)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

template <class T>
using V = vector<T>;

template <class T>
using VV = V<V<T>>;

template <class T>
using P = pair<T, T>;

// 遷移が大変だから、ダイクストラとかして計算量減らしたい
// でも制約的にそんな工夫しなくてもよさそう

int main() {
    int N, K;
    cin >> N >> K;
    V<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    V<int> DP(N, -1);
    priority_queue<P<int>, V<P<int>>, greater<P<int>>> que;

    que.emplace(0, 0);

    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int d = p.first;
        int x = p.second;
        if (DP[x] != -1) continue;
        DP[x] = d;
        for (int t = 1; t <= K; ++t) {
            int nx = x + t;
            if (nx >= N) break;
            if (DP[nx] == -1) {
                que.emplace(d + abs(h[nx] - h[x]), nx);
            }
        }
    }
    cout << DP[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 7972
import math
N = int(input())
A = list(map(int, input().split()))

flag = True
if N%2 == 0:
    if 0 in A or len(set(A)) != N//2:
        flag = False
else:
    if len([0 for a in A if a == 0]) != 1 or len(set(A)) != N//2 + 1:
        flag = False

if  flag:
    print(2**((N//2))%(10**9+7))
else:
    print(0)


Measured memory_bytes: 20368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,d;
	cin>>n>>d;
	if(n%(d*2+1))cout<<n/(d*2+1)+1<<endl;
	else cout<<n/(d*2+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int get_keta(long long n);
int all_9(long long n);
int saijoui(long long n, int keta);

int main()
{
    long long n;
    int keta;

    scanf("%lld", &n);
    keta = get_keta(n);

    if(all_9(n)){
        printf("%d\n", saijoui(n, keta) + 9 * (keta-1));
    }else{
        printf("%d\n", saijoui(n, keta)-1+(keta-1) * 9);
    }
    
    return 0;
}

int get_keta(long long n)
{
    int keta = 0;
    while(n > 0) {n /= 10; keta++;}
    return keta;
}

int all_9(long long n)
{
    int cnt = 0;

    while(n > 9){
        if(n % 10 != 9) return 0;
        n /= 10;
        cnt++;
    }

    return 1;
}

int saijoui(long long n, int keta)
{
    int i;
    for(i = 0; i < keta-1; i++) n /= 10;
    return (int)n;
}


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

int main(){
    int k,n;
    cin >> k >> n;
    vector<int> a(n+1);
    int maxi=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i==0) continue;
        maxi=max(a[i]-a[i-1],maxi);
    }
    maxi=max(k+a[0]-a[n-1],maxi);
    cout << k-maxi << endl;
    return 0;    
}

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

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a;
    x = 1;
    y = 0;
    if(b != 0)
        g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(int argc, char *argv[]){
  int i;
  int a,b,c;
  int count=0;

  scanf("%d %d %d", &a, &b, &c);
  for(i=a; i<=b; i++){
    if( c%i == 0)
      count++;
  }
  printf("%d\n", count);
  return(0);
}


Measured memory_bytes: 2104
MOD = 10 ** 9 + 7

H, W = map(int, input().split())
a = [input() for _ in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
for h in range(H):
	for w in range(W):
		if h + w == 0:
			dp[h][w] = 1
		elif a[h][w] == "#":
			continue
		elif h == 0:
			dp[h][w] = dp[h][w-1]
		elif w == 0:
			dp[h][w] = dp[h-1][w]
		else:
			dp[h][w] = (dp[h-1][w] + dp[h][w-1]) % MOD

print(dp[-1][-1])

Measured memory_bytes: 44616
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string a;
  cin >> a;
  int n = a.length();
  string key = "keyence";//7
  if(a[0]!=key[0]){
    a.erase(0,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[1]!=key[1]){
    a.erase(1,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[2]!=key[2]){
    a.erase(2,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[3]!=key[3]){
    a.erase(3,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[4]!=key[4]){
    a.erase(4,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[5]!=key[5]){
    a.erase(5,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else if(a[6]!=key[6]){
    a.erase(6,n-7);
    if(a==key){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
  }else{
    cout << "YES";
    return 0;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------



int a, b, c;

int main()
{
	cin >> a >> b >> c;

	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

int mod = 1e9 + 7;

int find(int a, vector<int>& group) {
    if (a == group[a]) return a;
    return find(group[a], group);
}

void unite(int group_a, int group_b, vector<int>& group, vector<int>& rank) {
    if (rank[group_a] < rank[group_b]) swap(group_a, group_b);
    group[group_b] = group_a;
    rank[group_a] += rank[group_b];
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // N-1 -(built edges)
    int N, M, a, b;
    cin >> N >> M;
    vector<int> group(N + 1);
    for (int i = 0; i <= N; i++) {
        group[i] = i;
    }
    vector<int> rank(N + 1, 0);
    int ans = N - 1;
    for (int j = 0; j < M; j++) {
        cin >> a >> b;
        int group_a = find(a, group), group_b = find(b, group);
        if (group_a != group_b) {
            ans--;
            if (ans == 0) {
                cout << 0;
                return 0;
            }
            unite(group_a, group_b, group, rank);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	
   	int n;
   	cin >> n;
   	vi a(n);
   	int sum = 0;
   	fi(0, n) {
   		cin >> a[i];
   		sum ^= a[i];
   	}
   	fi(0, n) {
   		cout << (sum ^ a[i]) << ' ';
   	}
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

#define INF 10000000000

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  std::vector<ll> A(N, 0), B(N, 0);
  for (size_t i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  // main procedure
  sort(ALL(A));
  sort(ALL(B));

  A.push_back(INF);
  B.push_back(INF);

  bool is_N_even = (N % 2 == 0);
  int target_lower_order = (N + 1) / 2;
  int target_higher_order = target_lower_order + (is_N_even ? 1 : 0);

  vector<pair<ll, ll>> target_range_vec((is_N_even ? 2 : 1));

  int current_order = 0;
  int closed_order = 0;

  ll next_left_i = 0;
  ll next_right_i = 0;

  while (closed_order < target_higher_order) {
    ll next_left = A[next_left_i];
    ll next_right = B[next_right_i];

    if (next_left <= next_right) {
      current_order++;
      if (current_order == target_lower_order) {
        target_range_vec[0].first = next_left;
      } else if (current_order == target_higher_order) {
        target_range_vec[1].first = next_left;
      }
      next_left_i++;
    } else {
      closed_order++;
      if (closed_order == target_lower_order) {
        target_range_vec[0].second = next_right;
      } else if (closed_order == target_higher_order) {
        target_range_vec[1].second = next_right;
      }
      next_right_i++;
    }
  }

  ll ans;

  if (!is_N_even) {
    ll med_min = target_range_vec[0].first;
    ll med_max = target_range_vec[0].second;
    ans = med_max - med_min + 1;
  } else {
    ll med2_min = target_range_vec[0].first + target_range_vec[1].first;
    ll med2_max = target_range_vec[0].second + target_range_vec[1].second;
    ans = med2_max - med2_min + 1;
  }

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7936
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define ll long long
#define ull unsigned long long
using namespace std;
void solve()
{
	ll n;
	cin >> n;
	ll sum = 0;
	ll i,j;
	ll a = n-1;
	for(i = 3;i<=sqrt(a);i++)
	{
		if(a%i == 0)
		{
			if(i*i == a)
				sum++;
			else
				sum+=2;
		}
	}
	ll b;
	for(i=3;i<=sqrt(n);i++)
	{
		if(n%i == 0)
		{
				a = n;
				while(a%i == 0)
					a/=i;
				if(a%i == 1)
					sum++;
				if(i*i!=n)
				{
				a = n;
				while(a%(n/i) == 0)
					a/=(n/i);
				if(a%(n/i) == 1)
					sum++;
				}
		}
	}
	if(n == 2)
		cout << 1 << endl;
	else if(n == 3)
		cout << 2 << endl;
	else if(n == 5)
		cout << 3 << endl;
	else
	{
	if(n%2)
		sum++;
	cout << sum+3 << endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
		solve();

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		String[] ss = s.split("");
		int size = 1;
		int count = 0;
		for(int i = 1; i < n; i++) {
			if(!ss[i-1].equals(ss[i])) {
				size++;
			}else {
				count++;
			}
		}
		for(int i = 0; i < k; i++) {
			if(size >= 3) {
				size -= 2;
				count += 2;
			}else if(size == 2){
				size--;
				count += 1;
			}else {
				break;
			}
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 34368
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


signed main() {
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<string,int> mp;
		rep(i,n){
			string s;
			cin>>s;
			mp[s]++;
		}
		cout<<"AC x "<<mp["AC"]<<endl;
		cout<<"WA x "<<mp["WA"]<<endl;
		cout<<"TLE x "<<mp["TLE"]<<endl;
		cout<<"RE x "<<mp["RE"];
		
	}
	
}

Measured memory_bytes: 3632
///Nahid Hasan Raju
#include <bits/stdc++.h>

#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define P1(XX) cout<<"db1: "<<XX<<endl
#define P2(XX,YY) cout<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cout<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007LL
#define MX 2000006


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[MX];

ll n, k,c;

int main()
{
    //Fin;
    int test, tc=0, i, j;
    ll m, d, l, ans,sum=0;
    int t;
    //scanf("%d", &test);
    test=1;
    while(test--)
    {
        //MS(a,0);
        cin>>n;
        n%=1000;
        if(n==0)n=1000;
        printf("%lld\n", 1000-n);
    }
    return 0;
}



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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int x , y;
   cin >> x >> y;
   for(int i = 0 ; i <= x ; i++)
      if(i * 2 + (x - i) * 4 == y)
         return cout << "Yes" , 0;
   cout << "No";
   return 0;
}


Measured memory_bytes: 3604
import string

def print_frequencies(frequency_dict):
  for letter, count in frequency_dict.items():
    print(f"{letter} : {count}")

def remove_digits(input_str):
  removed_digit_string = ""

  for a in input_str:
    if a.isdigit():
      continue
    else:
      removed_digit_string += a
  
  return removed_digit_string


# Init dictionary of letters and counts
letter_counts = dict.fromkeys(string.ascii_lowercase, 0)

# Replaces all punctuation with empty space
translator = str.maketrans('', '', string.punctuation)

while True:
  try:

    # Keep on concatenating string until end of input
    master_string = ""
    input_text = input()
    master_string += input_text
    
    # Remove punctuation from string
    master_string = master_string.translate(translator)
    master_string = master_string.replace(" ", "")
    
    # Make entire string lowercase
    master_string = master_string.lower()

    # Remove numeric characters
    master_string = remove_digits(master_string)

    # Update frequencies
    for letter in master_string:
      letter_counts[letter] += 1

  # Print frequencies
  except EOFError:
    print_frequencies(letter_counts)
    break



Measured memory_bytes: 6696