akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int length = s.length();
		for (int t = 0; t <= length - 1; t =  t + 2) {
			System.out.print(s.charAt(t));
		}
	}
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
using ll = long long int;

using namespace std;

int main() {
  string S;
  cin >> S;
  stringstream ss(S);
  int y, m, d;
  char c;
  ss >> y >> c >> m >> c >> d;
  if (y > 2019 || (y == 2019 && m >= 5))
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

 
Node root;
int count =0;
int count2 = 0;
Node treeMinimum(Node x){
   while (x->left != NULL){
    x = x->left;
}
return x;
}
 
 
 
Node IterativetreeSearch(Node u, int k){
  while(u !=NULL && k !=u->key){
    if(k < u->key)
      u = u->left;
 
    
 
    else u = u->right;
  }
  return u;
 
}
 
 

 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NULL){
    return treeMinimum(x->right);
      }
  y = x->parent;
 
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; 
  Node x;   
  if(z->left == NULL || z->right == NULL){
    y = z;
  }
  else 
    y = treeSuccessor(z);
  
 
  if(y->left != NULL)
    x = y->left;
  
  else 
    x = y->right;
  
 
  if(x != NULL)
    x->parent = y->parent;
  
  if(y->parent == NULL)
    root = x;
  
  else if(y == y-> parent ->left)
    y->parent->left =x;
  
  else y-> parent -> right = x;
 
   
  if(y != z)
    z->key = y->key;
  
 
}
 
void insert(int k){
  Node y = NULL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
 
  while(x != NULL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    
    else x = x->right; 
  }
  z->parent = y;
 
  if(y == NULL)
    root = z;
  
  else if (z->key < y->key)
    y->left = z;
  
   
  else y->right = z;
}
 
void inorder(Node u){
  if(u != NULL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
  
}
 
 
 
 
void preorder(Node u){
   
   
    if (u != NULL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
     
  
     
    }
}
 
int main(){
  int n, i, x;
   char com[20];
  scanf("%d", &n);
    for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = IterativetreeSearch(root, x);
      if ( t != NULL)
    printf("yes\n"); 
          
      else 
    printf("no\n");
    
     

    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
     
 
    else if ( com[0] == 'p' ){
          inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
    count = 0;
     
      }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(IterativetreeSearch(root, x));
    }
  }
 
  return 0;
  }

Measured memory_bytes: 19364
N = int(input())
A = list(map(int,input().split()))

Ans = [0 for _ in range(N)]

for i in range(N):
    if i % 2 == 0:
        Ans[0] += A[i]
    else:
        Ans[0] -= A[i]

for i in range(1,N):
    Ans[i] = 2*A[i-1] - Ans[i-1]

print(" ".join(map(str,Ans)))


Measured memory_bytes: 19092
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner scanner =new Scanner(System.in);
       int K=scanner.nextInt();
       int A = 7%K;

       for(int i=1;i<=K;++i){
           if(A==0){
                System.out.println(i);
                System.exit(0);
           }
           A = (A*10+7)%K;
           }
           System.out.println(-1);
       }
   }


Measured memory_bytes: 35724
#include<bits/stdc++.h>
const int MN=200000+5;
using namespace std;
typedef long long ll;
template<typename T>inline T IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n;
int a[MN];
int check(int x){
	for(int i=0;i<n;++i){
		if(((a[n+i]>=x)&&(a[n+i+1]>=x))||((a[n-i]>=x)&&(a[n-i-1]>=x)))return 1;
		if(((a[n+i]<x)&&(a[n+i+1]<x))||((a[n-i]<x)&&(a[n-i-1]<x)))return 0;
	}
	return a[1]>=x;
}
void input(){
	IN(n);
	for(int i=1;i<=2*n-1;++i)a[0]=max(a[0],IN(a[i]));
	int l=1,r=a[0]+1;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid))l=mid+1;
		else r=mid;
	}
	printf("%d\n",l-1);
}
int main(){
	
	input();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	long long mod = 1000000007; 
	long long pow[200010] = {}; 
	pow[0] = 1; 
	for(int i = 1; i <= 200005; i++){
		pow[i] = pow[i-1] * 2 % mod; 
	}
	long long zero = 0; 
	bool allzero = true; 
	map<pair<long long, long long>, int> M; 
	map<pair<long long, long long>, bool> seen; 
	long long P[200010] = {}; 
	long long Q[200010] = {}; 
	for(int i = 0; i < N; i++){
		long long A, B; cin >> A >> B; 
		if(A != 0 || B != 0) allzero = false; 
		if(A == 0 && B == 0){
			zero ++; continue; 
		}
		if(A == 0){
			P[i] = 0; Q[i] = 1; 
			M[make_pair(0, 1)] ++; 
		}else if(B == 0){
			P[i] = 1; Q[i] = 0; 
			M[make_pair(1, 0)] ++; 
		}else{
			long long G = gcd(abs(A), abs(B)); 
			long long p = A / G; long long q = B / G; 
			if(p < 0){
				p *= -1; q *= -1; 
			}
			P[i] = p; Q[i] = q; 
			M[make_pair(p, q)] ++; 
		}
	}
	if(allzero){
		cout << N << "\n"; return 0; 
	}
	long long ans = 1LL; 
	for(int i = 0; i < N; i++){
		if(P[i] == 0 && Q[i] == 0) continue; 
		if(seen[make_pair(P[i], Q[i])]) continue; 
		int a = M[make_pair(P[i], Q[i])]; 
		int b = M[make_pair(Q[i], -P[i])] + M[make_pair(-Q[i], P[i])]; 		
		long long mul = (mod + pow[a] + pow[b] - 1) % mod; 
		ans *= mul; ans %= mod; 
		seen[make_pair(P[i], Q[i])] = true; 
		seen[make_pair(Q[i], -P[i])] = true; 
		seen[make_pair(-Q[i], P[i])] = true; 
	}
	if(!zero){
		ans += mod - 1; ans %= mod; 
	}else{
		ans += zero - 1; ans %= mod; 
	}
	cout << ans << "\n"; 
}

Measured memory_bytes: 83352
from collections import deque

s = deque(input())
n = int(input())

memo = 0
for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        if  memo == 0: memo = 1
        else: memo = 0
    else:
        if memo == 0:
            if q[1] == '1': s.appendleft(q[2])
            else: s.append(q[2])
        else:
            if q[1] == '1': s.append(q[2])
            else: s.appendleft(q[2])

if memo == 0: print(''.join(s))
else: print(''.join(list(s)[::-1]))

Measured memory_bytes: 15776
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << w*h/2 << " ";
	if (w/2 == x && h/2 == y) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF ((1<<30) - 1)
int n;
struct Tree {
	Tree *c1, *c2;
	int L, S, pv;
	Tree(int b, int e) {
		L = 0;
		c1 = c2 = NULL;
		pv = b - 1;
		S = -1 * (e - b + 1);
	}
	Tree GetMax(int b, int e, int s) {
		if (b == s)return *this;
		int m = (b + e) >> 1;
		if (!c1) {
			c1 = new Tree(b, m);
			c2 = new Tree(m + 1, e);
		}
		if (m < s) return c2->GetMax(m + 1, e, s);
		Tree ret = c1->GetMax(b, m, s);
		if (ret.L < ret.S + c2->L) {
			ret.L = ret.S + c2->L;
			ret.pv = c2->pv;
		}
		ret.S = ret.S + c2->S;
		return ret;
	}
	void Add(int b, int e, int x) {
		if (b == e) {
			S++;
			if (S > 0) {
				L = S;
				pv = b;
			}
			return;
		}
		int m = (b + e) >> 1;
		if (c1 == NULL) {
			c1 = new Tree(b, m);
			c2 = new Tree(m + 1, e);
		}
		if (x <= m)c1->Add(b, m, x);
		else c2->Add(m + 1, e, x);
		S = c1->S + c2->S;
		L = max(c1->L, c1->S + c2->L);
		pv = c1->pv;
		if (L != c1->L) pv = c2->pv;
	}
	int Sum(int b, int e, int x) {
		if (b == x)return S;
		int m = (b + e) >> 1, r = 0;
		if (!c1) {
			c1 = new Tree(b, m);
			c2 = new Tree(m+1, e);
		}
		if (x <= m) {
			r = c2->S + c1->Sum(b, m, x);
		}
		else {
			r = c2->Sum(m + 1, e, x);
		}
		return r;
	}
};
int main() {
	int i, a;
	scanf("%d", &n);
	long long res = 0, SS = 0;
	Tree *Root = new Tree(0, INF);
	for (i = 1; i <= n; i++) {
		scanf("%d", &a);
		Tree rr = Root->GetMax(0, INF, a+1);
		res += rr.pv - a;
		res += Root->Sum(0, INF, rr.pv + 1) + (INF - rr.pv);
		Root->Add(0, INF, rr.pv);
		SS += rr.pv - a;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 232704
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ll long long

using namespace std;

const int maxn=2e5+5;

ll a[maxn][28];
ll i,j,k,l,r,x,y,n,t;
char s[maxn];
int ne[maxn];
bool bz;

void ge_border(){
	fo(i,2,n){
		while (j && s[j+1]!=s[i]) j=ne[j];
		if (s[j+1]==s[i]) j++;
		ne[i]=j;
	}
	t=n-ne[n];
	if (n%t==0) bz=true;
}
ll calc(ll x,int c){
	if (x<=n) return a[x][c];
	if (x<=2*n) return a[n][c]+a[x-n][c];
	ll t1=n,t2=n+t,an1=a[n][c],an2=an1+a[t][c],t3,an3;
	while (t1+t2<=x){
		t3=t2; t2=t1+t2; t1=t3;
		an3=an2; an2=an1+an2; an1=an3;
	}
	return an2+calc(x-t2,c);
}
ll ge_ans(ll x,int c){
	if (x<=n) return a[x][c];
	if (bz){
		x=x-n; ll ans=a[n][c];
		ans=ans+(x/t)*a[t][c]+a[x%t][c];
		return ans; 
	}
	return calc(x,c);
}
int main(){
//	freopen("077f.in","r",stdin);
	scanf("%s",s+1);
	scanf("%lld%lld",&l,&r);
	n=strlen(s+1)/2;
	ge_border();
	fo(i,1,n){
		fo(j,1,26) a[i][j]=a[i-1][j];
		a[i][s[i]-96]++;
	}
	fo(j,1,26) printf("%lld ",-ge_ans(l-1,j)+ge_ans(r,j));
	return 0;
}

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

int main()
{
    string s, t; cin>>s>>t;
    int a, b; cin>>a>>b;
    string u; cin>>u;
    if (u==s)
        cout<<a-1<<' '<<b<<endl;
    else
        cout<<a<<' '<<b-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int main()
{
    float r;
    cin>>r;
    cout<<2*M_PI*r<<endl;
    return 0;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vector<vector<vector<double>>> G(4);//L,R,U,Dの順
  for(ll i=0;i<n;i++){
    double x,y;
    char d;
    cin >> x >> y >> d;
    if(d=='L')G[0].push_back({x,y});
    else if(d=='R')G[1].push_back({x,y});
    else if(d=='U')G[2].push_back({x,y});
    else G[3].push_back({x,y});
  }


  vector<double> lx(4,-inf),sx(4,inf),ly(4,-inf),sy(4,inf);
  //cout << 5 << endl;
  for(ll i=0;i<4;i++){
    for(ll j=0;j<G[i].size();j++){
      lx[i]=max(lx[i],G[i][j][0]);
      sx[i]=min(sx[i],G[i][j][0]);
      ly[i]=max(ly[i],G[i][j][1]);
      sy[i]=min(sy[i],G[i][j][1]);
    }
  }

  //cout << 5 << endl;


  vector<double> kouho={0};
  
  double t[3];
  //x_maxについて
  double Lx=max(lx[2],lx[3]);
  t[0]=abs(lx[0]-Lx);
  t[1]=abs(lx[1]-Lx);
  t[2]=abs(lx[1]-lx[0])/2;
  for(ll i=0;i<3;i++)kouho.push_back(t[i]);

  //x_minについて
  double Sx=min(sx[2],sx[3]);
  t[0]=abs(sx[0]-Sx);
  t[1]=abs(sx[1]-Sx);
  t[2]=abs(sx[1]-sx[0])/2;
  for(ll i=0;i<3;i++)kouho.push_back(t[i]);

  //y_maxについて
  double Ly=max(ly[0],ly[1]);
  t[0]=abs(ly[2]-Ly);
  t[1]=abs(ly[3]-Ly);
  t[2]=abs(ly[2]-ly[3])/2;
  for(ll i=0;i<3;i++)kouho.push_back(t[i]);

  //y_minについて
  double Sy=min(sy[0],sy[1]);
  t[0]=abs(sy[2]-Sy);
  t[1]=abs(sy[3]-Sy);
  t[2]=abs(sy[2]-sy[3])/2;
  for(ll i=0;i<3;i++)kouho.push_back(t[i]);

  double ans=inf;
  for(ll i=0;i<kouho.size();i++){
    double T=kouho[i];
    double Xma,Xmi,Yma,Ymi;
    Xma=max(Lx,max(lx[0]-T,lx[1]+T));
    Xmi=min(Sx,min(sx[0]-T,sx[1]+T));
    Yma=max(Ly,max(ly[2]+T,ly[3]-T));
    Ymi=min(Sy,min(sy[2]+T,sy[3]-T));
    double p=(Xma-Xmi)*(Yma-Ymi);
    ans=min(ans,p);
  }

  printf("%f",ans);

  return 0;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    for(int i=0; i<n; i++) cin >> l[i];
    int d = 0;
    int j = 0;
    for(j=0; d<=x; j++){
        d += l[j];
    }
    cout << j << endl;
    return 0;
}

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

int mem[44][444][444];
int n , m , k ;
int a[44] , b[44] , c[44] ;

//  A/B == m/k
//  A*k == B*m

int dp(int i,int A,int B){
if( i == n ){
    if( A>0 && B>0 && A*k == B*m )return 0;
    return 1<<20;
}
int &ret = mem[i][A][B];
if( ret != -1 )return ret;
ret=dp(i+1,A,B);
ret=min( ret , dp(i+1,A+a[i],B+b[i])+c[i] );
return ret;
}

int main(){

cin>>n>>m>>k;
for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];

memset(mem,-1,sizeof mem);
int ans = dp(0,0,0);
if( ans > 100*n )ans=-1;
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 34176
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n").map(Number);
(function(a,b,c,d,p){
   var X=a*p;
   var Y=b;
   if(c<p)Y+=(p-c)*d;
   console.log(Math.min(X,Y));
}).apply(null,Arr);

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(int i=0;i<n-k;i++)
		sum+=a[i];
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define mod 1000000007
int main() {
	int n, m,t =0;cin >> n >> m;
	vector<ll> dp(n +1,0),a(m + 1,0);
	rep(i, m) cin >> a[i];
	if (a[t] != 1) dp[1] = 1;
	else {
		dp[1] = 0;t++;
	}
	if (a[t] != 2) dp[2] = dp[1] + 1;
	else {
		dp[2] = 0;t++;
	}
	for(int i = 3;i <= n;i++) {
		if (i == a[t]) {
			dp[i] = 0;t++;
		}
		else dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
	}
	cout << dp[n] << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int k,a=7,sol=1;
    cin >> k;

    int x = 7 % k;

    for (int  i = 1; i <= k; i++)
    {
        if (x == 0)
        {
            cout << i;
            return 0;
        }
        x = (x * 10 + 7) % k;
        
    }

    cout << -1;
    return 0;
}

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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

ll n;
void solve() {
  cin >> n;
  vector<double> p(n + 1);
  vector<double> dp(n + 1, 0);  // Number of i heads so far

  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    for (int j = i; j >= 1; j--) {
      dp[j] = dp[j] * (1 - p[i]) + dp[j - 1] * p[i];
    }
    dp[0] *= (1 - p[i]);
  }

  double ans = 0;
  for (int i = n; i > n / 2; i--) {
    ans += dp[i];
  }

  cout << fixed << setprecision(10) << ans;
}

int main(int argc, char const *argv[]) {

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

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 256
# ['表面', '南面', '東面', '西面', '北面', '裏面']
dice1 = [int(d) for d in input().split()]
dice2 = [int(d) for d in input().split()]

R1 = [
    [0, 1, 2, 3, 4, 5], # 移動なし
    [3, 1, 0, 5, 4, 2], # 東へ1
    [2, 1, 5, 0, 4, 3], # 西へ1
    [4, 0, 2, 3, 5, 1], # 南へ1
    [1, 5, 2, 3, 0, 4], # 北へ1
    [5, 4, 2, 3, 1, 0]  # 北へ2
]

R2 = [0, 3, 1, 4, 2, 5] # 水平回り1

ans = 'No'
for r1 in R1:
    dice3 = [dice2[i] for i in r1]
    for _ in range(4):
        dice3 = [dice3[i] for i in R2]
        if dice1 == dice3:
            ans = 'Yes'
            break
    else:
        continue
    break

print(ans)


Measured memory_bytes: 5604
def conform(string, i, Tmember):
    for t in Tmember:
        if s[i] != t:
            print("NO")
            exit()
        else:
            i += 1
    return i


S = str(input())
T = ["maerd", "remaerd", "esare", "resare"]
s = ""
for i in range(1, len(S)+1):
    s += S[-i]
count = 0
while(count < len(s)):
    flag = 4
    if s[count] == "m":
        flag = 0
    elif (s[count] == "r")and(s[count+1] == "e")and(s[count+2] == "m"):
        flag = 1
    elif s[count] == "e":
        flag = 2
    elif (s[count] == "r")and(s[count+1] == "e")and(s[count+2] == "s"):
        flag = 3
    else:
        print("NO")
        exit()
    count = conform(s, count, T[flag])
print("YES")


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

class UnionFind {
	vector<int> data;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		int ra = root(a), rb = root(b);
		if (ra == rb) return;
		if (data[ra] < data[rb]) {
			data[ra] += data[rb];
			data[rb] = a;
		}
		else {
			data[rb] += data[ra];
			data[ra] = b;
		}
	}
	int size(int a) {
		return -data[root(a)];
	}
};

int main()
{
	int n, q;
	int com, x, y;
	cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;
		if (com)
			cout << uf.Find(x, y) << endl;
		else
			uf.Union(x, y);
	}
	return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
#include<math.h>
using namespace std;
 
int main(){
    double r,x,y;
    scanf("%lf", &r);
    x = M_PI * r * r;
    y = 2 * M_PI * r;
    printf("%.5lf %.5lf\n",x,y);

    return 0;
}


Measured memory_bytes: 2740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] a = in.nextIntArray(n);

            int ans = Math.abs(a[0] - x);
            for (int i = 0; i < n; i++) {
                ans = (int) Euclid.gcd(ans, Math.abs(a[i] - x));
            }

            out.println(ans);
        }

    }

    static class Euclid {
        public static long gcd(long a, long b) {
            return a == 0 ? b : gcd(b % a, a);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 35808
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    REPL(i,0,n) cin>>a[i];
    if(n%2==0){
        SORTV(a);
        vector<ll> b,c,d,e;
        REPL(i,0,n/2) b.push_back(a[i]);
        REPL(i,n/2,n) c.push_back(a[i]);
        REPL(i,0,n/2){d.push_back(b[i]);d.push_back(c[i]);}
        REPL(i,0,n/2){e.push_back(c[i]);e.push_back(b[i]);}
        ll maxd=0,maxe=0;
        REP(i,0,n-1) maxd += abs(d[i]-d[i+1]);
        REP(i,0,n-1) maxe += abs(e[i]-e[i+1]);
        cout<<max(maxd,maxe)<<ENT;
    }else{
        SORTV(a);
        vector<ll> b,c;
        b.push_back(a[(n-1)/2]);
        REP(i,0,(n-1)/2){b.push_back(a[i+(n+1)/2]);b.push_back(a[i]);}
        c.push_back(a[(n-1)/2]);
        for(ll i=(n-3)/2; i>=0; --i){c.push_back(a[i]);c.push_back(a[i+(n+1)/2]);}
//        REP(i,0,n) cout<<b[i]<<" ";
//        cout<<ENT;
//        REP(i,0,n) cout<<c[i]<<" ";
        ll maxb=0,maxc=0;
        REP(i,0,n-1) maxb += abs(b[i]-b[i+1]);
        REP(i,0,n-1) maxc += abs(c[i]-c[i+1]);
        cout<<max(maxb,maxc)<<ENT;
    }
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 4212
# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

import datetime

def main():
    H, W = i2nn()
    HW = H * W
    A = ii2ss(H)
    A = [[0 if s == '#' else HW for s in line] for line in A]
    for i in range(H):
        for j in range(1, W):
            if A[i][j-1]+1 < A[i][j]:
                A[i][j] = A[i][j-1]+1
        for j in range(W-2, -1, -1):
            if A[i][j+1]+1 < A[i][j]:
                A[i][j] = A[i][j+1]+1
    for j in range(W):
        for i in range(1, H):
            if A[i-1][j]+1 < A[i][j]:
                A[i][j] = A[i-1][j]+1
        for i in range(H-2, -1, -1):
            if A[i+1][j]+1 < A[i][j]:
                A[i][j] = A[i+1][j]+1
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] > ans:
                ans = A[i][j]
    print(ans)

main()


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

int main()
{
  int num;
  int x[1000];
  int y[1000];
  int dst[1000];
  double minkov = 0.0;
  double manhat = 0.0;
  double manhat3 = 0.0;
  double euclid = 0.0;
  double a,b,c,d;
  double c1;

  cin >> num;
  for(int i = 0 ; i < num ; i++)
  {
    cin >> x[i];
  }
  for(int i = 0 ; i < num ; i++)
  {
    cin >> y[i];
    dst[i] = x[i] - y[i];
    if(dst[i] < 0)dst[i] = dst[i]*-1;
    minkov += dst[i];
    manhat += dst[i]*dst[i];
    manhat3 += dst[i]*dst[i]*dst[i];
    if(euclid < dst[i])euclid = dst[i];
  }
  a = minkov;
  b = pow(manhat,0.5);
  c = pow(manhat3,1.0/3.0);
  d = euclid;
  cout << fixed;
  cout << setprecision(9) << a << endl;
  cout << setprecision(9) <<b << endl;
  cout << setprecision(9) <<c << endl;
  cout << setprecision(9) <<d << endl;

  return 0;
}



Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int cnt[maxn];

int main() {
	int n; sd(n); for (int i = 0; i < maxn; i++) cnt[i] = 0;
	for (int i = 1; i <= n; i++) {
		int x; sd(x);
		cnt[x]++;
	}
	int ans = 0;
	for (int i = 1; i < maxn; i++) {
		ans = max(ans, cnt[i-1] + cnt[i] + cnt[i+1]);
	}
	pd(ans); endc;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sstream> //C++
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)







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

	if (n / 100 == 7) {
		cout << "Yes";
		return 0;
	}
	else if (n % 10 == 7) {
		cout << "Yes";
		return 0;
	}
	else if (n / 10 % 10 == 7) {
		cout << "Yes";
		return 0;
	}
	else {
		cout << "No";
		return 0;
	}

}




Measured memory_bytes: 3580
# coding: utf-8

keys = input().rstrip()
result = ""

for c in keys:
    if c == "0":
        result += "0"
    elif c == "1":
        result += "1"
    elif c == "B":
        l = len(result)
        if l > 0:
            result = result[:l-1]

print(result)


Measured memory_bytes: 3064
let xs = (stdin.ReadLine()).ToCharArray()
let mutable odd = true
let mutable even = true
for i in 0..xs.Length-1 do
    if (i+1) % 2 <> 0 then
        if xs.[i] <> 'R' && xs.[i] <> 'U' && xs.[i] <> 'D' then
            odd <- false
    else
        if xs.[i] <> 'L' && xs.[i] <> 'U' && xs.[i] <> 'D' then
            even <- false
printfn "%s" (if odd && even then "Yes" else "No")

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = abs(x1-x2);
  int dy = abs(y1 - y2);
  cout << string(dy,'U') << string(dx,'R');
  cout << string(dy,'D') << string(dx,'L');
  cout << 'L' << string(dy + 1,'U') << string(dx + 1,'R') << 'D';
  cout << 'R' << string(dy + 1,'D') << string(dx + 1,'L') << 'U' << endl;

return 0;
}

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

#define INF (1 << 30)

int min(int a, int b)
{
    return (b > a ? a : b);
}

/*
int memo(int b, int w, int col)
{
    int ans;
    
    if (w == n / 2){
        return (0);
    }
    
    if (dp[b][w][col] >= 0){
        return (dp[b][w][col]);
    }
    
    ans = 1 << 30;
    if (col == 0){
        if (w < n / 2){
            ans = min(ans, memo(b, w + 1, col));
        }
        if (b < n / 2){
            ans = min(ans, memo(b ^ 1, w, col ^ 1) + div[b + w]);
        }
    }
    else {
        if (b < n / 2){
            ans = min(ans, memo(b ^ 1, w, col));
        }
        if (w < n / 2){
            ans = min(ans, memo(b, w + 1, col ^ 1) + div[b + w]);
        }
    }
    
    return (dp[b][w][col] = ans);
}
*/

int main(void)
{
    int i, j, k;
    int n;
    int div[10001];
    static int dp[2][5001][2];
    
    scanf("%d", &n);
    
    for (i = 1; i <= n - 1; i++){
        scanf("%d", &div[i]);
    }
    
    for (i = 0; i < 2; i++){
        for (j = 0; j <= n / 2; j++){
            dp[i][j][0] = dp[i][j][1] = INF;
        }
    }
    dp[0][0][0] = 0;
    
    for (i = 0; i <= n / 2; i++){
        for (j = 0; j <= n / 2; j++){
            if (i > 0){
                dp[i % 2][j][0] = dp[(i - 1) % 2][j][0];
                dp[i % 2][j][1] = dp[(i - 1) % 2][j][0] + div[i + j];
            }
            if (j > 0){
                dp[i % 2][j][0] = min(dp[i % 2][j][0], dp[i % 2][j - 1][1] + div[i + j]);
                dp[i % 2][j][1] = min(dp[i % 2][j][1], dp[i % 2][j - 1][1]);
            }
        }
    }
    
    printf("%d\n", min(dp[n % 2][n / 2][0], dp[n % 2][n / 2][1]));
    
    return (0);
}

Measured memory_bytes: 476
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int N = S.size()-1;
    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[N-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    int M,L;
    M = (N)/2;
    L = (N+4)/2;
    int j = M-1;
    int k = N;
    int i = 0;
    while(i < j){
        if(S[i] != S[j]){
            cout << "No" << endl;
            return 0;
        }
        i++;
        j--;
    }
    i = L-1;
    while(i < k){
        if(S[i] != S[k]){
            cout << "No" << endl;
            return 0;
        }
        i++;
        k--;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
const int MaxN = 500 + 10 ;
int N , M ;
bool Map[MaxN][MaxN] ;
inline void Cin( bool &A ) {
	register char C = getchar() ;
	while( C == ' ' or C == '\n' ) C = getchar() ;
	A = ( C == '#' ) ;
}
int main() {
	Readin( N ) ;
	Readin( M ) ;
	for(register int i = 0 ; ++i <= N ; )
		for(register int j = 0 ; ++j <= M ; )
			Cin( Map[i][j] ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		for(register int j = 0 ; ++j <= M ; )
			putchar( ( Map[i][j] or ( j == 1 ) or ( j != M and ( i & 1 ) ) ) ? '#' : '.' ) ;
		putchar( '\n' ) ;
	}
	putchar( '\n' ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		for(register int j = 0 ; ++j <= M ; )
			putchar( ( Map[i][j] or ( j == M ) or ( j != 1 and ( ( i & 1 ) ^ 1 ) ) ) ? '#' : '.' ) ;
		putchar( '\n' ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <vector>
#define MAX 1234567890

int a;
int x[200010],ans[200010];
std::vector<int> V[200010];
std::vector<int> A[200010];
void func(int k, int prev)
{
	int min = 1, max = a;
	int p = 0;
	
	while(min<=max)
	{
		int h = (min+max)/2;
		if(A[h][A[h].size()-1] >= x[k])
		{
			p = h;
			max = h-1;
		}
		else min = h+1;
	}
	A[p].push_back(x[k]);
	
	min = 1, max = a;
	int p2 = 0;
	while(min<=max)
	{
		int h = (min+max)/2;
		if(A[h][A[h].size()-1] != MAX)
		{
			p2 = h;
			min = h+1;
		}
		else max = h-1;
	}
	ans[k] = p2;
	
	for(int i=0;i<V[k].size();i++)
	{
		if(V[k][i]==prev) continue;
		func(V[k][i],k);
	}
	A[p].pop_back();
}

int main()
{
	scanf("%d",&a);
	for(int i=1;i<=a;i++) A[i].push_back(MAX);
	
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<a;i++)
	{
		int b,c;
		scanf("%d%d",&b,&c);
		V[b].push_back(c);
		V[c].push_back(b);
	}
	func(1,0);
	for(int i=1;i<=a;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 36344
n = int(input())
w_l = [ input() for _ in range(n) ]
memo = set()
b_w = w_l[0][0]
ans = 'Yes'
for w in w_l:
    if b_w == w[0]:
        if w not in memo:
            memo.add(w)
            b_w = w[-1]
            continue
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
template<typename T> void read(T &x){
	char c=getchar();x=0;int f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;
}
int n,a[100007],ans,ha[100007],ha2[100007],ma,maa2,ma2,maa;
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=1;i<=n;i+=2)ha[a[i]]++;
	for(int i=1;i<=100000;i++){
		if(ha[i]>ha[ma]){ma2=ma;ma=i;}
		else{if(ha[i]>ha[ma2])ma2=i;}
	}
	for(int i=2;i<=n;i+=2)ha2[a[i]]++;
	for(int i=1;i<=100000;i++){
		if(ha2[i]>ha2[maa]){maa2=maa;maa=i;}
		else{if(ha2[i]>ha2[maa2])maa2=i;}
	}
	if(ma==maa){
		if(ha[ma2]>ha2[maa2])ans=n-ha[ma2]-ha2[maa];
		else ans=n-ha2[maa2]-ha[ma];
		cout<<ans<<endl;return 0;
	}
	cout<<n-ha[ma]-ha2[maa]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
print(I()**2)


Measured memory_bytes: 10436
#n = int(input())
s = input()
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

if s == "hi":
    print("Yes")
    exit()
s = s.split("hi")
for i in s:
    if i != "":
        print("No")
        exit()
print("Yes")
# if len(s) != 1:
#     print("Yes")
# else:
#     print("No")

Measured memory_bytes: 2940
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    a, b = reads()
    if a == 1:
        a = 14
    if b == 1:
        b = 14

    if a == b:
        print('Draw')
    elif a > b:
        print('Alice')
    else:
        print('Bob')
 
main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 200005
#define PMAX 55
#define PRECISION 0.00000000001
#define INF 2000000000
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int a[MAX];
bool top[MAX],bottom[MAX];
int main()
{
    int n,i,j;
    long long k=0,money=1000,price=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            top[i]=(a[i]>=a[i+1]);
            bottom[i]=(a[i]<=a[i+1]);
        }
        else if(i==n-1)
        {
            top[i]=(a[i]>=a[i-1]);
            bottom[i]=(a[i]<=a[i-1]);
        }
        else
        {
            top[i]=(a[i]>=a[i+1]&&a[i]>=a[i-1]);
            bottom[i]=(a[i]<=a[i+1]&&a[i]<=a[i-1]);
        }
    }
    for(i=0;i<n;i++)
    {
        if(bottom[i])
        {
            k=k+(money/a[i]);
            money=money-(money/a[i])*a[i];
        }
        if(top[i]||i==n-1)
        {
            money=money+k*a[i];
            k=0;
        }
        //printf("i=%d, k=%d, money=%d, price=%d\n",i,k,money,price);
    }
    printf("%lld",money);
    return 0;
}


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

using Graph = vector<vector<int>>;
int N, Q;
Graph G;

void dfs(int v, int p, vector<long long> &res) {
  if (p != -1) res[v] += res[p];
  for (auto e : G[v]) {
    if (e == p) continue;
    dfs(e, v, res);
  }
}

int main() {
  cin >> N >> Q;
  G.assign(N, vector<int>());
  for (int i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> val(N, 0);
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    --p;
    val[p] += x;
  }
  dfs(0, -1, val);
  for (auto v : val) cout << v << " ";
  cout << endl;
}

Measured memory_bytes: 25084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<int> L(2*N);
	rep(i,2*N) cin >> L[i];
	sort(L.begin(),L.end());
	int ans = 0;
	for(int i = 0; i < 2*N; i+=2){
		ans += L[i];
	}
	cout << ans << endl;

}



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

int main(void){
	long long A, V, B, W, T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;

	if (V*T >= (W*T+abs(A-B))) cout << "YES" << endl;
	else cout << "NO" << endl;

return 0;
}


Measured memory_bytes: 3132
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    x,y = na()
    if y%2:
        print('No')
        return
    y = y//2
    a,b = 2*x-y,y-x
    if a>=0 and b>=0:
        print('Yes')
    else:
        print('No')
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61888
import bisect
 
N = int(input())
A = [int(a) for a in input().split()]
A = sorted(A)
 
c = 0
for i in range(N - 1 , -1, -1):
    if A[i] == int(A[i]):
        b = 1
        while b <= A[i]:
            b <<= 1
 
        j = bisect.bisect_left(A, b - A[i])
        if i > j:
            if b - A[i] == A[j]:
                c += 1
                A[j] = A[j] - 0.5
                A[i] = A[i] + 0.5
print(c)

Measured memory_bytes: 25836
from collections import*
n, *a = map(int, open(0).read().split())
c = Counter(a)
MOD = 10**9+7
if n%2:
    if c.get(0, 0) != 1 or any(c.get(i, 0) != 2 for i in range(2, n, 2)):
        exit(print(0))
    print(2 ** (n // 2) % MOD)
else:
    if any(c.get(i, 0) != 2 for i in range(1, n, 2)):
        exit(print(0))
    print(2 ** (n // 2) % MOD)

Measured memory_bytes: 14320
import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int r = sc.nextInt();
        
        if(n<10){
            System.out.println(r+(100*(10-n)));
            return;
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; string s; cin >> n >> s;
    int c[26][2] = {};

    int ans = 0;
    FOR(i, 1, n-1){
        rep(j, i){
            c[s[j]-'a'][0]++;
        }
        FOR(j, i, n){
            c[s[j]-'a'][1]++;
        }

        int cnt = 0;
        rep(j, 26){
            if(c[j][0]>0 && c[j][1]>0) cnt++;
        }
        chmax(ans, cnt);

        rep(j, 26) rep(k, 2) c[j][k] = 0;
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  int N;
  cin >> N;
  int a;
  multiset<int> ans;
  set<int> k;
  rep(i,N){
    cin >> a;
    ans.insert(a);
    k.insert(a);
  }
  int c=0;
  for(auto i : k){
    if(ans.count(i)%2==1) c++;
  }
  cout << c << endl;
  
  return 0;

}

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

long long A, B, C;

int main() {
    cin >> A >> B >> C;
    vector<long long> v{A, B, C};
    sort(begin(v), end(v));
    long long ans = (v[2] % 2) * v[1] * v[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    if (S[K - 1] == 'A')
    {
        S[K - 1] = 'a';
    }
    else if (S[K - 1] == 'B')
    {
        S[K - 1] = 'b';
    }
    else if (S[K - 1] == 'C')
    {
        S[K - 1] = 'c';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;
int n;
int summ;
int cnt[3]={0};
vector<vector<vector<double>>>dp;
double eval(int a,int b,int c)
{
  if(dp[a][b][c]!=-1)
  {
    return dp[a][b][c];
  }
  else
  {
    double res=0;
    if(a>0){res+=eval(a-1,b,c)*a;}
    if(b>0){res+=eval(a+1,b-1,c)*b;}
    if(c>0){res+=eval(a,b+1,c-1)*c;}
    res=res/(a+b+c);
    res+=n/(a+b+c+0.0);
    dp[a][b][c]=res;
    return res;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  std::cout<<fixed<<setprecision(10);
  cin>>n;

  for(int i=0;i<n;i++)
  {
    int tmp;
    cin>>tmp;
    cnt[tmp-1]++;
  }
  dp=vector<vector<vector<double>>>(n+1,vector<vector<double>>(cnt[1]+cnt[2]+1,vector<double>(cnt[2]+1,-1)));
  dp[0][0][0]=0.0;
  cout<<eval(cnt[0],cnt[1],cnt[2])<<endl;
  return 0;

}


Measured memory_bytes: 216960
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int s;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        s = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
    	ArrayList<Integer> a = new ArrayList<Integer>();
    	a.add(s);	//初項
    	
    	int m = 0;
        for (int i=1; i<100000; i++) {
        	if (a.get(i-1) % 2 == 0) {
        		s =  s /2;
        	} else {
        		s = 3 * s + 1;
        	}
        	if (a.contains(s)) {
        		m = i + 1;
        		break;
        	} else {
        		a.add(s);
        	}
        }
        
        return m;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35792
#include <iostream>
using namespace std;
int n, x;
int primeTable[1000001];

void makePrimeTable(void) {

    primeTable[0] = false;
    primeTable[1] = false;
    for(int i = 2; i < 1000001; i++) {
        primeTable[i] = true;
    }
    
    for(int i = 2; i < 1000001; i++) {
        if(primeTable[i]) {
            for(int j = i + i; j < 1000001; j += i) {
                primeTable[j] = false;
            }
        }
    }
}


void search(int k, int * price, bool * numbers) {
    
    for(int i = 0; i < n; i++) {
        if(k + price[i] < x + 1) {
            if(!numbers[k + price[i]]) {
                numbers[k + price[i]] = true;
                search(k + price[i], price, numbers);
            }
        }
    }
}

int main(void){
    // Your code here!
    makePrimeTable();
    
    while(cin >> n >> x) {
        if(n == 0 && x == 0) break;
        
        int price[n];
        bool numbers[x+1];
        
        for(int i = 0; i < n; i++) {
            cin >> price[i];
        }
        for(int i = 0; i < x+1; i++) {
            numbers[i] = false;
        }
        numbers[0] = true;

        search(0, price, numbers);
        
        bool flag = true;
        for(int i = x; i >= 0; i--) {
            if(numbers[i] && primeTable[i]) {
                flag = false;
                cout << i << endl;
                break;
            }
        }
        if(flag) cout << "NA" << endl;
        
    }
}



Measured memory_bytes: 54816
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <bits/stdc++.h>

using namespace std;


const int INF=1e9 + 5;
int main(){
	cin.tie(0);
	int n;
	cin>>n;
	vector<int>dp(3);
	for(int day=0;day<n;day++){
		vector<int>new_dp(3,0);
		vector<int>c(3);
		for(int i=0;i<3;i++){
			cin>>c[i];
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp=new_dp;
	}
	
	printf("%d",max({dp[0],dp[1],dp[2]}));
	return 0;
}


Measured memory_bytes: 3692
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);i++)
int r,cl;//v,h
char a[10000];
void dp(int v, int h, char c){
	if(v>=r||v<0) return ;
	if(h>=cl||h<0) return ;
	if(a[v*cl+h]!=c) return ;
	a[v*cl+h]='0';
	dp(v-1,h,c);
	dp(v+1,h,c);
	dp(v,h-1,c);
	dp(v,h+1,c);
	return ;
}
int main(){
	cin>>r>>cl;
	while(r&&cl){
		forn(i,r){
				forn(j,cl) cin>>a[i*cl+j];
			}
			int ans=0;
			forn(i,r)
				forn(j,cl){
					if(a[i*cl+j]!='0'){
						dp(i,j,a[i*cl+j]);
						ans++;
					}
			}
			cout<<ans<<endl;
			cin>>r>>cl;
	}
	return 0;
}

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

const int MAX = 200010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long pow(long a, long n, long m) {
	long ret = 1;
	for (; n > 0; n >>= 1, a = a * a % m) {
		if (n % 2 == 1) {
			ret = ret * a % m;
		}
	}
	return ret;
}

long comb(long n,long r){
    long ret = 1;
    for(int i=1;i<=r;i++){
        ret*=inv[i];
        ret%=MOD;

        ret*=(n+1-i);
        ret%=MOD;
    }
    return ret;
}
signed main(){
    long n,a,b;
    cin>>n>>a>>b;
    long ans=pow(2,n,MOD)-1;
    COMinit();
    ans=(ans-comb(n,a)-comb(n,b))%MOD;
    if(ans<0)ans+=MOD;
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 4992