akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s = "codefestival2017";
    string t;
    cin >> t;
    if(t.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        puts("GREATER");
        return 0;
    } else if (a.size() < b.size()) {
        puts("LESS");
        return 0;
    } else {
        for (int i = 0; i < a.size(); i++) {
            if (a[i] > b[i]) {
                puts("GREATER");
                return 0;
            } else if (a[i] < b[i]) {
                puts("LESS");
                return 0;
            }
        }

    }

    puts("EQUAL");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n;
	cin>>n;
	int x=(int)ceil((double)n/1000);
	int val=x*1000-n;
	cout<<val;
	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 3752
sa=input()+"0"
la=len(sa)
na=0
sb=input()+"0"
lb=len(sb)
nb=0
sc=input()+"0"
lc=len(sc)
nc=0
x="a"
y="a"
ansdic={"a":"A","b":"B","c":"C"}
while(y!="0"):
  x=y
  if(x=="a"):
    for i in range(na,la):
      na+=1
      if(sa[na-1]!="a"):
        y=sa[na-1]
      break
  elif(x=="b"):
    for i in range(nb,lb):
      nb+=1
      if(sb[nb-1]!="b"):
        y=sb[nb-1]
      break
  else:
    for i in range(nc,lc):
      nc+=1
      if(sc[nc-1]!="c"):
        y=sc[nc-1]
      break
print(ansdic[x])

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main()
{
  int N;
  double x[N];
  char u[N];
  double sum;
  int i;
  
  scanf("%d",&N);
  for(i = 0; i < N; i++)
  {
    scanf("%lf %s",&x[i],u);
    if(strcmp(u,"JPY") == 0)
      sum = sum + x[i];
    else if(strcmp(u,"BTC") == 0)
      sum = sum + x[i] * 380000;
  }

  printf("%f\n",sum);
  
  return 0;
}
  

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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

//vector<vector<ll> > comb(ll n, ll b){
void comb(vector<vector <ll> > &v, ll n){
  cout << v.size();
  rep(i, n){
    v[i][0] = 1;
    v[i][i] = 1;
  }

  rep(j, n) {
    rep(k,j) {
      v[j][k] = (v[j-1][k-1] + v[j-1][k]);
    }
  }
}


int main(){
  string S,T;
  cin >> S >> T;

  int flag = 0;
  int cnt = 0;
  
    for (int i= S.size()-T.size(); i>=0; i--) {
      cnt = 0;
      rep(j, T.size()) {
      if (S[i+j]!=T[j] && S[i+j]!='?') break;
            cnt++;

    }
    if (cnt==T.size()){
      rep(j, T.size()) S[i+j] = T[j];
      flag = 1;
      break;
    }
  }

  if (flag == 0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  rep(i, S.size()){
    if (S[i]=='?') S[i]='a';
  }
  
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	int b;
	double p = 0;
	if (n >= k)
	{
		p = (double)(n - k + 1) / (double)n;
		b = k - 1;
	}
	else
	{
		b = n;
	}

	for (int i = 1; i <= b; i++)
	{
		int x = i, j;
		for (j = 0; k > x; j ++)
		{
			x *= 2;
		}
		double p0 = (1.0 / n) * pow(0.5, j);

		p += p0;
	}



	cout << fixed << setprecision(12) << p << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
const int N=2e5+10;
char str[N];
int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1),cnt=0;
	ll ans=0;
	for(int i=1;i<=n;i++)
	if(str[i]=='W') ans+=cnt;
	else cnt++;
	printf("%lld",ans);
	return 0;
}

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


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 SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF INT_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;}}

int atcoder(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if(e-a<=k) cout << "Yay!" << ENT;
    else cout << ":(" << ENT;
    return 0;
}


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


Measured memory_bytes: 256
import itertools
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
l=[i for i in range(1,N+1)]
a=list(itertools.permutations(l))
p=a.index(P)
q=a.index(Q)
print(abs(p-q))

    














    


    














Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    typedef long long ll;
    ll X, K, D;
    ll answer, kaisuu;
    cin >> X >> K >> D;
    X = abs(X);
    kaisuu = X / D;//往復する場合で、往復に入る直前までに動いた回数
    //if(X - D * K >= 0){//往復しない場合
    if(X/D >= K){
        answer = X - D * K;
    }else if ((K - kaisuu) % 2 == 0){//残された回数が偶数
        answer = X - D * kaisuu;
    }else{
        answer = abs(X - D * kaisuu - D);//残された回数が奇数
    }
    cout << answer << endl;
    return 0;
}


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

int search_position(vector<int> Idx, vector<int> Target, int n){
    int ans = -1 , cnt = 0;
    do{
        bool f = true;
        for(int i = 0; i < n; i++){
            if(Idx[i] == Target[i]);
            else{
                f = false;
                break;
            }
        }
        if(f){
            ans = cnt;
            break;
        }
        cnt++;
    }while(next_permutation(Idx.begin(), Idx.end()));
    return ans;
}

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

    int n;
    cin >> n;
    vector<int> A(n), P(n), Q(n);
    for(int i = 0; i < n; i++){
        cin >> P[i];
    }
    for(int i = 0; i < n; i++){
        cin >> Q[i];
    }

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

    cout << abs(search_position(A, P, n) - search_position(A, Q, n)) << endl;

    return 0;
}

Measured memory_bytes: 256
sub f{
	$v[$_]||f($v[$_]=1)for grep$$a{$_},keys%{$a=$_}
}
($N,$M)=glob<>;
${$`}{$'+0}=${$'+0}{$`}=/ / for@@=<>;
print~~grep{
	@v=(0,$_=/ /);
	f${$`}{$'+0}=${$'+0}{$`}=0;
	${$`}{$'+0}=${$'+0}{$`}=1;
	$N>grep$_,@v
}@@


Measured memory_bytes: 896
// practice with kaiboy, coached by rainboy
import java.io.*;
import java.util.*;

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

	static final int A = 4, MD = 1000000007;
	int n; int[][] tt; boolean[] eof;
	void build(byte[][] cc, int m) {
		int[] ii = new int[26];
		ii['A' - 'A'] = 0;
		ii['C' - 'A'] = 1;
		ii['G' - 'A'] = 2;
		ii['T' - 'A'] = 3;
		n = 2;
		for (int h = 0; h < m; h++)
			n += cc[h].length;
		tt = new int[n][A];
		eof = new boolean[n];
		n = 2;
		for (int h = 0; h < m; h++) {
			int l = cc[h].length;
			int i = 1;
			for (int k = 0; k < l; k++) {
				int a = ii[cc[h][k] - 'A'];
				if (tt[i][a] == 0)
					tt[i][a] = n++;
				i = tt[i][a];
			}
			eof[i] = true;
		}
		Arrays.fill(tt[0], 1);
		int[] ff = new int[n];
		int[] qu = new int[n]; int head = 0, cnt = 0;
		ff[1] = 0; qu[head + cnt++] = 1;
		while (cnt > 0) {
			int i = qu[head++]; cnt--;
			int e = ff[i];
			for (int a = 0; a < A; a++) {
				int j = tt[i][a];
				int f = tt[e][a];
				if (j == 0)
					tt[i][a] = f;
				else {
					ff[j] = f; qu[head + cnt++] = j;
				}
			}
		}
	}
	void main() {
		int l = sc.nextInt();
		byte[][] cc = new byte[6][];
		cc[0] = "AGC".getBytes();
		cc[1] = "ACG".getBytes();
		cc[2] = "GAC".getBytes();
		cc[3] = "AGGC".getBytes();
		cc[4] = "AGTC".getBytes();
		cc[5] = "ATGC".getBytes();
		build(cc, 6);
		int[] dp = new int[n]; dp[1] = 1;
		int[] dq = new int[n];
		while (l-- > 0) {
			Arrays.fill(dq, 0);
			for (int i = 1; i < n; i++) {
				int x = dp[i];
				if (x == 0 || eof[i])
					continue;
				for (int a = 0; a < A; a++) {
					int j = tt[i][a];
					dq[j] = (dq[j] + x) % MD;
				}
			}
			int[] tmp = dp; dp = dq; dq = tmp;
		}
		int ans = 0;
		for (int i = 1; i < n; i++)
			if (!eof[i])
				ans = (ans + dp[i]) % MD;
		println(ans);
	}
}


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

#define MAXN 200010
#define ll long long

using namespace std;

const int mod = 1e9+7;

int n, tot;

ll product = 1;

int head[MAXN], siz[MAXN];

ll f[MAXN];

struct edge {
	int to, next;
}e[MAXN * 2];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

ll qp(ll a, ll b) {
	ll res = 1, base = a;
	while (b) {
		if (b & 1) res = (res * base) % mod;
		base = (base * base) % mod;
		b >>= 1;
	}
	
	return res;
}

void dfs1(int x, int fa) {
	siz[x] = 1;
	for (int i = head[x]; i; i = e[i].next) {
		int v = e[i].to;
		if (v == fa) continue;
		dfs1(v, x);
		siz[x] += siz[v];
	}
	
	f[1] = (1ll * f[1] * siz[x]) % mod;
	return;
}

void dfs2(int x, int fa) {
	for (int i = head[x]; i; i = e[i].next) {
		int v = e[i].to;
		if (v == fa) continue;
		f[v] = (1ll * f[x] * (1ll * (n - siz[v]) * qp(siz[v], mod - 2) % mod)) % mod;
		dfs2(v, x);
	}
	
	return;
}

int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		add_edge(u, v); add_edge(v, u);
	}
	
	f[1] = 1;
	dfs1(1, 0);
	dfs2(1, 0);
	
	for (int i = 1; i <= n; i++) {product = (1ll * product * i) % mod;}
	for (int i = 1; i <= n; i++) {printf("%lld\n", (ll)(1ll * product * qp(f[i], mod - 2)) % mod);}
	return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int D,N;
int main(){
  cin >> D >> N;
  if(N%100==0)cout<< fixed << setprecision(0)<< pow(100,D)*(N+1) <<endl;
  else cout<< fixed << setprecision(0) << pow(100,D)*N <<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
int n,m;
int a[1005], b[1005], c[1005];
int d[1005], e[1005], f[1005];
int G[6005][6005];
int vis[6005][6005];
ll ans = 0;
int w[6005], h[6005];
int dx[]={1,0,-1,0}, dy[]={0,1,0,-1};
vector<int> _X, _Y;
unordered_map<int,int> _mX, _mY;
queue<ii> q;
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < n; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        _X.emplace_back(a[i]);
        _X.emplace_back(b[i]);
        _Y.emplace_back(c[i]);
    }
    for (int i = 0; i < m; i++){
        scanf("%d%d%d",&d[i],&e[i],&f[i]);
        _X.emplace_back(d[i]);
        _Y.emplace_back(e[i]);
        _Y.emplace_back(f[i]);
    }
    _X.emplace_back(0);
    _Y.emplace_back(0);
    sort(_X.begin(),_X.end());
    sort(_Y.begin(),_Y.end());
    _X.erase(unique(_X.begin(),_X.end()),_X.end());
    _Y.erase(unique(_Y.begin(),_Y.end()),_Y.end());
    //printf("X: "); for (auto x:  _X) printf("%d ",x); printf("\n");
    //printf("Y: "); for (auto x:  _Y) printf("%d ",x); printf("\n");
    for (int i = 0; i < _X.size(); i++) _mX[_X[i]] = i;
    for (int i = 0; i < _Y.size(); i++) _mY[_Y[i]] = i;
    for (int i = 0; i < _X.size()-1; i++){
        h[i*2+2] = _X[i+1] - _X[i];
        //printf("%d ",h[i*2+2]);
    }
    for (int i = 0; i < _Y.size()-1; i++){
        w[i*2+2] = _Y[i+1] - _Y[i];
        //printf("%d ",w[i*2+2]);
    }
    for (int i = 0; i < n; i++){
        a[i] = 2*_mX[a[i]]+1; b[i] = 2*_mX[b[i]]+1; c[i] = 2*_mY[c[i]]+1;
        //printf("abc %d %d %d\n",a[i],b[i],c[i]);
        for (int J = a[i]; J <= b[i]; J++){
            G[J][c[i]] = 1;
        }
    }
    for (int i = 0; i < m; i++){
        d[i] = 2*_mX[d[i]]+1; e[i] = 2*_mY[e[i]]+1; f[i] = 2*_mY[f[i]]+1;
        //printf("def %d %d %d\n",d[i],e[i],f[i]);
        for (int J = e[i]; J <= f[i]; J++){
            G[d[i]][J] = 1;
        }
    }
    /*for (int i = 0; i <= 2*n+1+m; i++){
        for (int j = 0; j <= 2*m+n+1; j++){
            printf("%d",G[i][j]);
        }
        printf("\n");
    }*/
    int sx = 2*_mX[0]+1;
    int sy = 2*_mY[0]+1;
    q.push({sx,sy});
    vis[sx][sy] = 1;
    while (q.size()){
        int x, y;
        tie(x,y) = q.front(); q.pop();
        for (int k = 0; k < 4; k++){
            int nx=  x+dx[k], ny = y +dy[k];
            if (G[nx][ny] == 0 && vis[nx][ny] == 0){
                vis[nx][ny] = 1;
                if (nx == 0 || ny == 0 || nx == 2*_X.size() || ny == 2*_Y.size()){
                    printf("INF");
                    return 0;
                }
                q.push({nx,ny});
                ans += (ll)h[nx]*w[ny];
            }
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 237124
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.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        DBrickBreak solver = new DBrickBreak();
        solver.solve(1, in, out);
        out.close();
    }

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

            int score = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] == score + 1)
                    score++;
            }

            int answer = score == 0 ? -1 : n - score;
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 46676
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void) {
	int k, x, i;
	cin >> k >> x;
	for (i = -1000000; i <= 1000000; i++) {
		if (i > x - k && i < x + k)
			printf("%d ", i);
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_121
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            long[][] abArray = new long[n][];
            for(int i = 0; i < n; i++)
            {
                abArray[i] = ReadLongs();
            }
            abArray=abArray.OrderBy(a => a[0]).ToArray();
            long res = 0;
            long now = m;
            for(int i = 0; i < n; i++)
            {
                if (abArray[i][1] >= now)
                {
                    res += now * abArray[i][0];
                    break;
                }
                else
                {
                    res += abArray[i][0] * abArray[i][1];
                    now -= abArray[i][1];
                }
            }
            WriteLine(res);
            //for (int i = 0; i < n; i++) WriteLine(abArray[i][0]);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27328
def cross(c1, c2):
    return c1.real * c2.imag - c1.imag * c2.real

def dot(c1, c2):
    return c1.real * c2.real + c1.imag * c2.imag

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    cross_ab = cross(a, b)
    if cross_ab > 0:
        return 1
    elif cross_ab < 0:
        return -1
    elif dot(a, b) < 0:
        return 1
    elif abs(a) < abs(b):
        return -1
    else:
        return 0

def intersect(p1, p2, p3, p4):
    # p1 and p2 are end points of a segment.
    # p3 and p4 are end points of the other segment.
    if (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and \
       (ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0):
        return True
    else:
        return False

def get_distance_sp(sp1, sp2, p):
    a = sp2 - sp1
    b = p - sp1
    if dot(a, b) < 0:
        return abs(b)
    c = sp1 - sp2
    d = p - sp2
    if dot(c, d) < 0:
        return abs(d)
    return abs(cross(a, b) / a)

def solve():
    from sys import stdin
    lines = stdin.readlines()
    
    while True:
        N = int(lines[0])
        if N == 0:
            break
        sx, sy, ex, ey = map(int, lines[1].split())
        sp = sx + sy * 1j
        ep = ex + ey * 1j
        R = []
        for l in lines[2:2+N]:
            D = []
            x1, y1, x2, y2, h = map(int, l.split())
            bp1 = x1 + y1 * 1j
            bp2 = x2 + y1 * 1j
            bp3 = x2 + y2 * 1j
            bp4 = x1 + y2 * 1j
            if intersect(sp, ep, bp1, bp2) or intersect(sp, ep, bp2, bp3) or \
            intersect(sp, ep, bp3, bp4) or intersect(sp, ep, bp4, bp1) or \
            (x1 <= sx <= x2 and y1 <= sy <= y2) or \
            (x1 <= ex <= x2 and y1 <= ey <= y2):
                print(0)
                break
            else:
                D.append(get_distance_sp(sp, ep, bp1))
                D.append(get_distance_sp(sp, ep, bp2))
                D.append(get_distance_sp(sp, ep, bp3))
                D.append(get_distance_sp(sp, ep, bp4))
                D.append(get_distance_sp(bp1, bp2, sp))
                D.append(get_distance_sp(bp1, bp2, ep))
                D.append(get_distance_sp(bp2, bp3, sp))
                D.append(get_distance_sp(bp2, bp3, ep))
                D.append(get_distance_sp(bp3, bp4, sp))
                D.append(get_distance_sp(bp3, bp4, ep))
                D.append(get_distance_sp(bp4, bp1, sp))
                D.append(get_distance_sp(bp4, bp1, ep))
                
                d = min(D)
                if h < d:
                    R.append((d ** 2 + h ** 2) / (2 * h))
                else:
                    R.append(d)
        else:
            print(min(R))
        lines = lines[2+N:]

solve()


Measured memory_bytes: 5960
s = input()

case = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i ==0:
                a = '+'
            else:
                a = '-'
            if j ==0:
                b = '+'
            else:
                b = '-'
            if k ==0:
                c = '+'
            else:
                c = '-'
            case.append('%s%s%s' % (a,b,c))

for case_i in case:
    print
    if 7 == eval('%s%s%s%s%s%s%s' % (s[0],case_i[0],s[1],case_i[1],s[2],case_i[2],s[3])):
        break

print('%s%s%s%s%s%s%s=7' % (s[0],case_i[0],s[1],case_i[1],s[2],case_i[2],s[3]))

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

int main() {
  int n; cin >>n;
  vector<int> s(n);
  for (int i=0; i<n; i++) cin >>s.at(i);
  
  int sum = 0;
  int notten = 100;
  int ans;
  for (int i=0; i<n; i++){
    sum += s.at(i);
    if (s.at(i)%10!=0 && s.at(i)<notten){
      notten = s.at(i);
    }
  }
  
  if (sum%10 == 0){
    if (notten == 100) ans = 0;
    else ans = sum - notten;
  }else ans = sum;
  
  cout <<ans <<endl;
  //if (ans) cout <<"YES" <<endl;
  //else cout <<"NO" <<endl;
}


Measured memory_bytes: 256
def m():
    n = int(input())
    a = list(map(int, input().split()))
    b = a.copy()

    for i in range(1, n):
        b[i] = b[i] + b[i-1]
    for j in range(n-2, -1, -1):
        a[j] = a[j] + a[j+1]

    ans = 999999999999
    for j in range(n-1):
        ans = min(ans, abs(b[j] - a[j+1]))
    return ans
print(m())

Measured memory_bytes: 24800
using System;
using System.Linq;

namespace AtCoder
{
    class B_CardGameforTwo_088
    {
        public static void Main()
        {
            var length = int.Parse(Console.ReadLine());
            var cards = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var PointAlice = 0;
            var PointBob = 0;
            InsertSort<int>(ref cards);
            for (var i = 0; i < length; ++i)
            {
                if (i % 2 == 0) { PointAlice += cards[i]; }
                else { PointBob += cards[i]; }
            }
            Console.WriteLine(PointAlice - PointBob);
        }

        private static void InsertSort<T>(ref T[] _array) where T : IComparable
        {
            for (var i = 1; i < _array.Length; ++i)
            {
                var target = _array[i];
                var k = i - 1;
                while (0 <= k && 0 < target.CompareTo(_array[k]))
                {
                    _array[k + 1] = _array[k];
                    --k;
                }

                _array[k + 1] = target;
            }
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;

int main()
{
  int N, l, L_i, L_j, L_k;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> l;
    L.at(i) = l;
  }
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N - 2; ++i)
  {
    L_i = L.at(i);
    for (int j = i + 1; j < N - 1; ++j)
    {
      L_j = L.at(j);
      for (int k = j + 1; k < N; ++k)
      {
        L_k = L.at(k);
        if (L_i >= L_j + L_k | L_j >= L_i + L_k | L_k >= L_j + L_i)
        {
          break;
        }
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n;
    cin >> n;
    ll ans=0;
    vector<ll> v(5,0);
    for(int i=0;i < n;i++)
    {
        string s;
        cin>> s;
        if(s.at(0)=='M'){
            v.at(0)++;
        }else if(s.at(0)=='A'){
            v.at(1)++;
        }else if(s.at(0)=='R'){
            v.at(2)++;
        }else if(s.at(0)=='C'){
            v.at(3)++;
        }else if(s.at(0)=='H'){
            v.at(4)++;
        }
    }

    for(int i=0;i < 3;i++)
    {
        for(int j=i+1;j < 4;j++)
        {
            for(int k=j+1;k < 5;k++)
            {
                ans += v.at(i)*v.at(j)*v.at(k);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long cnt=1000000007;
long long pow_ans(long long x, long long n) {
    x = x%cnt;
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res *= x; }
        res %= cnt;
        x *= x;
        x = x%cnt;
        n >>= 1;
    }
    return res;
}

int main() {
    long long m, n; cin >> m >> n;
    cout << pow_ans(m, n) << endl;
}
//g++ -o prob.exe prob.cpp


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
struct UnionFind {
    vector<int> par, siz;
    int cnt;
    UnionFind(int n) {
        par.resize(n);
        siz.resize(n, 1);
        cnt = n;
        for (int i = 0; i < n; i++)
            par[i] = i;
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v)
            return false;
        --cnt;
        if (siz[u] < siz[v])
            swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    }
    bool same(int u, int v) { return find(u) == find(v); }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    bool f = true;
    vector<ll> na = a, nb = b;
    sort(all(na));
    sort(all(nb));
    map<ll, int> mp, mp2;
    for (int i = 0; i < n; i++) {
        mp[nb[i]] = i;
        mp2[na[i]] = i;
        if (na[i] > nb[i]) {
            f = false;
        }
    }
    if (!f) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i < n; i++) {
        if (na[i] <= nb[i - 1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    UnionFind uf(n);
    for (int i = 0; i < n; i++) {
        uf.unite(mp2[a[i]], mp[b[i]]);
    }
    if (uf.cnt == 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 16640
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll X, Y;

  std::cin >> X>>Y;

  std::cout << X +Y/2 << '\n';


  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using pll = pair<long, long>;

vector<pll> bunkai(ll p) {
  vector<pll> res;
  for (ll i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      ll count = 0;
      while (p % i == 0) {
        count++;
        p /= i;
      }
      res.push_back(pll(i, count));
    }
  }
  if (p != 1) {
    res.push_back(pll(p, 1));
  }
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;
  auto v = bunkai(p);
  ll ans = 1;
  for (auto i : v) {
    if (i.second >= n) {
      ans *= pow(i.first, i.second / n);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
a,b,c,x,y = map(int, input().split())
k1 = a*x+b*y
k2 = 2*c*max(x,y)
if x < y:
  k3 = 2*c*min(x,y)+b*(y-x)
else:
  k3 = 2*c*min(x,y)+a*(x-y)

print(min(k1, k2, k3))

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 151200

long long quant_cont1(long long n){
  return n * n * n;
}
long long quant_cont2(long long n){
  return n * (n+1) * (n+2) / 6;
}

int main()
{
  set<long long> possible_quant;
  vector<long long> possible_container_1;
  vector<long long> possible_container_2;

  for(long long n = 1; quant_cont1(n) <= MAX; ++n){
    possible_container_1.push_back( quant_cont1(n) );
    possible_quant.insert( quant_cont1(n) );
  }

  for(long long n = 1; quant_cont2(n) <= MAX; ++n){
    possible_container_2.push_back( quant_cont2(n) );
    possible_quant.insert( quant_cont2(n) );
  }

  for(int i = 0; i < (int)possible_container_1.size(); ++i){
    for(int j = 0; j < (int)possible_container_2.size(); ++j){
      long long q = possible_container_1[i] + possible_container_2[j];
      if( q <= MAX ){
	possible_quant.insert( q );
      }
    }
  }
  
  long long request;
  while(cin >> request)
    {
      if( request == 0 ) break;
      set<long long>::iterator it = possible_quant.lower_bound( request );
      if( *it > request ) --it;
      cout << *it << endl;
    }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include <iterator>
using namespace std;



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

    int A[250];

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

    int anscnt=0;
    bool flag=true;
    while(true){

        for(int i=0; i<N; i++){
            if(A[i] % 2 != 0)
            {
                flag = false;
            }
            else{
                A[i] = A[i]/2;
            }
        }

        if(flag == true ){
            anscnt++;
        }
        else{break;}
    }
    cout << anscnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	if (sum >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}




Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    use std::f64::consts::PI;
    input!(R: f64);
    println!("{}", 2. * PI * R);
}


Measured memory_bytes: 2216
import itertools

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def gcd_3(a,b,c):
    a = gcd(gcd(a,b),c)
    return a

k = int(input())
ans = 0

num = list(itertools.combinations_with_replacement(range(1,k+1),3))

for l in num:
    a,b,c = l
    if a==b==c:
        ans += a
    elif a!=b!=c:
        ans += gcd_3(a,b,c)*6
    else:
        ans += gcd_3(a,b,c)*3
print(ans)

Measured memory_bytes: 105372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int>V(100000);
  for(int X=0;X<N;X++){
    int K;cin>>K;
    V[K]++;
    if(K!=99999){
      V[K+1]++;
    }
    if(K!=0){
      V[K-1]++;
    }
  }
  sort(V.begin(),V.end());
  cout<<V[99999]<<endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll K,A,B;
    cin>>K>>A>>B;
    if(A+2>=B || K<=A) cout<<1+K<<endl;
    else{
        K-=A+1;
        ll ans=B;
        ans+=(B-A)*(K/2);
        if(K%2) ans++;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a[3];
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] == '1') a[0] = '9';
  else a[0] = '1';
  if (a[1] == '1') a[1] = '9';
  else a[1] = '1';
  if (a[2] == '1') a[2] = '9';
  else a[2] = '1';
  cout << a[0] << a[1] << a[2] <<endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

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

    int a[1005];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--)
    {
        cout << a[i];
        if (i > 0)
            cout << " ";
        else
            cout << endl;
    }
}


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

int main() {
    int d, n;
    cin >> d >> n;
    int ans = n * pow(100, d);
    if (n == 100) ans += pow(100, d);
    cout << ans << endl;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1e9  //
#define LINF 1e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    Yes(n / 10 == 9 || n % 10 == 9);

    return 0;
}



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

int main()
{
    int A, B;
    cin >> A >> B;
    for (int i = 1; i <= 3; i++)
    {
        if (i == A || i == B)
            continue;
        else
        {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int commandCount = int.Parse(Console.ReadLine());
        HashSet<string> dic = new HashSet<string>();
        for(int i=0; i<commandCount; i++)
        {
            string[] inpt = Console.ReadLine().Split(' ');

            if(inpt[0].Equals("insert"))
            {
                dic.Add(inpt[1]);
            } else
            {
                // find
                string ans = "no";
                if(dic.Contains(inpt[1]))
                {
                    ans = "yes";
                }
                Console.WriteLine(ans);
            }
        }
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 39824
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int X,i;
  scanf("%d",&X);

  for(i=0;i<3;i++)
  {
    if(X%10 == 7)
    {
      printf("Yes\n");
      break;
    }
    else
    {
      X /= 10;
    }

    if(i==2)
    {
      printf("No\n");
    }
  }

  return 0;
}

Measured memory_bytes: 1656
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

const int MAX = 100000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 5 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;

const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(ll A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (A >= 100000) {
		if (A >= 1000000000) dig = 5;
		else if (A >= 100000000) dig = 4;
		else if (A >= 10000000) dig = 3;
		else if (A >= 1000000) dig = 2;
		memcpy(di + dig, f.C + A % 100000 * 5, 5);
		A /= 100000;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += 5 + dig;
	}
	else {
		if (A >= 10000) dig = 5;
		else if (A >= 1000) dig = 4;
		else if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += dig;
	}
	*di++ = ' ';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kei = 0;
	rep(i, N) {
		A[i] = getint();
		kei ^= A[i];
	}
	rep(i, N) putint(kei ^ A[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3404
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;
// 4 100
// 7 111
// 0 000
// 3 011

// 4 100
int main() {
    int N,i,j;
    long long nums[100001], K;
    cin>>N>>K;
    for(i=0;i<N;i++){
        cin>>nums[i];
    }
    int cnts[64];
    for(i=0;i<64;i++){
        for(j=0;j<N;j++){
            cnts[i]+=((nums[j]>>i)&1);
        }
    }
    long long ans=0, now=(1l<<62);
    for(i=62;i>=0;i--){
        if(cnts[i]*2<N && (ans+now)<=K){
            ans+=now;
        }
        now/=2;
    }
    long long ansCnt=0;
    for(i=0;i<N;i++){
        ansCnt+=(ans^nums[i]);
    }
    cout<<ansCnt;
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    for (i in 1..3000) {
        val inStr: String? = readLine()
        if (inStr === null) {
            return
        }
        val inStrList = inStr.split(' ')
        if (inStrList.size != 2) {
            return
        }
        val dataSets = inStrList.map { s -> s.toInt() }
        if (dataSets.any { n -> (n < 0) || (n > 10000) }) {
            return
        }
        if (dataSets.all { n -> n == 0 }) {
            return
        }
        val sortedDataSets = dataSets.sorted()
        val outString = sortedDataSets.joinToString(" ")
        println(outString)
    }
}



Measured memory_bytes: 35904
import java.util.Scanner;

public class Main {
	static int w,h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w=sc.nextInt();
			h=sc.nextInt();
			if(w==0&&h==0) break;
			int[][] map = new int[h][w];
			int[][] flag = new int[h][w];
			for(int j=0;j<h;++j){
				for(int i=0;i<w;++i){
					map[j][i]=sc.nextInt();
				}
			}
			int count=0;
			for(int j=0;j<h;++j){
				for(int i=0;i<w;++i){
					if(map[j][i]==1&&flag[j][i]==0){
						flag[j][i]=1;
						mapping(map,flag,i,j);
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void mapping(int[][]map,int[][]flag,int i,int j){
		if(i!=0){
			if(map[j][i-1]==1&&flag[j][i-1]==0){
				flag[j][i-1]=1;
				mapping(map,flag,i-1,j);
			}
		}
		if(j!=0){
			if(map[j-1][i]==1&&flag[j-1][i]==0){
				flag[j-1][i]=1;
				mapping(map,flag,i,j-1);
			}
		}
		if(i!=w-1){
			if(map[j][i+1]==1&&flag[j][i+1]==0){
				flag[j][i+1]=1;
				mapping(map,flag,i+1,j);
			}
		}
		if(j!=h-1){
			if(map[j+1][i]==1&&flag[j+1][i]==0){
				flag[j+1][i]=1;
				mapping(map,flag,i,j+1);
			}
		}
		if(i!=0&&j!=0){
			if(map[j-1][i-1]==1&&flag[j-1][i-1]==0){
				flag[j-1][i-1]=1;
				mapping(map,flag,i-1,j-1);
			}
		}
		if(i!=0&&j!=h-1){
			if(map[j+1][i-1]==1&&flag[j+1][i-1]==0){
				flag[j+1][i-1]=1;
				mapping(map,flag,i-1,j+1);
			}
		}
		if(i!=w-1&&j!=0){
			if(map[j-1][i+1]==1&&flag[j-1][i+1]==0){
				flag[j-1][i+1]=1;
				mapping(map,flag,i+1,j-1);
			}
		}
		if(i!=w-1&&j!=h-1){
			if(map[j+1][i+1]==1&&flag[j+1][i+1]==0){
				flag[j+1][i+1]=1;
				mapping(map,flag,i+1,j+1);
			}
		}
	}
}



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

int main() {
    cin >> s;

    int l, r;
    l = 0;
    r = s.size() - 1;

    int ans = 0;
    while (l < r) {
        if (s[l] == s[r]) {
            l++, r--;
        }
        else if (s[l] == 'x') {
            ans++;
            l++;
        }
        else if (s[r] == 'x') {
            ans++;
            r--;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int k; cin >> k;
    int a, b; cin >> a >> b;
    bool found = false;

    for (int i = a; i <= b; ++i) {
        if (i % k == 0) found = true;
    }

    puts((found) ? "OK" : "NG");
    return 0;
}

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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int a;
  cin>>a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<a-1;i++){
    if(vec.at(i)==vec.at(i+1)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/
int n,i,j,ans=0,x,dp[10][10];
void solve()
{  
   cin >> n;
   for(i=1;i<=n;i++)
   {
      x=i;
      while(x>=10)
      x=x/10;
      dp[x][i%10]++;
   }
   for(i=1;i<=9;i++)
   {
      for(j=1;j<=9;j++)
      ans+=dp[i][j]*dp[j][i];
   }
   cout << ans;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




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

using namespace std;

const int MAXN = 100005;

void readAndPreprocess(char s[], int &n, int diff[]) {
    scanf("%s", s);
    n = strlen(s);

    for(int i = 1; i <= n; ++i) {
        if (s[i-1] == 'A')
            diff[i] = diff[i-1] - 1;
        else
            diff[i] = diff[i-1] + 1;
    }
}

int n, m, q, diffS[MAXN], diffT[MAXN];
char s[MAXN], t[MAXN];

int getDiff(int diff[], int l, int r) {
    int res = diff[r] - diff[l-1];
    return (res%3 + 3)%3;
}

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

    readAndPreprocess(s, n, diffS);
    readAndPreprocess(t, m, diffT);

    scanf("%d", &q);
    for(int i = 0; i < q; ++i) {
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);

        bool canTransform = (getDiff(diffS, a, b) == getDiff(diffT, c, d));
        puts(canTransform ? "YES" : "NO");
    }

    return 0;
}

Measured memory_bytes: 1536
x1, y1, x2, y2 = map( int, input().split() )

x3 = x2 + y1 -y2
y3 = y2 - x1 + x2

x4 = x3 + x1 - x2
y4 = y3 + y1 - y2

print(x3, y3, x4, y4)

Measured memory_bytes: 2940