akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
#define MAX 100000
#define NIL -1
vector<int> G[MAX];
stack<int> S;
int color[MAX],n,m;
void dfs(int u,int id){
    S.push(u);
    color[u] = id;
    while(!S.empty()){
        u = S.top();
        S.pop();
        for(int i=0;i<G[u].size();i++){
            int v = G[u][i];
            if(color[v]==NIL){
                color[v] = id;
                S.push(v);
            }
        }
    }
}
void dfs_init(){
    int id = 0;
    for(int i=0;i<n;i++){
        color[i] = NIL;
    }
    for(int i=0;i<n;i++){
        if(color[i]==NIL)
            dfs(i,id++);
    }

}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs_init();
    int num;
    cin>>num;
    for(int i=0;i<num;i++){
        int u,v;
        cin>>u>>v;
        if(color[u]==color[v]){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 9004
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int Y = scan.nextInt();
        for(int i = 0; i <= N; i++){
            for(int j = 0; j <= N; j++){
                if((i*10000 + j*5000 + (N-i-j)*1000) == Y && (N-i-j) >= 0){
                    System.out.println(i + " " + j + " " + (N-i-j));
                    return;
                }else if((N-i-j) < 0){
                    break;
                }
            }
        }
        System.out.println(-1 + " " + -1 + " " + -1);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(void){
	double n;
	while(1){
		string ans = "";
		cin >> n;
		if(n < 0){
			break;
		}
		for(int i = 7;i >= -4;i--){
			if(n >= pow((double)2,(double)i)){
				ans += '1';
				n -= pow((double)2,(double)i);
			}else{
				ans += '0';
			}
			if(i == 0){
				ans += '.';
			}
		}
		if(n == 0){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1272
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long x[110000];
long long y[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%lld%lld",x+i,y+i);
	}
	long long D=1000000000000000000LL;
	long long ret=0;
	for(int i=0;i<61;i++){
		int cnt=0;
		long long at=(1LL<<i);
		for(int j=0;j<a;j++){
			long long n=D-(x[j]+y[j]);
			long long k=at-y[j];
			if(n<k||k<0)continue;
			if((n&k)==k)cnt++;
		}
		if(cnt%2)ret+=(1LL<<i);
	}
	printf("%lld\n",D-ret);
}

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

const int N = 100005;
const int mod = 1e9 + 7;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return 1LL * x * y % mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mul(ret, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ret;
}

int n;
int F[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	F[0] = 0;
	for (int i = 1; i <= n; ++i) {
		F[i] = F[i - 1];
		add(F[i], pw(i, mod - 2));
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		add(res, mod - x);
		add(res, mul(x, F[i]));
		add(res, mul(x, F[n - i + 1]));
	}
	for (int i = 1; i <= n; ++i) {
		res = mul(res, i);
	}
	cout << res << '\n';
}


Measured memory_bytes: 640
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vector<vi >adj(505);
vi ::iterator it,it1;
int main(){
	std::ios::sync_with_stdio(false);
	int n,m,q,i,j,l,r,ans=0;
	cin>>n>>m>>q;
	rep(i,m){
		cin>>l>>r;
		l--;
		r--;
		adj[l].pb(r);
	}
	rep(i,n){
		sort(all(adj[i]));
	}
	rep(i,q){
		cin>>l>>r;
		l--;
		r--;
		ans=0;
		f(j,l,r+1){
			it=upper_bound(adj[j].begin(),adj[j].end(),r);
			if(it==adj[j].begin()){
				continue;
			}
			else{
				it--;
				it1=lower_bound(adj[j].begin(),adj[j].end(),l);
				if(it1==adj[j].end()){
					continue;
				}
				else{
					ans+=(int)(it-it1+1);
				}
			}
		}
		cout<<ans<<endl;
	}
} 
	

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

int main(){
	int n;
	cin >>n ;
	vector<long> x(n);
	if(n/100 == 7 || (n / 10) % 10 == 7 || n % 10 == 7) {
  		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
#include<stdlib.h>

#define N 100000
#define INF 1000000

typedef struct{
  int go, back, cost;
}Date;

int n, d[N];
Date a[500000];
void root(int);

int main(){
  int i, j, u, k, count = 0;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++) {
    scanf("%d%d", &u, &k);
    for( j = 0 ; j < k ; j++){
      a[count].back=u;
      scanf("%d%d", &a[count].go, &a[count].cost);
      count++;
    }
  }
  root(count);
  for( i = 0 ; i < n ; i++) printf("%d %d\n", i, d[i]);
  return 0;
}



void root(int b){
  int i, flag = 1;

  for( i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0){
    flag = 0;
    for( i = 0 ; i < b ; i++){
      if(a[i].cost + d[a[i].back] < d[a[i].go]){
        d[a[i].go] = a[i].cost + d[a[i].back];
        flag = 1;
      }
    }
  }
}



Measured memory_bytes: 7584
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    int M, K;
    cin >> M >> K;
    if (M == 0) {
        if (K == 0)
            cout << "0 0" << endl;
        else
            cout << -1 << endl;
        return 0;
    } else if (M == 1) {
        if (K == 0)
            cout << "0 0 1 1" << endl;
        else
            cout << -1 << endl;
        return 0;
    }

    int len = pow(2, M);
    if (K >= len) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    for (int i = 0; i < len; i++) {
        if (i == K) {
            continue;
        }
        cout << i << " ";
    }
    cout << K << " ";
    for (int i = len - 1; i >= 0; i--) {
        if (i == K) {
            continue;
        }
        cout << i << " ";
    }
    cout << K << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	string N;
	cin >> N;
	
	bool flag = true;
	for(int i = N.size() - 1; i > 0; i--){
		if(N[i] != '9'){
			flag = false;
		}
	}
	if(flag){
		cout << (N.size() - 1) * 9 + N[0] - '0' << endl;
	}else{
		cout << (N.size() - 1) * 9 + N[0] - '0' - 1 << endl;
	}
	
	return 0;
	
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
counter = 0
data = []
tmp = {}#問題番号をkeyとしてWAをカウント

wa = 0
#入力処理
for _ in range(m):
  a,b = input().split() #入力処理
  if b == "WA": #解答がWA→tmpに問題番号をkeyとしてカウント
    if int(a) not in tmp:
      tmp[int(a)] = 0
    if tmp[int(a)] != -1:
      tmp[int(a)] += 1
  if int(a) not in tmp: #WA無しのACの対応 
    tmp[int(a)] = 0
  if (( b == "AC") and (tmp[int(a)] != -1)):#解答がACでtmp[問題番号]が出力済みでない場合
    counter += 1
    #checkd.append(int(a))
    wa += tmp[int(a)] #問題番号aの値をWAの合計に加算
    tmp[int(a)] = -1 #問題番号aが加算済み


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)

  
  



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

typedef long long ll;


int n;
map<char,map<char,int>> c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        c[s.front()][s.back()]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        ans += c[s.back()][s.front()];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int a[N][N],s[N][N],t[N][N],b1[N][N],b2[N][N];
int main()
{
	int n,m,q,x1,y1,x2,y2,sum1,sum2;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
	{
		getchar();
		for(int j=1;j<=m;j++)
		{
			a[i][j]=getchar()-'0';
			s[i][j]=s[i-1][j]+s[i][j-1]+a[i][j]-s[i-1][j-1];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j])
			{
				if(a[i-1][j])
					t[i][j]++;
				if(a[i][j-1])
					t[i][j]++;
			}
			t[i][j]=t[i-1][j]+t[i][j-1]+t[i][j]-t[i-1][j-1];
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]&&a[i-1][j])
				b1[i][j]=1;
			b1[i][j]+=b1[i][j-1];
		}
	}
	for(int i=2;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[j][i]&&a[j][i-1])
				b2[j][i]=1;
			b2[j][i]+=b2[j-1][i];
		}
	}
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		sum1=s[x2][y2]+s[x1-1][y1-1]-s[x1-1][y2]-s[x2][y1-1];
		sum2=t[x2][y2]+t[x1-1][y1-1]-t[x1-1][y2]-t[x2][y1-1];
		sum2-=b1[x1][y2]-b1[x1][y1-1];
		sum2-=b2[x2][y1]-b2[x1-1][y1];
		printf("%d\n",sum1-sum2);
	}
	return 0;
}


Measured memory_bytes: 80256
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int64{
  sc.Scan()
  i, e :=strconv.ParseInt(sc.Text(), 10, 64)
  if e!=nil{
    panic(e)
  }
  return i
}
func min (a *int64, b int64) bool{
  if *a>b{
    *a=b
    return true
  }
  return false
}
func abs(a int64) int64{
  if a<0{
    return a*-1
  }else{
    return a
  }
}
func main(){
  var i, j int64
  dp:=make([]int64, 110000)
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  k:=nextInt()
  a:=make([]int64, 110000)
  for i=0;i<n;i++{
    a[i]=nextInt()
  }
  for i=0;i<100001;i++{
    dp[i]=1000000001
  }
  dp[0]=0
  for i=0;i<n;i++{
    for j=1;j<=k;j++{
      min(&dp[i+j], dp[i]+abs(a[i]-a[i+j]))
    }
  }
  fmt.Println(dp[n-1])
}


Measured memory_bytes: 2816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};




int sq[200];
int ans[33001];
int n;

main(){
  rep(i,200)sq[i]=i*i;
  for(int i=1;i<200;i++){
    int ti=sq[i];
    if(ti>33000)break;
    ans[ti]++;
    for(int j=i;j<200;j++){
      int tj=ti+sq[j];
      if(tj>33000)break;
      ans[tj]++;
      for(int k=j;k<200;k++){
	int tk=tj+sq[k];
	if(tk>33000)break;
	ans[tk]++;
	for(int l=k;l<200;l++){
	  int tl=tk+sq[l];
	  if(tl>33000)break;
	  ans[tl]++;
	}
      }
    }
  }
  
  while(cin>>n,n){
    cout<<ans[n]<<endl;
  }
}

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

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

    unordered_set<int> s;
    while(K--){
        int D; cin >> D;
        int c[D];
        for(int i = 0; i < D; ++i){
            cin >> c[i];
            s.insert(c[i]);
        }
        if(s.size() == N){
            break;
        }
    }
    cout << N-s.size() << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>
#include<algorithm>
using namespace std;

string intplus(string a,string b){
  if(a.size()<b.size())swap(a,b);
  int ai=a.size()-1,bi=b.size()-1,bii,k=0;
  string c = a;
  for(;ai>=0;ai--,bi--){
    bii = bi>=0?b[bi]:48;
    c[ai] = (a[ai]+bii+k-96)%10+48;
    if((a[ai]+bii+k-96)>=10)k=1;
    else k=0;
  }
  if(k==1)c="1"+c;
  return c;
}

int main(){
  string a,b,c,d,f,ff,n;
  while(cin>>f){
    bool chk = false;
    for(int i=0;i<10;i++){
      ff = f;
      n = " ";
      n[0] = (char)(i+48);
      while(ff.find("X")!=-1)ff.replace(ff.find("X"),1,n);
      a = ff.substr(0,ff.find("+"));
      b = ff.substr(ff.find("+")+1,ff.find("=")-ff.find("+")-1);
      c = ff.substr(ff.find("=")+1);
      if(i==0&&((a.size()>1&&a[0]=='0')||(b.size()>1&&b[0]=='0')||(c.size()>1&&c[0]=='0'))) continue;
      //cout<<intplus(a,b)<<endl;
      if(intplus(a,b)==c){
	cout<<i<<endl;
	chk = true;
      break;
      }
    }
    if(!chk)cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import math
H, W = map(int, input().split())

w1 = math.ceil(W/2)*math.ceil(H/2)
w2 = math.floor(W/2)*math.floor(H/2)

if H == 1:
    print(1)
elif W==1:
    print(1)
elif W != 1:
    print(w1+w2)

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	long long n,k; cin >> n >> k;
	vector<long long> A;
	vector<long long> S;
	map<long long,int> D;
	vector<long long> F;
	A.push_back(0);
	long long s=1;
	for (long long i=0;i<n;i++){
		long long a; cin >> a;
		A.push_back(a);
		D[i+1]=0;
	}
	D[1]=1;
	long long f=0;
	S.push_back(1);
	for (long long i=1;i<=k;i++){
		s=A[s];
		if (D[s]==1){
			for (int i=0;i<S.size();i++){
				if(S[i]==s){
					f=i;
					break;
				}
			}
			long long g=S.size()-f;
			long long h=(k-f)%g;
			cout << S[f+h] << "\n";
			return 0;	
		}
		D[s]=1;
		S.push_back(s);
	}
	cout << s << "\n";
}


Measured memory_bytes: 20188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
using ll = long long;
int main(){
  int a;
  cin >> a;
  string s;
  cin >> s ;
  rep(i,s.length()){
    if(s[i]+a>=91){
      s[i] = s[i]+a-26;
    }else{
      s[i]+=a;
    }
}
cout << s <<  endl;
  return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

int main() {
	string s, s1 = "AC";
	cin >> s ;
		int flag = 0;
		for(int i = 0; i <s.size(); i++){
			string ss;
			ss.clear();
			for (int j = i,k = 1; k <=2; k++, j++)
				ss += s[j];
			if(ss == s1) flag = 1;
		}
		if(flag) cout << "Yes" << endl;
		else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll N=5e5+5;

int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,a,b;cin>>n>>a>>b;
    ll ans=min(b-1,n-a);
    if(a%2==b%2)ans=min(ans,(b-a)/2);
    else{
        ll val=min(a-1,n-b);
        val = val + (b-a+1)/2;
        ans=min(ans,val);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  int n, ans=1, x;
    cin >> n;
  int a[n];
    if(n%2){
      for(int i=0; i<n; i++){
        cin >> x;
        if(x%2==0) a[i] = x;
        else ans = 0;
      }
    }else{
      for(int i=0; i<n; i++){
        cin >> x;
        if(x%2==1) a[i] = x;
        else ans = 0;
      }
    }
    sort(a, a+n);
    
    if(n%2){
      if(a[0]!=a[1]&& a[0]==0){
        for(int i=1; i<n-1; i++)
          if(a[i-1]==a[i] && a[i]==a[i+1]) ans = 0;
          else if(n<=a[i]) ans = 0;
      }else{
        ans = 0;
      }
    }else{
      if(a[0]==a[1] && a[0]==1){
        for(int i=1; i<n-1; i++)
          if(a[i-1]==a[i] && a[i]==a[i+1]) ans = 0;
          else if(n<=a[i]) ans = 0;
      }else{
        ans = 0;
      }
    }

    if(ans){
      int dig=n/2;
      for(int i=0; i<dig; i++)
        ans = (ans*2)%mod;

    }

    cout << ans << endl;


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
const int INF = 1<<29;

using namespace std;


bool palindrome(int start,int end,string str)
{
	while(start<=end)
	{
		if(str[start++]!=str[end--]) return false;
	}
	return true;
}
bool check(string str)
{
	return palindrome(0,str.size()-1,str) && palindrome(0,(((str.size())-1)/2)-1,str) && palindrome(((str.size()+3)/2)-1,str.size()-1,str);
}

int main()
{
	
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();  
	string name;cin>>name;
	if(check(name)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;





	//time_req = clock()- time_req;cout << "Time Compexity:"<< (float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n); REP (i, n) cin >> a[i];
  int ans = 1e18;
  REP (i, n - 1) {
    int w0 = 0, w1 = 0;
    REP (j, n) {
      (j <= i ? w0 : w1) += a[j];
    }
    chmin(ans, abs(w0 - w1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import static java.lang.System.out;
import java.io.File;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() throws Exception {
        String data;
        for (int count = 1; count <= 10000; count++) {
            if ("0".equals(data = nextLine()))
                break;
            out.println("Case " + count + ": " + data);
        }
    }
}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 59704
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int x,t;
  cin>>x>>t;
  cout<<max(0,x-t)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

std::map<char, char> m;
std::map<char, char> w;
std::string s, t;
bool all_same = true;
int main() {
    std::cin >> s >> t;
    for (int i = 0; i < t.size(); i++) {
        auto g = w[s[i]];
        auto p = m[t[i]];
        if (p == '\0') {
            m[t[i]] = s[i];
        }
        if (g == '\0') {
            w[s[i]] = t[i];
        }
        if (p != '\0' && p != s[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
        if (g != '\0' && g != t[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 776
n,m = map(int,input().split())

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

sum_a = sum(a)

res = 0
for i in range(n):
	if a[i] >= sum_a / (4*m):
		res += 1

if res >= m:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  ll n; cin >> n;
  vector<ll> a(n);

  rep(i,n)  cin >> a.at(i);

  sort(all(a));
  ll Aside=0,Bside=0;

  for(int i=n-2;i>=0;i--){
    if(a.at(i)==a.at(i+1)){
      if(!Aside){
        Aside = a.at(i);
      }else if(!Bside){
        Bside = a.at(i);
      }
      i--;
    }
  }
  cout << Aside*Bside << endl;
}


Measured memory_bytes: 3912
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N], b[N], c[N], d[N];
map<int, int> par, sz;
int find(int x) {
	if (par.find(x) == par.end()) return par[x] = x;
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}
void unite(int u, int v) {
	u = find(u);
	v = find(v);
	if (u == v) return;
	par[u] = v;
}
map<int, int> deg;
int main() {
	int n;
	cin >> n;
	int s0 = 0;
	for (int j = 0; j < n; ++j) cin >> a[j], s0 ^= a[j], c[j] = a[j];
	c[n] = s0;
	int s1 = 0;
	for (int j = 0; j < n; ++j) cin >> b[j], s1 ^= b[j], d[j] = b[j];
	d[n] = s1;
	++n;
	sort(d, d + n);
	sort(c, c + n);
	for (int j = 0; j < n; ++j)
		if (c[j] != d[j]) {
			cout << -1 << endl;
			return 0;
		}
	--n;
	set<int> all;
//	if (s0 != s1) unite(s0, s1);
	int res = 0;//flag = 0;
	for (int j = 0; j < n; ++j) {
		res += (a[j] != b[j]);
		if (a[j] != b[j]) {
			unite(a[j], b[j]);
		}
	}
	if (res == 0) {
		cout << 0 << endl;
		return 0;
	}
	unite(s0, s1);
	for (int j = 0; j < n; ++j)
		if (a[j] != b[j])
			all.insert(find(a[j]));
	all.erase(find(s0));
	cout << max(0, res + (int) all.size()) << endl;
	 
	 
}








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

bool check (int d[10][5], int h) {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 5; j++) {
            int count = 1;
            while (j + 1 < 5 && d[i][j] == d[i][j + 1] && d[i][j] != 0) {
                j++;
                count++;
            }
            if (count >= 3) return true;
        }
    }
    return 0;
}

int main ()
{
    int h;
    while (cin >> h, h) {
        int d[10][5];
        for (int i = h - 1; i >= 0; i--) {
            for (int j = 0; j < 5; j++) {
                int t; cin >> t; d[i][j] = t;
            }
        }

        int res = 0;
        while (check(d, h)) {
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < 5; j++ ) {
                    int count = 1;
                    while (j + 1 < 5 && d[i][j] == d[i][j + 1] && d[i][j] != 0) {
                        j++; count++;
                    }
                    if (count >= 3) {
                        res += count * d[i][j];
                        for (int k = j; count--; k--) {
                            d[i][k] = 0;
                        }
                    }
                }
            }

            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < h; j++) {
                    if (d[j][i] == 0) {
                        int n = 0;
                        for (int k = j; k < h; k++) {
                            if (d[k][i] != 0) n++;
                            if (k < h - 1) {
                                d[k][i] = d[k + 1][i];
                            } else {
                                d[k][i] = 0;
                            }
                        }
                        if (n > 0) j--;
                    }
                }
            }
        }
        cout << res << endl;
    }

    return 0;
}

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


using namespace std;


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

    int A;
    cin >> A;

    int x[ N ];
    for ( int i = 0; i < N; i++ ) { cin >> x[ i ]; }
    cout << endl;

    const int DP_MAX_SIZE = N * A;
    
    long long*** dp = new long long**[ N + 1 ];
    for ( int i = 0; i < N + 1; i++ ) {
        dp[ i ] = new long long*[ DP_MAX_SIZE + 1 ];
        
        for ( int j = 0; j < DP_MAX_SIZE + 1; j++ ) {
            dp[ i ][ j ] = new long long[ N + 1 ];

            for ( int k = 0; k < N + 1; k++ ) {
                dp[ i ][ j ][ k ] = 0;
            }
        }
    }
    dp[ 0 ][ 0 ][ 0 ] = 1;
    

    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j <= DP_MAX_SIZE; j++ ) {
            for ( int k = 0; k < N; k++ ) {
                dp[ i + 1 ][ j ][ k ] += dp[ i ][ j ][ k ];

                if ( j >= x[ i ] ) {
                    dp[ i + 1 ][ j ][ k + 1 ] += dp[ i ][ j - x[ i ] ][ k ];
                }
            }
        }
    }
    
    long long ans_count = 0;
    for ( int i = A, j = 1; i <= DP_MAX_SIZE; i += A, j++ ) {
        ans_count += dp[ N ][ i ][ j ];
    }
    
    cout << ans_count << endl;

    return 0;
}


Measured memory_bytes: 53120
using System;
using System.Collections.Generic;

class ABC_126_D
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        Node[] node = new Node[N];

        for (int i = 0; i < N; i++)
        {
            Node n = new Node();
            node[i] = n;
        }
        for (int i = 0; i < N-1; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int u = int.Parse(input[0]);
            int v = int.Parse(input[1]);
            int w = int.Parse(input[2]);

            Connection c1 = new Connection();
            c1.target = node[v-1];
            c1.length = w;
            node[u-1].targetList.Add(c1);

            Connection c2 = new Connection();
            c2.target = node[u-1];
            c2.length = w;
            node[v-1].targetList.Add(c2);
        }

        node[0].color = 0;
        SetColor(node[0]);

        for (int i = 0; i < node.Length; i++)
        {
            Console.WriteLine(node[i].color);
        }
    }

    static void SetColor(Node n)
    {
        for (int i = 0; i < n.targetList.Count; i++)
        {
            Connection conn = n.targetList[i];
            if(conn.target.color<0)
            {
                conn.target.color = (conn.length % 2 == 0) ? n.color : (n.color+1)%2;
                SetColor(conn.target);
            }
        }
    }
}

class Node
{
    public int color = -1;
    public List<Connection> targetList = new List<Connection>();
}

class Connection
{
    public Node target;
    public int length;
}

Measured memory_bytes: 37972
#include <stdio.h>
#define N 101
int main(){
  int i,j,n,m,l,b;
  int A[N][N];

  scanf("%d",&n);

  for(i=1;i<=n;++i){
    for(j=1;j<=n;++j)A[i][j]=0;
  }

  for(i=1;i<=n;++i){
    scanf(" %d %d",&m,&l);
     
    for(j=1;j<=l;++j){
      scanf("%d",&b);
      A[m][b] = 1;
    }
  }

  for(i=1;i<=n;++i){
    for(j=1;j<n;++j)  printf("%d ",A[i][j]);
    printf("%d\n",A[i][j]);
  }
  return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,r=0;
  cin>>n;
  vector<int> p(n);
  for(auto& i:p)cin>>i;
  for(int i=1;i<n-1;++i)if(max({p[i-1],p[i],p[i+1]})!=p[i]&&min({p[i-1],p[i],p[i+1]})!=p[i])r++;
  cout<<r;
}

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

int main() {
    int n; scanf("%d", &n);
    n %= 10;
    if (n == 3) printf("bon\n");
    else if (n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
    else printf("hon\n");
}

Measured memory_bytes: 1652
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=list(input())

    # アルファベット小文字→(97, 123)
    # アルファベット大文字→(65, 91)
    # 半角数字→(48, 58)
    # ひらがな→(12353, 12436)
    # カタカナ→(12449, 12532+1)
    # 全角数字→(65296, 65306)

    def moji_list(*args):
        moji = []
        for i in range(len(args)):
            moji.extend([chr(j) for j in range(args[i][0], args[i][1])])
        return moji

    lowercase = moji_list((97,123))

    for i in s:
        if i in lowercase:
            lowercase.remove(i)
    print(lowercase[0] if len(lowercase)!=0 else 'None')

resolve()

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

int main(){
    int N; cin >> N;
    string S[N];
    map<string, ll> M;
    set<string> SET;
    for(int i= 0; i < N; i++){
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        SET.insert(S[i]);
        M[S[i]]++;
    }

    ll res = 0;
    for(auto it: SET){
        res += M[it] * (M[it]-1)/2;
    }

/*
    ll hash[10000] = {0};
    for(int i = 0; i < N; i++){
        int t = 0;
        for(int j = 0; j < 10; j++){
            t += (S[i][j] - 'a') * 27;
        }
        //cout << t << endl;
        hash[t]++;

    }
    */
    cout << res << endl;
}

Measured memory_bytes: 27648
#!/usr/bin/env python3

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [None] * n
    allxor = 0
    for i in range(n):
        allxor ^= a[i]
    for i in range(n):
        ans[i] = allxor ^ a[i]
    print(*ans)


if __name__ == "__main__":
    main()


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

int main(){
  vector<char> v(9);
  for(int i = 0; i < 9; i++){
    cin >> v.at(i);
  }
  cout << v.at(0) << v.at(4) << v.at(8) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

struct Edge {
    ll a, b, cost, index;
    bool operator<(const Edge &e) const {
        return (cost < e.cost);
    }
};

int main() {
    ll n;
    cin >> n;
    const ll m = 2*(n-1);

    vector<pair<ll, ll>> p1(n), p2(n);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        p1[i] = make_pair(x, i);
        p2[i] = make_pair(y, i);
    }
    sort(all(p1));
    sort(all(p2));

    vector<Edge> es(m);  // es[i] : 辺iは頂点es[i].aと頂点es[i].bをコストes[i].costで結ぶ
    rep(i, m) {
        if(i < n-1) {
            es[i].a = p1[i].second;
            es[i].b = p1[i+1].second;
            es[i].cost = abs(p1[i].first - p1[i+1].first);
        }
        else {
            es[i].a = p2[i - (n-1)].second;
            es[i].b = p2[(i+1) - (n-1)].second;
            es[i].cost = abs(p2[i - (n-1)].first - p2[(i+1) - (n-1)].first);
        }
    }
    sort(all(es));  // esをcostの昇順でソート
    
    UnionFind Uni(n);
    Uni.init(n);
    
    // クラスカル法。計算量はO(E*log(E))
    ll ans = 0;
    rep(i, m) {
        if(!Uni.same(es[i].a, es[i].b)) {
            Uni.unite(es[i].a, es[i].b);
            ans += es[i].cost;
        }
    }
    
    out(ans);
    re0;
}

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

int main()
{
	ll n,m,f=0,i,on=0;
	cin>>n>>m;
	map<ll,ll>mp;
	for(i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x==1)
			on=1;
		if(mp[x]==0)
			mp[x]=y;
		else
		{
			if(mp[x]!=y)
				f=-1;
		}
	}
	if(mp[1]==0 && on==1 && n!=1)
		f=-1;
	// if(n==2 && mp[1]==0 && mp[2]==0)
	// 	f=-1;
	// if(n==3 && mp[1]==0 && mp[3]==0 && mp[2]==0)
	// 	f=-1;
	if(f==-1)
		cout<<-1<<"\n";
	else if(n==1 && mp[1]==0)
		cout<<0;
	else
	{
		for(i=0;i<n;i++)
		{
			if(i==0)
			{
				if(mp[1]!=0)
				cout<<mp[1];
				else
					cout<<1;
			}
			else
			{
				if(mp[i+1] != 0)
					cout<<mp[i+1];
				else
					cout<<0;
			}
		}
	}
	return 0;
}

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

double get_distance(double x1, double y1, double x2, double y2)
{
	return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

double get_area(double a, double b, double c)
{
	return a * b * sin(c * M_PI / 180) / 2;
}

double get_length(double a, double b, double c)
{
	return a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c * M_PI / 180));
}

double get_height(double b, double c)
{
	return b * sin(c * M_PI / 180);
}

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

	cout << fixed << setprecision(12) << get_area(a, b, c) << endl;
	cout << fixed << setprecision(12) << get_length(a, b, c) << endl;
	cout << fixed << setprecision(12) << get_height(b, c) << endl;
}


Measured memory_bytes: 3588
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n],i,j,k,l;
    for(i=0;i<n;i++) {
        cin>>a[i]>>b[i]>>c[i];
    }
    int h[n][3]={0};
    h[0][0]=a[0];
    h[0][1]=b[0];
    h[0][2]=c[0];
    for(i=1;i<n;i++) {
        h[i][0]=max(h[i-1][1],h[i-1][2])+a[i];
        h[i][1]=max(h[i-1][0],h[i-1][2])+b[i];
        h[i][2]=max(h[i-1][1],h[i-1][0])+c[i];
    }
    cout<<max(h[n-1][0],max(h[n-1][1],h[n-1][2]))<<endl;

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int main() {
    int a, b;
    cin >> a >> b;
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define RANGE(i, x, n) for(int i = x; i < n; ++i)
using namespace std;

struct Creature {
    long long a;
    long long sum;
    bool operator <(const Creature &r) const {
        return a < r.a;
    }
};

bool judge(int pos, vector<Creature> &A)
{
    if(pos <= 0) {
        return false;
    }
    RANGE(i, pos - 1, A.size() - 1) {
        if(2 * A[i].sum < A[i + 1].a) {
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    vector<Creature> A;
    Creature tmp;
    REP(i, N) {
        cin >> tmp.a;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end());

    long long res = 0;
    REP(i, N) {
        res += A[i].a;
        A[i].sum = res;
        //cout << A[i].sum << endl;
    }

    int l = 0, h = A.size();
    int mid = (l + h) / 2;
    while(mid != l) {
        if(judge(mid, A)) {
            h = mid;
        }else {
            l = mid;
        }
        mid = (l + h) / 2;
    }
    cout << A.size() - mid << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int bt = 0, bx = 0, by = 0, t, x, y;
    bool ok = true;
    rep(i, n) {
        cin >> t >> x >> y;
        bt = t - bt;
        bx = abs(x - bx);
        by = abs(y - by);
        if (bx + by > bt) ok = false;
        if ((bt - bx - by) % 2 == 1) ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;

int main(){
    long N;
    cin>>N;
    vector<vector<int>> F(N,vector<int>(10));
    for(auto i=0;i<N;i++){
        for(auto j=0;j<10;j++){
            cin>>F[i][j];
        }
    }
    ll P[N][10];
    for(auto i=0;i<N;i++){
        for(auto j=0;j<11;j++){
            cin>>P[i][j];
        }
    }
    
    ll res = LLONG_MIN;
    for(ll bit=1;bit < (1<<10);bit++){
        vector<ll> c(N,0);
        ll tmp = 0;
        for(ll i=0;i<10;i++){
            if((1<<i)&bit){
                for(long sh=0;sh<N;sh++){
                    c[sh] += F[sh][i];
                }
            }
        }
        for(auto i=0;i<N;i++){
            tmp += P[i][c[i]]; 
        }
        res = max(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "strconv"
)

func main() {

  var s int

  fmt.Scan(&s)
  
  v := 1000000000
  x := (v-s%v)%v
  y := (s+x)/v

  fmt.Println("0 0 1000000000 1 " + strconv.Itoa(x) + " " + strconv.Itoa(y))

}

Measured memory_bytes: 512
n,d = map(int, input().split())
import numpy as np
import itertools
x = np.array([np.array(list(map(int, input().split()))) for _ in range(n)])
count = 0
for i,j in itertools.combinations(x,2):
  k = np.sqrt(np.sum(np.square(i-j)))
  if k==int(k):
    count += 1
    
print(count)
  

Measured memory_bytes: 12408
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

const int maxn=3010;
const int mo=1000000007;

int n,m,f[maxn][maxn],z[maxn];

int mul(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=1ll*ans*a%mo;
		a=1ll*a*a%mo;
		b>>=1;
	}
	return ans;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int a=1;a<=n;a++)
		scanf("%d",&z[a]);
	for (int a=1;a<=n;a++)
		for (int b=1;b<=n;b++)
			f[a][b]=(z[a]<z[b]);
	int div2=mul(2,mo-2);
	for (int a=1;a<=m;a++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if (x==y) continue;
		f[x][y]=f[y][x]=(0ll+f[x][y]+f[y][x])*div2%mo;
		for (int b=1;b<=n;b++)
			if (b!=x && b!=y)
			{
				f[b][x]=f[b][y]=(0ll+f[b][x]+f[b][y])*div2%mo;
				f[x][b]=f[y][b]=(0ll+f[x][b]+f[y][b])*div2%mo;
			}
	}
	int ans=0;
	for (int a=1;a<=n;a++)
		for (int b=a+1;b<=n;b++)
		{
			ans += f[b][a];
			if (ans>=mo) ans-=mo;
		}
	printf("%d\n",1ll*ans*mul(2,m)%mo);

	return 0;
}


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

int main(){
  int n; cin>>n;
  vector<ll>A(n);
  rep(i,n){
    cin>>A[i];
    if (A[i]==0){
      cout << 0;
      return 0;
    }
  }
  ll ans = A[0];
  for(int i=1; i<n; i++){
    if (A[i]<=(1000000000000000000/ans)){
      ans *= A[i];
    }
    else{
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    int x,y;
    cin >> x >> y;
    string ans = "No";
    for(int i=0; i<x+1;i++){
        if(y == (2*i+4*(x-i))){
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632