akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int n,l;
int data[200000];
int memo[200000];

int solve(int num){
    if(memo[num]!=-1)return memo[num];
    
    if( data[num-1]<data[num] && data[num+1]<data[num] )return l-data[num];
    if( data[num-1]<data[num] && num==n-1 )  return l-data[num];
    if( data[num+1]<data[num] && num==0  )   return l-data[num];
    
    int left=0,right=0;
    if( data[num-1]>data[num] )left = solve(num-1);
    if( data[num+1]>data[num] )right= solve(num+1);
    
    memo[num] = l-data[num] + max(left,right);
    return memo[num];
}


int main(){
    rep(i,200000)memo[i]=-1;
    cin>>n>>l;
    rep(i,n) cin>>data[i];
    
    int ans = 0;
    rep(i,n){
        ans = max(ans,solve(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;

   int s=a*b;
   if(s<c)
   {
      cout<<s;

   }
   else
   {
      cout<<c;
   }
   return 0;

}


Measured memory_bytes: 256
#include <cstdio>

int main (){
    int N;
    scanf("%d",&N);
    int a[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&a[i]);
    }
    int sum=0;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if(i!=j){
                sum+=a[i]*a[j];
            }
        }
    }
    printf("%d",sum/2);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> children(N);
  for (int i=0; i<N; i++)
    children.at(i) = i + 1;
  
  for (int i=0; i<K; i++) {
    int d;
    cin >> d;
    
    for (int j=0; j<d; j++) {
      int num;
      cin >> num;
      
      for (int k=0; k < children.size(); k++) {
        if (children.at(k) == num)
          children.at(k) = 0;
      }
    }
  }
  
  int count;
  for (int i=0; i < children.size(); i++) {
    if (children.at(i) != 0)
      count++;
  }
  cout << count << endl;
}
      
    


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 50005
typedef pair<double,int> P;

int n;
int x[MAX_N],r[MAX_N];
P t[MAX_N*2];

bool check(double h){
  int m=0;
  for(int i=0;i<n;i++){
    if(r[i]<=h)continue;
    double k=sqrt((double)r[i]*(double)r[i]-h*h);
    t[m++]=P(x[i]-k,0);
    t[m++]=P(x[i]+k,1);
  }
  int cnt=0;
  double last=1e9;
  sort(t,t+m);
  for(int i=0;i<m;i++){
    if(t[i].second){
      cnt--;
      if(t[i].first-last>=h*2.0)return true;
      if(cnt==0)last=1e9;
    }else{
      cnt++;
      last=min(last,t[i].first);
    }
  }
  return false;
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(int i=0;i<n;i++)scanf("%d %d",&x[i],&r[i]);
    double L=0,R=100000,M;
    for(int i=0;i<50;i++){
      M=(L+R)/2.0;
      if(check(M))L=M;
      else R=M;
    }
    printf("%.10f\n",L*2.0);
  }
  return 0;
}

Measured memory_bytes: 3176
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j+g) <- v
    else begin
      a.(j+g) <- a.(j);
      incr cnt;
      insert (j - g) v
    end in
  let rec doit i =
    if i < n then begin
      insert (i - g) a.(i);
      doit (i + 1)
    end in
  doit g

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl ->
      insertion_sort a n hd;
      doit tl in
  doit !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, m;
    cin >> n >> m;

    vector <int> cnt(n+1, 0);
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        cnt[l]++;
        cnt[r]--;
    }

    int ans = 0;
    if (cnt[0] == m) ans++;
    for (int i = 1; i < n; i++) {
        cnt[i] += cnt[i-1];
        if (cnt[i] == m) ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    -- kaigyousuuretu
    cs <- map strToInt <$> replicateM n getLine
    -- 出力
    putStrLn $ show . sum . map (\x -> if odd x then 1 else 0) . map length . group $ sort cs


Measured memory_bytes: 61436
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> A(4);
	A.at(0) = N / 1000;
	A.at(1) = N / 100 % 10;
	A.at(2) = N / 10 % 10;
	A.at(3) = N % 10;

	for (int i = 0; i < (1 << 3); i++) {
		int sum = A.at(0);
		vector<char> v;

		for (int j = 0; j < 3; j++) {
			if (i & (1 << j)) {
				sum -= A.at(j + 1);
				v.push_back('-');
			}
			else {
				sum += A.at(j + 1);
				v.push_back('+');
			}
		}
		//cout << sum << endl;

		if (sum == 7) {
			for (int j=0;j<3;j++) cout << A.at(j) << v.at(j);
			cout << A.at(3) << "=7" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
H,W = map(int,input().split())
lis = [[1000000007] * W for i in range(H)]
A = []
for i in range(H):
    Ain = list(input())
    A.append(Ain)
    for j in range(W):
        if A[i][j] == '#':
            lis[i][j] = 0
        else:
            lis[i][j] = min(lis[i][j],lis[i][j-1]+1)

    for j in reversed(range(W-1)):
        lis[i][j] = min(lis[i][j],lis[i][j+1]+1)
#print(lis)

for j in range(W):
    for i in range(1,H):
        lis[i][j] = min(lis[i][j],lis[i-1][j]+1)
    for i in reversed(range(H-1)):
        lis[i][j] = min(lis[i][j],lis[i+1][j]+1)

#print(lis)
ans = 0
for i in range(H):
    ans = max(ans,max(lis[i]))
print(ans)


Measured memory_bytes: 122620
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll x = 1e9 + 7;
  vector<ll> sum_A(N);
  ll sum_a = 0;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    A[i] = tmp % x;
    sum_a += A[i];
  }
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum_a -= A[i];
    ll tmp_x = sum_a % x;
    sum += (A[i] * tmp_x) % x;
  }

  cout << sum % x << endl;
  return 0;
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)1e9+7
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
int main()
{
    IP
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC\n";
    else cout<<"ABC\n";
    
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <vector>
int n;
int br, wh, yy, zz;
int ans[200000];
int color[200000];
struct vertex {
	std::vector<long long>way;
};
vertex v[200000];
void dfs(long long now, long long pa, int cc) {
	//(primary,-1)
	color[now] = cc;
	for (int i = v[now].way.size() - 1; i >= 0; i--) {
		if (v[now].way[i] != pa)dfs(v[now].way[i], now, 1 - cc);
	}
}
void makegraph(void) {
	long long inx, iny;
	scanf("%lld %lld", &inx, &iny);
	inx--; iny--;
	v[inx].way.push_back(iny);
	v[iny].way.push_back(inx);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		makegraph();
	}
	dfs(0, -1, 0);
	for (int i = 0; i < n; i++) {
		if (color[i])br++;
		else wh++;
	}
	if (br <= n / 3) {
		yy = 0;
		for (int i = 0; i < n; i++) {
			if (color[i]) {
				yy += 3;
				ans[i] = yy;
			}
		}
		zz = 0;
		for (int i = 0; i < n; i++) {
			if (color[i] == 0) {
				zz++;
				if (zz % 3 == 0 && zz <= yy)zz++;
				ans[i] = zz;
			}
		}
		goto A;
	}
	if (wh <= n / 3) {
		yy = 0;
		for (int i = 0; i < n; i++) {
			if (color[i] == 0) {
				yy += 3;
				ans[i] = yy;
			}
		}
		zz = 0;
		for (int i = 0; i < n; i++) {
			if (color[i]) {
				zz++;
				if (zz % 3 == 0 && zz <= yy)zz++;
				ans[i] = zz;
			}
		}
		goto A;
	}
	yy = -1;
	zz = -2;
	for (int i = 0; i < n; i++) {
		if (color[i]) {
			yy += 3;
			if (yy <= n)ans[i] = yy;
		}
		else {
			zz += 3;
			if (zz <= n)ans[i] = zz;
		}
	}
	yy = 0;
	for (int i = 0; i < n; i++) {
		if (ans[i] == 0) {
			yy += 3;
			ans[i] = yy;
		}
	}
A:
	for (int i = 0; i < n - 1; i++) {
		printf("%d ", ans[i]);
	}
	printf("%d\n", ans[n - 1]);
}

Measured memory_bytes: 21760
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y,q;ll z, w=0, sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int dp[10010][2][110];
int main(void) {
	string s; int d; cin >> s >> d;
	Fill(dp, 0);
	dp[0][1][0] = 1;
	rep(i, s.size()) {
		rep(j, d) {
			rep(k, 10) {
				dp[i + 1][0][(j + k) % d] += dp[i][0][j];
				dp[i + 1][0][(j + k) % d] %= MOD;
			}
			int Si = s[i] - '0';
			rep(k, Si) {
				dp[i + 1][0][(j + k) % d] += dp[i][1][j];
				dp[i + 1][0][(j + k) % d] %= MOD;
			}
			dp[i + 1][1][(j + Si) % d] = dp[i][1][j];
		}
	}cout << (dp[s.size()][0][0] + dp[s.size()][1][0] - 1 + MOD) %MOD << endl;
}

Measured memory_bytes: 12228
n,_=gets.split.map(&:to_i)
a = [0,n-1]
b = $<.map{|s|s.split.map &:to_i}
b.each do |m|
   a[0] = m[0]-1 if m[0]-1 > a[0] 
   a[1] = m[1]-1 if m[1]-1 < a[1] 
end

k = a[1] - a[0] + 1
puts k > 0 ? k : 0

Measured memory_bytes: 9468
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll x[110],y[110];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld%lld",x+i,y+i);
	rep(_,0,n)rep(i,0,n-1){
		double t1=atan2(y[i  ],x[i  ]);
		double t2=atan2(y[i+1],x[i+1]);
		if(t1>t2){
			ll t;
			t=x[i];x[i]=x[i+1];x[i+1]=t;
			t=y[i];y[i]=y[i+1];y[i+1]=t;
		}
	}
	
	double ans=0;
	rep(i,0,n){
		double xx=0,yy=0;
		rep(jj,0,n){
			int j=(jj+i)%n;
			xx+=x[j];
			yy+=y[j];
			ans=max(ans,hypot(xx,yy));
		}
	}
	printf("%.12f",ans);
}

Measured memory_bytes: 128
#include<stdio.h>
char s[400000];
int ch[400000];
int main(void){
    int n,i,min=400000;
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<400000;i++){
        ch[i]=0;
    }
    for(i=1;i<n;i++){
        if(s[i]!='W'){
            ch[0]++;
        }
    }
    for(i=n-2;i>=0;i--){
        if(s[i]!='E'){
            ch[n-1]++;
        }
    }
    for(i=1;i<n-1;i++){
        ch[i]=ch[i-1];
        if(s[i]=='E'){
            ch[i]--;
        }
        if(s[i-1]!='E'){
            ch[i]++;
        }
    }
    for(i=0;i<n;i++){
        if(ch[i]<min){
            min=ch[i];
        }
    }
    printf("%d\n",min);
    return 0;
}



Measured memory_bytes: 2176
#include<stdio.h>
 
int main(){
  long long n,ans=1;
  scanf("%lld",&n);
  long long a[n+1],b=1000000000000000000;
  for(long long i=1;i<=n;i++){scanf("%lld",&a[i]);}
  
  for(int i=1;i<=n;i++){
    if(a[i]==0){printf("0");return 0;}
  }
  
  for(long long i=1;i<=n;i++){
    if(b/ans<a[i]){printf("-1");return 0;}
    
    ans*=a[i];
  }
  
  printf("%lld",ans);
}

Measured memory_bytes: 2508
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
using namespace std; 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<pii> 
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,x,n)        for(int i=x;i<n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
int32_t main(){
 
    
	  ios::sync_with_stdio(0);
      cin.tie(0);
 
      int n,k; 
      cin>>n>>k; 
      mk(a,n,int) ; 
      f(i,0,n){ 
      	cin>>a[i];
      }
     //  cout<<fun(a,n-1,k,n) ;
 
     int dp[n] ; 
     dp[0]= 0 ; 
     dp[1]= abs(a[1]-a[0]) ; 
 
     f(i,2,n){
         int q1=inf ;
     	 for(int j=1;j<=k;j++){
              
              if(i >= j ) {
     	 	  q1 = min(q1,dp[i-j] + abs(a[i]-a[i-j])) ; 
     	 	  dp[i] = q1 ;
 
     	 	  }
     	 	  else
     	 	  break ;  
     	 }
     } 
     cout<<dp[n-1] ; 
 }
 
 
 
 
 

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,res=0;
  cin >> a >> b >> c;
  if(a==b) res++;
  if(b==c) res++;
  if(c==a) res++;
  if(res==1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def isPalindrome(string):
    flag = True
    len_string = len(string)
    if len_string == 1:
        return flag
    for i in range(len_string//2):
        if string[i] != string[-1-i]:
            flag = False
            break
    return flag

S = input()
len_s = len(S)
fro_s = S[:len_s//2]
if len_s % 2 == 0:
    bak_s = S[-len_s//2:]
else:
    bak_s = S[-len_s//2 + 1:]

if isPalindrome(S) and isPalindrome(fro_s) and isPalindrome(bak_s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61952
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a[110],prime[110];

int main() {
    ll n;cin>>n;
    for(int i = 2; i <= n;i++){
        int tmp = i;
        for(int j = 2; j <= i;j++){
            while (tmp % j == 0){
                a[j]++;
                tmp = tmp / j;
            }
        }
    }
    for(int i = 0;i<=100;i++){
        if (a[i] >= 2)prime[3]++;
        if (a[i] >= 4)prime[5]++;
        if (a[i] >= 14)prime[15]++;
        if (a[i] >= 24)prime[25]++;
        if (a[i] >= 74)prime[75]++;
    }

    int ans = 0;
    ans += prime[75];
    ans += prime[25] * (prime[3] - 1);
    ans += prime[15] * (prime[5] - 1);
    ans += prime[5] * (prime[5] - 1) / 2 * (prime[3] - 2);

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;cin>>N;
  int AX = 0;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
     AX ^= vec[i];
  }
  for (int i = 0; i < N; i++)
  {
    if(i != 0 )cout<<" ";
    int Y = AX^vec[i];
    cout<<Y;
  }
  cout<<endl;

  
  
  
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main (){
  int N,i,sum = 0,ans;
  int dis[100001];

  std::cin >> N;
  dis[0] = 0;

  for (i = 1 ; i < N+1 ; i ++ ) {
    cin >> dis[i];
    }
    dis[N+1] = 0;
  for (i = 0; i < N+2;i++){
 sum = sum + abs(dis[i]-dis[i+1]);
  }
for (i = 1; i < N+1;i++ ){
  ans = sum + abs(dis[i-1]-dis[i+1])-(abs(dis[i-1]-dis[i])+abs(dis[i]-dis[i+1]));
cout << ans <<endl;
}

return 0;
  }


Measured memory_bytes: 1664
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
    	FastIO sc = new FastIO(System.in);
    	PrintWriter out = new PrintWriter(System.out);
    	int k = sc.nextInt();
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int l = a/k;
    	int r = b/k+1;
    	boolean good = false;
    	for(int i=l; i<=r; i++) {
    		//System.out.println(k*i);
    		if(k*i>=a&&k*i<=b) {
    			good = true;
    		}
    	}
     	if(good) System.out.println("OK");
     	else System.out.println("NG");
    	out.close();
    }
    static class FastIO {
		 
		// Is your Fast I/O being bad?
 
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
 
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
 
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
 
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
 
		String next() throws IOException {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
 
	}
}

Measured memory_bytes: 32764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  cout<<N*N*N<<endl;
}

Measured memory_bytes: 256
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
  l.append(chr(97+i))
  r.append(l.copy())
  

p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
  for j in r[i]:
    x = ord(j)-97
    for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
      for m in k:
        p[i][max(n,x)].append(m+j)


p = p[-1]
p = list(itertools.chain.from_iterable(p))
p.sort()
for q in p:
  print(q)

Measured memory_bytes: 13940
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    v = set()

    c = 1
    cnt = 0
    while True:
        if c in v:
            break
        v.add(c)
        cnt += 1
        c = A[c - 1]
        if cnt == K:
            print(c)
            return
    K -= cnt

    syuki = []
    syuki.append(c)
    c = A[c - 1]
    while True:
        if c == syuki[0]:
            break
        syuki.append(c)
        c = A[c - 1]
    print(syuki[K % len(syuki)])

if __name__ == '__main__':
    main()


Measured memory_bytes: 31680
#
#   Bad python template TM
#
#       Zeyu, 2019
#

from sys import stdin, stdout, setrecursionlimit

input = stdin.readline
flush = stdout.flush

# setrecursionlimit(1000000)

############################################################

OUT = []


def write(item, sep=""):
    if type(item) is int or type(item) is long:
        OUT.append(str(item))
    elif type(item) is float:
        OUT.append("%.9f" % item)
    elif type(item) is list or type(item) is tuple:
        if len(item) == 0:
            OUT.append(" ")
        elif type(item[0]) is int:
            OUT.append(sep.join(map(str, item)))
        else:
            OUT.append(sep.join(item))
    else:
        OUT.append(item)


def PRINT(sep="\n"):
    print(sep.join(OUT))


GI = lambda: int(input())
GS = lambda: input().rstrip()

gi = lambda: list(map(int, input().split()))
gs = lambda: input().split()

digits = lambda i: list(map(int, str(i)))

############################################################

n = GI()
pts = [gi() for i in range(n)]
while len(pts) < 3:
    pts.append(pts[-1])
    n+=1
def getDist(x,y,z):
    xa,ya = pts[x]
    xb,yb = pts[y]
    xc,yc = pts[z]

    a = pow((xb - xc)**2 + (yb - yc)**2, 0.5)
    b = pow((xa - xc)**2 + (ya - yc)**2, 0.5)
    c = pow((xb - xa)**2 + (yb - ya)**2, 0.5)
    s = (a + b + c) / 2.0
    a,b,c = sorted([a,b,c])
    if s == 0 or a*a + b*b - c*c <= 0:
        return c / 2.0
    return a*b*c / 4.0 / pow(s*(s-a)*(s-b)*(s-c), 0.5)



m = -1
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            m = max(m, getDist(i, j, k))
print "%.7f" % m

Measured memory_bytes: 33512
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int ch(int n, int k) {
		return n < k ? 0 : k == 0 ? 1 : ch(n - 1, k - 1) * n / k;
	}
	int power(int a, int k) {
		return k == 0 ? 1 : power(a, k - 1) * a;
	}
	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		int k = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int d = cc[i] - '0';
			if (d != 0)
				cnt++;
		}
		int ans = cnt == k ? 1 : 0;
		cnt = 0;
		for (int i = 0; i < n; i++) {
			int d = cc[i] - '0';
			if (d == 0)
				continue;
			ans += ch(n - 1 - i, k - cnt) * power(9, k - cnt);
			if (k > cnt)
				ans += ch(n - 1 - i, k - cnt - 1) * power(9, k - cnt - 1) * (d - 1);
			if (cnt++ == k)
				break;
		}
		println(ans);
	}
}


Measured memory_bytes: 35816
#include <iostream>
#include <string>

using namespace std;

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

    double s = 0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        s += u == "BTC" ? 3.8e5 * x : x;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<vector>
    #include<math.h>
    #include<cmath>
    #include<stack>
    //#include<stdlib.h>
    using namespace std;
    int main() {
    	int n,k; string s;
    	cin>> n>>s>>k;k--;
      for(int a=0;a<n;a++){if(s[a]!=s[k]){s[a]='*';}}
      cout<<s;
      return 0;}

Measured memory_bytes: 256
data=[int(_) for _ in input().split()]

data.sort()
A=data[2]
B=data[1]
C=data[0]
count=0

while A!=B:

    B+=1
    C+=1
    count+=1


while C<B:
    C+=2
    count+=1


if B==C:
    print(count)
else:
    print(count+1)


Measured memory_bytes: 3060
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        
        for(int i=1;i<=5;i++){
            int x=sc.nextInt();
          if(x==0)o=i;
          	
        }
      System.out.println(o);
    }
    
}

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

using namespace std;

int N, M;
int par[100005];

int getrt(int n){
    return par[n] = (par[n] == n ? n : getrt(par[n]));
}

int main(){
    cin >> N >> M;
    for(int i = 1; i<=N; i++){
        par[i] = i;
    }
    while(M--){
        int a, b, c;
        cin >> a >> b >> c;
        if(getrt(a) != getrt(b)){
            N--;
            par[getrt(a)] = getrt(b);
        }
    }
    cout << N << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  } 
  auto iter = max_element(a.begin(),a.end());
  auto index = distance(a.begin(),iter);
  int mx = a[index];
  a[index] = 0;
  auto iter2 = max_element(a.begin(),a.end());
  auto index2 = distance(a.begin(),iter2);

  rep(i,n){
    if(i==index)cout<<a[index2]<<endl;
    else cout<<mx<<endl;
      }
  return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <iostream>

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

using namespace std;

int h, w;
string s[101];

signed main(){
  scanf("%d %d", &h, &w);
  
  rep(i, h){
      cin >> s[i];
  }

  rep(i, h){
    cout << s[i] << '\n';
    cout << s[i] << '\n';
  }
  
}


Measured memory_bytes: 256
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define fi first
#define se second
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pb push_back
#define pf push_front
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif
}
ll prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    //fastio();
    ll t=1;
    //cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        std::vector<ll> a(n-1);
        ll co = 0;
        for(ll i=0;i<n-1;i++) cin >> a[i];
        co = a[0]+a[n-2];
        for(ll i=0;i<n-2;i++)
        {
            co+=min(a[i],a[i+1]);
        }

        cout << co << endl;
    }
}

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

using namespace std;

typedef long long ll;

const int N(2e5 + 9);

int T, n, m, ans;
int a[N];

int main()
{
    cin>>n;
    int Max = 0, Max1 = 0;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
        if (a[i] > Max)
        {
            Max1 = Max;
            Max = a[i];
        }
        else Max1 = max(Max1, a[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (a[i] == Max) m++;
    }
    if (m == 1)
    {
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == Max) cout<<Max1<<endl;
            else cout<<Max<<endl;
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            cout<<Max<<endl;
        }
    }

}


Measured memory_bytes: 2432
#include<iostream>

using namespace std;

int main(){
    char s[5];
    long long ans=0;
    while(cin>>s[0]){
        ans += s[0] - '0';

    }
    //cout << ans << endl;
    if(ans%9==0){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
        
    }
    return 0;
}

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

typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll> > a(N);
    for(ll i=0; i<N; i++) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());

    K--;
    ll now=0; // a[i]のある最初の要素番号
    for(ll i=0; i<N; i++){
        //cout << a[i].first <<" "<< now <<" "<< now+a[i].second-1 << endl;
        now += a[i].second;
        if(K<now){
            cout << a[i].first << endl;
            break;
        }
    }
}


Measured memory_bytes: 1792
N = int(input())
A = [int(a) for a in input().split()]

if max(A) <= 0:
    ma = - 10 ** 9
    for i, a in enumerate(A):
        if a > ma:
            ma = a
            mai = i
    print(ma)
    print(N - 1)
    for i in range(mai+1, N)[::-1]:
        print(i+1)
    for i in range(mai):
        print(1)
else:
    E = sum([a for a in A[::2] if a > 0])
    O = sum([a for a in A[1::2] if a > 0])
    ANS = []
    if O > E:
        ANS.append(1)
        A = A[1:]
    if len(A) % 2 == 0:
        ANS.append(len(A))
        A.pop()
    
    while len(A) > 1:
        if A[0] < 0:
            ANS.append(1)
            ANS.append(1)
            A = A[2:]
        elif A[-1] < 0:
            ANS.append(len(A))
            A.pop()
            ANS.append(len(A))
            A.pop()
        elif A[-3] < 0:
            ANS.append(len(A) - 2)
            A[-2] = A.pop()
            A.pop()
        else:
            ANS.append(len(A) - 1)
            A[-3] += A[-1]
            A.pop()
            A.pop()
    
    print(A[0])
    print(len(ANS))
    for a in ANS:
        print(a)

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

using namespace std;

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

	sort(L.begin(), L.end());

	int max = L.back();
	L.pop_back();

	int sum = accumulate(L.begin(), L.end(), 0);

	cout << (max < sum ? "Yes" : "No") << endl;

	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


ll BinarySearch(ll ng, ll ok, function<bool(ll)> judge){
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}


signed main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;
    a -= b;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    function<bool(ll)> fn = [&v, a, b](ll m){
        ll cnt = 0;
        for(auto i : v){
            if(i - b*m > 0){
                cnt += Div(i - b*m, a);
            }
        }
        return (cnt <= m);
    };

    cout << BinarySearch(0, 1e9, fn) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

int main(int argc, char const* argv[])
{
	int a, b, d, r;
	double f;

	std::cin >> a >> b;

	d = a / b;
	r = a % b;
	f = static_cast<double>(a) / static_cast<double>(b);
	std::cout << d << " ";
	std::cout << r << " ";
	std::cout << std::fixed << std::setprecision(5) << f << std::endl;

	return 0;
}



Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

    int cnt=0;
    for(int i=1;i<n-1;i++){
        vi temp;
        temp.pb(arr[i-1]);
        temp.pb(arr[i]);
        temp.pb(arr[i+1]);

        sort(all(temp));
        if(temp[1]==arr[i])
            cnt++;
    }

    cout<<cnt<<endl;

    
    return 0;
}

Measured memory_bytes: 3600
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
set<int> s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
    for(int i=1;i<3;i++){
      int x;
      cin >> x;
      s.insert(x);
    }
    for(int i=1;i<=3;i++){
      if(s.find(i)==s.end()){
        cout << i << endl;
      }
    }

return 0;
}
///....


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	
	int counter = 0;
	for(int i = 0; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			if(i * j == n) {
				counter = 1;
				break;
			}
		}
	}
	
	if(counter == 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1632
n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(m):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []

Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;

	for (int i = 0; i < s.length(); i++)
	{
		bool f = true;
		for (int j = 0; j < s.length(); j++)
		{
			if ( t[j] != s[(i + j) % s.length()] )
			{
				f = false;
				break;
			}
		}

		if ( f )
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
int count=0,count2=0;
for(int i=0;i<3;i++)
{
    if(s1[i]==s2[i])
    {
        count++;
        if(count==3)
        {
            cout<<3<<endl;
            break;
        }
    }
    else 
     count2++;    
}
if(count>0 && count <3)cout<<3-count2<<endl;
else if(count==0)cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,p[1000],x,i;
	double h[1000],w[1000],y;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++) {
			scanf("%d %lf %lf",&p[i],&h[i],&w[i]);
			h[i]=h[i]/100;
			h[i]=w[i]/(h[i]*h[i]);
			h[i]=h[i]-22;
			if(h[i]<0)  h[i]=h[i]*-1;
		}
		x=p[0]; y=h[0];
		for(i=1;i<n;i++){
			if(y>h[i]){
				x=p[i];  y=h[i];
			}
		}
		printf("%d\n",x);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 2672
#include<bits/stdc++.h>
using namespace std;
int k;queue<long long>q;
int main()
{
	cin>>k;
	for(int i=1;i<=9;++i)
	 q.push(i);
	while(--k)
	{
		long long x=q.front();q.pop();
		for(int i=max(0,(int)x%10-1);i<=min(9,(int)x%10+1);++i)
		 q.push(x*10+i);
	}
	cout<<q.front();
	return 0;
}

Measured memory_bytes: 4556
#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>;

int main() {
    ll X;
    cin >> X;
    ll money = 100;
    int ans = 0;
    while (money < X) {
        money += money / 100;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    ll minn=n;
    ll j=0;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            j=i;
            ll temp=i+(n/i);
            minn=min(minn,temp);
        }
    }
    if(j==1){
        cout<<minn-1<<endl;
    }else{
        cout<<minn-2<<endl;
    }

    return 0;
}
            

                

Measured memory_bytes: 256
#!/usr/bin/python

N = int(raw_input())
S = str(raw_input())

counter = 0
ans = 0

for i in range(N):
	X = list(S[:i])
	Y = (S[i:])

	sorted(X)
	sorted(Y)

	X = list(set(X))
	Y = list(set(Y))

	for j in range(len(X)):
		if(str(Y).find(X[j]) != -1):
			counter += 1
	if(counter > ans):
		ans = counter
	counter = 0

print ans

Measured memory_bytes: 2568
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct XorShift { // Reference: http://yukicoder.me/submissions/44108
    unsigned z;
    XorShift() : z((unsigned)time(NULL)) {}
    XorShift(int seed) : z(z) {}
    unsigned next() {
        z ^= z << 13;
        z ^= z >> 17;
        z ^= z << 5;
        return z;
    }
    unsigned nextInt(unsigned a, unsigned b) {
        return next() % (b - a + 1) + a;
    }
    double nextDouble() {
        return next() / (double)(1ll << 32);
    }
};

int D;
vector<ll> C;
vector<vector<ll>> S;
vector<int> T;

struct state {
    vector<ll> pen, cpen;
    vector<int> TT;
    ll ans;
};

state incremental(ll ans, vector<ll> pen, vector<ll> cpen, vector<int> TT, int d, int c) {
    int prev = TT[d];
    int cur = c;
    ans += cpen[prev] + cpen[cur];
    ans -= S[d][prev];
    ans += S[d][cur];
    pen[prev] = 0;
    pen[cur] = 0;
    cpen[prev] = 0;
    cpen[cur] = 0;
    TT[d] = c;
    rep(i, D) {
        pen[prev] += C[prev];
        pen[cur] += C[cur];
        if(TT[i] == prev) pen[prev] = 0;
        if(TT[i] == cur) pen[cur] = 0;
        cpen[prev] += pen[prev];
        cpen[cur] += pen[cur];
    }
    ans -= cpen[prev] + cpen[cur];
    return {pen, cpen, TT, ans};
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    cin >> D;
    C.resize(26);
    rep(i, 26) cin >> C[i];
    S.resize(D, vector<ll>(26));
    rep(i, D) rep(j, 26) cin >> S[i][j];
    T.resize(D);
    rep(i, D) {
        T[i] = i % 26;
    }
    
    ll ans = 0;
    vector<ll> pen(26);
    vector<ll> cpen(26);
    rep(i, D) {
        ans += S[i][T[i]];
        rep(j, 26) pen[j] += C[j];
        pen[T[i]] = 0;
        rep(j, 26) {
            cpen[j] += pen[j];
            ans -= pen[j];
        }
    }
    
    
    state F = {pen, cpen, T, ans};
    
    
    XorShift xs;
//    vector<state> FB(10);
    rep(xx, 550000) {
        pair<int, int> m1 = mp(xs.nextInt(0, D - 1), xs.nextInt(0, 25));
        pair<int, int> m2 = mp(xs.nextInt(0, D - 1), xs.nextInt(0, 25));
        state FS = incremental(F.ans, F.pen, F.cpen, F.TT, m1.first, m1.second);
        state FSS = incremental(FS.ans, FS.pen, FS.cpen, FS.TT, m2.first, m2.second);
        float buf = 0;
        if(FSS.ans > F.ans || modf(xs.nextDouble(), &buf) < exp(-xx) / 100.0) {
            F = FSS;
        }
    }
    
    rep(i, D) {
        output(F.TT[i] + 1);
    }
    
    return 0;
}


Measured memory_bytes: 4264
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

template <class T>
void out(const T param) {
    cout << param << "\n";
}

int main() {
    
    int N;
    
    cin >> N;
    
    long A[N];
    
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    sort(A, A+N);
    
    out(A[N-1] - A[0]);
    
    
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())

    if K % 2 != 0:
        ans = (N // K)**3
    else:
        n = N // K
        if (n + 0.5) * K <= N:
            ans = (n + 1)**3 + n**3
        else:
            ans = 2 * n**3

    print(ans)


main()


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

using namespace std;

int main()
{
    int a,b,c,d,h=1;;
    bool redboxes[100000];
    int ball[100000];
    for(int i=0;i<100000;i++){
        redboxes[i]=false;
        ball[i]=1;
    }
    redboxes[0]=true;
    cin>>a>>b;
    while(b--)
    {
        cin>>c>>d;
        if(redboxes[c-1]  )
        {
            if(ball[c-1]-1==0){
                    h--;
                    redboxes[c-1]=false;
            }

             ball[c-1]--;
            ball[d-1]++;
             if(!redboxes[d-1]){h++;redboxes[d-1]=true;}


        }
        else
        {
             ball[c-1]--;
            ball[d-1]++;
        }

    }
    cout<<h<<"\n";

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >> n;
  ll c[n-1],s[n-1],f[n-1];
  for(ll i=0;i<n-1;i++) cin >>c[i]>>s[i]>>f[i];
  for(ll i=0;i<n-1;i++){
    ll t=0;
    for(ll j=i;j<n-1;j++){
     if(t>=s[j]){
       if(t%f[j]==0) t+=c[j];
       else t+=((f[j]-t%f[j])+c[j]);
     }
     else{
       t+=((s[j]-t)+c[j]);
     }
   }
   cout <<t<<endl;
  }
  cout <<0<<endl;
  return 0;
}


Measured memory_bytes: 256