akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int[] n = sc.nextIntArray(3);
		
		if(n[0] == n[1]) out.println(n[2]); else if(n[0] == n[2]) out.println(n[1]); else out.println(n[0]);
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

int main(){
  long long A,B,C;
  long long ans=1;
  cin >> A >> B;
  C = A>B ? A : B ;
  B = A>B ? B : A ;
  while(C%B!=0){
    A = C%B;
    C = B;
    B = A;
  }
  A = B;
  for(int i=2; i<=sqrt(B); i++){
    if(A%i==0){
      ans++;
      while(A%i==0) A /= i;
    }
  }
  if(A!=1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> amap;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (amap.count(a[i]) > 0) {
            amap[a[i]]++;
        } else {
            amap[a[i]] = 1;
        }
    }
    map<int, ll> ansmap;
    ll all_combinations = 0;
    for (auto& p : amap) {
        ll n = p.second;
        ansmap[n] = (n * (n - 1)) / 2;
        all_combinations += ansmap[n];
    }
    for (int k = 0; k < n; k++) {
        int banned = a[k];
        ll n = amap[banned];
        ll ans = all_combinations - ansmap[n];

        n--;
        ans += (n * (n - 1)) / 2;

        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int n;
int a[N],f[N];
int main()
{
  cin>>n;
  for(int i=1;i<=n;++i) cin>>a[i];
  memset(f,127,sizeof(f));
  f[1]=0;
  for(int i=1;i<n;++i) f[i+1]=min(f[i+1],f[i]+abs(a[i+1]-a[i])),
                       f[i+2]=min(f[i+2],f[i]+abs(a[i+2]-a[i]));
  cout<<f[n];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC153();
}

void ABC153(){
    int h,sum=0,x;
    cin>>h>>n;
    for(i=0;i<n;i++){
        cin>>x;
        sum+=x;
    }
    if(h>sum)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int N;
    static int K;
    static int[] A;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve() );
    }

    private static long solve() {
        Arrays.sort(A);

        Map<Integer, Integer> map = new HashMap<>(N);
        for (int i = 0; i < N; i++) {
            Integer count = map.get(A[i]);
            if( count != null ) {
                map.put(A[i], count+1);
            } else {
                map.put(A[i], 1);
            }
        }

        List<Map.Entry<Integer, Integer>> entries = new ArrayList<>(map.entrySet());
        Comparator<Map.Entry<Integer, Integer>> c = Comparator.comparingInt(Map.Entry::getValue);
        entries.sort(c);

        int rem_k = entries.size() - K;
        if( rem_k < 0 ) return 0;

        long ans = 0;
        for (int i = 0; i < rem_k; i++) {
            ans += entries.get(i).getValue();
        }
        return ans;
    }
}


Measured memory_bytes: 86240
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int buf = 0;
		int buff = 0;
		int buf2 = 0;
		int ans = 1000000;
		int X,i;
		for(i = 0;i < N;i++){
			X = sc.nextInt();
			buf += X;
			buff += X * X;
		}
		for(i = 1;i < 101;i++){
			buf2 = buff + i * ((N * i) - (2 * buf));
			if(ans > buf2){
				ans = buf2;
			}
		}
		System.out.println(ans);
	}	
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d%d%d', $a[], $a[], $a[]);

sort($a);

$cost = 0;
$total = 0;
foreach ($a as $value) {
    if ($cost == 0) {
        $total += 0;
    } else {
        $total += abs($value - $cost);
    }
    $cost = $value;
}

echo $total;

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

int check(string x, string y){
  map<char, bool> m;
  map<char, bool> m2;
  
  int ret = 0;
  for(int i = 0; i < x.size(); i++){
    m[x[i]] = true;
  }
  for(int i = 0; i < y.size(); i++){
    m2[y[i]] = true;
  }

  for(auto x: m2){
    if(m.count(x.first) != 0){
      ret++;
    }
  }
  return ret;
}

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  cerr << check("hoge", "huge") << endl;
  
  int tmpans = 0;
  for(int i = 0; i < N; i++){
    string x,y;
    x = S.substr(0, i);
    y = S.substr(i, N-i);
    // cerr << x << " " << y << endl;
    int tmp = check(x,y);
    if(tmp > tmpans){
      tmpans = tmp;
    }
  }
  cout << tmpans << endl;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  else return abs(__gcd(a,b));
}

int32_t main(){
  DESYNC;
  int n;
  cin >> n;
  map<int,int> even, odd;
  int e = 0, o =0;
  for(int i=0; i<n; i++){
    int x;
    cin >>x;
    if(i%2 == 0){
      e++;
      even[x]++;
    }
    else{
      o++;
      odd[x]++;
    }
  }
  set< ii > ev, od;
  for(auto it : even){
    ev.insert(ii(e - it.ss, it.ff));
  }
  for(auto it : odd){
    od.insert(ii(o - it.ss, it.ff));
  }
  if(ev.begin()->ss != od.begin()->ss){
    cout << ev.begin()->ff + od.begin()->ff <<endl;
  }
  else {
    if(ev.size() == 1){
      cout << od.begin()->ff + e << endl;
    }
    else if(od.size() == 1){
      cout << ev.begin()->ff + o << endl;
    }
    else {
      int ans1 = ev.begin()->ff;
      int ans2 = od.begin()->ff;
      ev.erase(ev.begin());
      od.erase(od.begin());
      ans1 += od.begin()->ff;
      ans2 += ev.begin()->ff;
      cout << min(ans1,ans2) << endl;
    }
  }
}



Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;
ll inf = 1e18;

class network_flow{
private:
	int N;
	struct edge{int to; ll cap; int rev;};
	vector<vector<edge>> G;
	vector<int> level,iter;
	void bfs(int s){
		for(int i=0;i<=N;i++) level[i] = -1;
		queue<int> Q;
		level[s] = 0;
		Q.push(s);
		while(!Q.empty()){
			int v = Q.front(); Q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e = G[v][i];
				if(e.cap > 0 && level[e.to]<0){
					level[e.to] = level[v]+1;
					Q.push(e.to);
				}
			}
		}
	}
	ll dfs(int v,int t,ll f){
		if(v==t) return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e = G[v][i];
			if(level[v]<level[e.to] && e.cap>0){
				ll d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	network_flow(int n){
		N = n;
		G = vector<vector<edge>>(N+1);
		level = iter = vector<int>(N+1);
	}
	void add_edge(int from, int to,ll cap){
		G[from].push_back((edge){to,cap,(int) G[to].size()});
		G[to].push_back((edge){from,0,(int) G[from].size()-1});
	}
	ll max_flow(int s,int t){
		ll flow = 0;
		for(;;){
			bfs(s);
			if(level[t]<0) return flow;
			for(int i=0;i<=N;i++) iter[i] = 0;
			ll f;
			while((f=dfs(s,t,inf))>0) flow += f;
		}
	}
};

int X,Y,E;

int main(){
	cin >> X >> Y >> E;
	network_flow flow(X+Y+2);
    int x,y;
    for(int i=1;i<=X;i++) flow.add_edge(0,i,1);
    for(int i=1;i<=Y;i++) flow.add_edge(X+i,X+Y+1,1);
    for(int i=0;i<E;i++){
		cin >> x >> y;
        x++; y++;
		flow.add_edge(x,X+y,1);
	}
	cout << flow.max_flow(0,X+Y+1) << endl;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B, C;
  cin >> A >> B >> C;

  cout << max(0LL, C - (A - B)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

int main2() {
  int H, W;
  cin >> H >> W;
  vector<string> vs;
  REP(i, H) {
    string s; cin >> s;
    vs.push_back(s);
  }
  bool possible = true;

  int s = 0;
  REP(i, H) REP(j, W) if (vs[i][j] == '#') s++;
  int step = 0;
  int h = 0, w = 0;
  for (;;) {
    step++;
    if (h == H - 1 && w == W - 1) break;
    bool right = w+1 < W && (vs[h][w+1] == '#');
    bool down = h+1 < H && (vs[h+1][w] == '#');
    if (right && down) {
      possible = false; break;
    }
    if (!right && !down) {
      possible = false; break;
    }
    if (right) w++;
    else if (down) h++;
  }
  if (step != s) possible = false;
  
  cout << (possible ? "Possible" : "Impossible") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int g[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

int main()
{
	int x,y;
	cin >> x >> y;
	if (g[x] == g[y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
V, E = [int(_) for _ in input().split()]
STD = [[int(_) for _ in input().split()] for _ in range(E)]
G = [[float('inf')] * V for _ in range(V)]
for s, t, d in STD:
    G[s][t] = d
ans = float('inf')
dp = [[float('inf')] * V for _ in range(2**V)]
#for start in range(V):
for start in range(1):
    dp[(2**V - 1)][start] = 0
    for S in range(2**V - 1 - 2**start, -1, -1):
        for v in range(V):
            for u in range(V):
                if not (S >> u & 1):
                    dp[S][v] = min(dp[S][v], dp[S | 1 << u][u] + G[v][u])
    ans = min(ans, dp[0][start])
if ans == float('inf'):
    print(-1)
else:
    print(ans)
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_A&lang=jp



Measured memory_bytes: 20688
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483647
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll N;
vector<ll> node,lazy;
ll IDEN=0;
 
ll op(ll x,ll y){
	return x+y;
}
 
void seg_init(vector<ll> v){
	int sz=v.size();
	N=1;while(N<sz)N*=2;
	node.resize(2*N-1,IDEN);
	lazy.resize(2*N-1, IDEN);
	rep(i,sz)node[i+N-1]=v[i];
	for(int i=N-2; i>=0; i--) node[i]=op(node[2*i+1],node[2*i+2]);
}

void eval(ll k, ll l, ll r) {
  if(lazy[k] != 0) {
      node[k] += lazy[k];
      if(r - l > 1) {
          lazy[2*k+1] += lazy[k] / 2;
          lazy[2*k+2] += lazy[k] / 2;
      }
      lazy[k] = 0;
  }
}

void update(ll a, ll b,ll val,ll k=0,ll l=0, ll r=-1){
	if(r < 0) r = N;
	eval(k, l, r);
	if(b<=l || r<=a) return;
	if(a<=l && r<=b){
		lazy[k]+=(r-l)*val;
		eval(k,l,r);
	}else{
		update(a,b,val,2*k+1,l,(l+r)/2);
		update(a,b,val,2*k+2,(l+r)/2,r);
		node[k]=op(node[2*k+1],node[2*k+2]);
	}
}

ll query(ll a,ll b, ll k=0, ll l=0, ll r=-1){
	if(r<0) r=N;
	eval(k,l,r);
	if(b <= l || r <= a) return IDEN;
  if(a <= l && r <= b) return node[k];
  ll vl = query(a, b, 2*k+1, l, (l+r)/2);
  ll vr = query(a, b, 2*k+2, (l+r)/2, r);
  return op(vl,vr);
}
int main(){
	ll n,q;cin>>n>>q;
	seg_init(vector<ll>(n,IDEN));
	bool flg;
	ll s,t,x;
	rep(i,q){
		cin>>flg>>s>>t;
	  if(flg){
	  	cout<<query(s-1,t)<<endl;
	  }else{
	  	cin>>x;
	  	update(s-1,t,x);
	  }
	}
}


Measured memory_bytes: 7592
import java.util.Scanner;

public class Main {
static int ans,N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.nextLine();
        String S[]=s.split("");
        s="";
        for(int i=0;i<S.length;i++) {
        	s+=10-Integer.parseInt(S[i]);
        }
System.out.println(s);
        }
    }

Measured memory_bytes: 24916
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int INF = numeric_limits<int>::max() / 2;

struct Edge {
	int src, dst;
	int weight;
	Edge(int src, int dst, int weight):
	src(src),dst(dst),weight(weight){}
};

auto operator < (const Edge &e, const Edge &f) {
	if (e.weight != f.weight) return e.weight > f.weight;
	else if (e.src != f.src) return e.src < f.src;
	else return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;

pair<int, int> sweep(int p, int v,const Graph &g) {
	pair<int, int> r(0, v);
	for (auto e : g[v]) {
		if (e.dst != p) {
			pair<int, int> t = sweep(v, e.dst, g);
			t.first += e.weight;
			if (r.first < t.first) r = t;
		}
	}
	return r;
}
int double_sweep(const Graph &g, int s) {
	pair<int, int> r = sweep(-1, s, g);
	pair<int, int> t = sweep(-1, r.second, g);
	return t.first;
}

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

	while (true) {
		int n; cin >> n;
		if (n == 0) break;
		int len = 0, cut = 0;
		vector<int> p(n), d(n);
		for (int i = 1; i < n; i++) {
			cin >> p[i];
			p[i]--;
		}
		for (int i = 1; i < n; i++) {
			cin >> d[i];
			len += d[i];
		}
		vector<int> v[1000];
		vector<bool> leaf(n, false);
		Graph g(n);
		for (int i = 1; i < n; i++) {
			int s = i, g = p[i];
			v[s].push_back(g);
			v[g].push_back(s);
		}
		for (int i = 0; i < n; i++) if (v[i].size() == 1)leaf[i] = true;
		for (int i = 1; i < n; i++) {
			if (leaf[i] || leaf[p[i]]) continue;
			else {
				Edge  e(i, p[i], d[i]),e2(p[i],i,d[i]);
				g[i].push_back(e);
				g[p[i]].push_back(e2);
				cut += d[i];
			}
		}

		int st;
		for (int i = 0; i < n; i++) if (!leaf[i]) st = i;
		int r = double_sweep(g, st);
		//??´???=r
		cout << len + cut * 2 - r << endl;
	}
}

Measured memory_bytes: 3260
#include <stdio.h>
int main(){
  int n, i, k, j, count;
  int point[200][3], sum[200];
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    for(k = 0; k < 3;k++){
      scanf("%d", &point[i][k]);
    }
  sum[i] = 0;
  }
  for(i = 0;i < n;i++){
    for(k = 0;k < 3;k++){
      count = 0;
      for(j = 0;j < n;j++){
        if(point[i][k] == point[j][k]){
          count += 1;
        }
      }
      if(count == 1){
        sum[i] += point[i][k];
      }
    }
  printf("%d\n", sum[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long int ll;
int main(void){
    ll x ;
    cin >> x ;
    ll n500 , n5 ;
    n500 = x / 500 ;
    x = x - 500 * n500 ;
    n5 = x / 5 ;

    ll ans ;
    ans = 1000 * n500 + 5 * n5 ;
    cout << ans << endl;
    
 
   
    return 0;
}

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

using namespace std;

const int SIZE = 10013;

vector<int> G[SIZE];
bool stackmember[SIZE];
int disc[SIZE], low[SIZE];

int find(vector<int> &C, int x){ return (C[x] == x) ? x : C[x] = find(C, C[x]); }
bool same(vector<int> &C, int x, int y){return find(C, x) == find(C, y);}
void merge(vector<int> &C, int x, int y){C[find(C,x)] = find(C,y);}

void dfs(int u, stack<int> *st, vector<int> &C){
  static int time = 0;
  disc[u] = low[u] = ++time;
  st->push(u);
  stackmember[u] = true;
  for(int i = 0; i < G[u].size(); i++){
    int v = G[u][i];
    if(disc[v] == -1){
      dfs(v, st, C);
      low[u] = min(low[u], low[v]);
    }
    else if(stackmember[v] == true) low[u] = min(low[u], disc[v]);
  }
  int w = 0;
  if(low[u] == disc[u]){
    while(st->top() != u){
      w = st->top();
      merge(C, u,w);
      stackmember[w] = false;
      st->pop();
    }
    w = st->top();
    merge(C, u,w);
    stackmember[w] = false;
    st->pop();
  }
}


void scc(vector<int> &C, int n){
  for(int i = 0; i < n; i++){
    C[i] = i;
    disc[i] = -1;
  }
  stack<int> st;
  for(int i = 0; i < n; i++){
      if(disc[i] == -1)
        dfs(i, &st, C);
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n, m;
  cin>>n>>m;
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      G[u].push_back(v);
  }
  vector<int> C(n);
  scc(C, n);
  int q;
  cin>>q;
  for(int i = 0; i < q; i++){
    int x,y;
    cin>>x>>y;
    cout<<same(C, x,y)<<"\n";
  }
}

Measured memory_bytes: 4464
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

const int MAXN = 105000;

int n, m;
set < pair<int, int> > st[MAXN];
string ans[MAXN];

string format(int x) {
  string result = "";
  for (int i = 0; i < 6; i++) {
    result.append(1, '0' + x % 10);
    x /= 10;
  }
  reverse(all(result));
  return result;
}

int main() { 

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; i++) {
    int p, y;
    scanf("%d %d", &p, &y);
    st[p - 1].insert(make_pair(y, i));
  }

  for (int i = 0; i < n; i++) {
    int cur = 0;
    for (auto p : st[i]) {
      int index = p.second;
      ans[index] = format(i + 1) + format(cur + 1);
      cur++;
    }
  }

  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    per(i,n-2){
        if(a[i] <= a[i+1])continue;
        if(a[i] -1 == a[i+1]){
            --a[i];
            continue;
        }
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    vector<vector<int>> is(26);
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i+n);
    }
    long long ans=0;
    int pos=0;
    for(int i=0;i<m;i++){
        int c=t[i]-'a';
        if(is[c].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        pos=*lower_bound(is[c].begin(),is[c].end(),pos)+1;
        if(pos>=n){
            pos-=n;
            ans+=n;
        }
    }
    ans+=pos;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1724
S = input()
if S == "RRR":
    print(3)
elif S[0:2] == "RR" or S[1:3] == "RR":
    print(2)
elif S[0] == "R" or S[1] == "R" or S[2] == "R":
    print(1)
else:
    print(0)

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vi vals(N);
    for (int i = 0; i < N; i++) {
        cin >> vals[i];
        if (vals[i] > i + 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    vi seq;

    while (vals.size()) {
        int rem = -1;
        for (int i = 0; i < vals.size(); i++) {
            if (vals[i] == i + 1)
                rem = i;
        }

        if (rem == -1) {
            cout << -1 << endl;
            return 0;
        }

        seq.push_back(vals[rem]);
        vals.erase(vals.begin() + rem);
    }

    reverse(all(seq));
    for (int v : seq)
        cout << v << " ";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
// 2018.09.05 2min

#include <iostream>
using namespace std;


int main() {

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(c-a)<=d) cout << "Yes" << endl;
    else if(abs(b-a)<=d && abs(c-b)<=d) cout << "Yes" << endl;
    else cout << "No";
}

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

void pushpush(int a){
    if(a==1) cout << "+";
    if(a==-1) cout << "-";
    return;
}

int main(){
    string S;
    cin >> S;
    auto A=S.at(0)-'0';
    auto B=S.at(1)-'0';
    auto C=S.at(2)-'0';
    auto D=S.at(3)-'0';
    int op1[2]={1,-1};
    int op2[2]={1,-1};
    int op3[2]={1,-1};
    int s,t,u;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                if(A+op1[i]*B+op2[j]*C+op3[k]*D == 7){
                    s=op1[i], t=op2[j], u=op3[k];
                }
            }
        }
    }
    cout << A; pushpush(s); 
    cout << B; pushpush(t);
    cout << C; pushpush(u);
    cout << D <<  "=7" <<endl ;  

}

Measured memory_bytes: 256
import bisect
n = int(input())
k = []
for _ in range(3):
    a = [int(i) for i in input().split()]
    a.sort()
    k.append(a)
count = 0
for i in k[1]:
    b = bisect.bisect_left(k[0],i)
    c = bisect.bisect_right(k[2],i)
    count += b*(n-c)
print(count)


Measured memory_bytes: 22592
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    x = int(input())
    val = 11 - x / 200
    if val == int(val):
        print(int(val) - 1)
    else:
        print(int(val))

if __name__ == "__main__":
    main()


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

int num[100003];
int num1[100003];
int num2[100003];

int main()
{
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&num[i]);
    sort(num,num+n);
    int ans=0;
    int maxm=num[n-1];
    int minm=num[0];
    for(int i=1;i<n-1;i++){
        if(num[i]<0){
            num1[i]=maxm;
            num2[i]=num[i];
            maxm-=num[i];
        }
        else{
            num1[i]=minm;
            num2[i]=num[i];
            minm-=num[i];
        }
    }
    cout<<maxm-minm<<endl;
    for(int i=1;i<n-1;i++){
        printf("%d %d\n",num1[i],num2[i]);
    }
    cout<<maxm<<" "<<minm<<endl;
    return 0;
}


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

int main() {
	int n, a, b;
	int d, t;
	cin >> n >> a >> b;

	d = a * n;
	t = b;
	if (d > t) {
		cout << t << '\n';
	}
	else {
		cout << d << '\n';

	}
	return 0;
}

Measured memory_bytes: 256
/**
 *
 * Contest - Problema X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

void precomp()
{
}

void solve(int R)
{
    cout << (R < 1200 ? "ABC" : (R < 2800 ? "ARC" : "AGC")) << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    int R;
    cin >> R;

    solve(R);

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  bool flag = true;
  for(int i = n - 1; i > 0; i--){
    if(h[i - 1] - 1 == h[i]) h[i - 1]--;
    else if(h[i - 1] - h[i] > 1) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;
    i64 sum = accumulate(all(a), 0l, bit_xor<>());
    for (auto& e : a) cout << (sum ^ e) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 4780
function Main(input) {
  input = input.split('\n');
  tmp = input[0].split(' ');
  heights = input[1].split(' ');
  numFriends = parseInt(tmp[0], 10);
  minHeight = parseInt(tmp[1], 10); 
  var count = 0;

//console.log('data heights: ' + heights);
//console.log('data numFriends: ' + numFriends);
//console.log('data minHeight: ' + minHeight);
  for(var i = 0; i < numFriends; i++) {
    if(parseInt(heights[i], 10) >= minHeight) {
      count++;
    }
  }
  console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


Measured memory_bytes: 16576
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i <= (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep (i, a) {
    rep (j, b) {
      rep (k, c) {
        if (i * 500 + j * 100 + k * 50 == x) ans++;
      }
    }
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
//69行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

//Simple Array Input
#define SAI int n;cin >> n;vi a(n);ain(a)
//Simple Graph Input
#define SGI(m) for(int i=0;i<m;i++){int a,b;cin >> a >> b;g[--a].pb(--b);g[b].pb(a);}
//Simple Tree Input
#define STI SGI(n-1)

typedef long long ll;
typedef long long integer;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){
    for(int i=0;i<a.size();i++)cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
}
///////////////////////////////////////////////////////////

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int a,b;cin >> a >> b;
    if(b >= a)cout << "un";
    cout << "safe" << '\n';
    return 0;
}
/*
 *!!CHECK!! 
 * 制約をよく読め：まず最も愚直な解法を考えろ
 * intの掛け算をしてる場合：overflowは大丈夫？
 * 制約の下限・上限は大丈夫？
 * 木構造は一直線にした時TLEしない？
 * */

/*
* DEBUG before you submit!
* 入力はされてる？
* vectorはサイズを初期化している？
* まずは変数が適切かをチェックする
* 特に二重ループ内部の変数が適切か？
* while文はカウンタがインクリメントされてるかチェック！
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N;
   cin>>N;
   vector<int> A(N-1);
  vector<int> B(N);
   for(int i=0;i<N-1;i++ ){
       cin>>A.at(i);
   }
    for(int i=0;i<N;i++ ){
      B.at(i)=0;
    }
   for(int i = 0 ;i<N-1;i++){
     int n;
     n=A.at(i);
       B.at(n-1)+=1;
   }
  for(int i=0; i<N;i++){
    cout<<B.at(i)<<endl;
  }
 



}

Measured memory_bytes: 4804
def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline
    input()
    a = Counter(map(int, input().split()))
    ans = sum(k * v for k, v in a.items())
    for _ in range(int(input())):
        b, c = map(int, input().split())
        if b in a:
            ans += (c - b) * a[b]
            print(ans)
            a[c] = a[c] + a[b] if c in a else a[b]
            del a[b]
        else:
            print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21920
use std::io::*;
use std::str::FromStr;

fn main(){
    let s: String = read::<String>();
    let k: u64 = read();
    let mut po: u64 = 0;
    for i in s.chars() {
        if i == '1' {
            po += 1;
            if po == k {
                println!("{}", 1);
                break;
            }
        } else {
            println!("{}", i);
            break;
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    string s; cin >> s;
    int n = s.size();
    vint ans(n, 0);
    vint map;
    int cnt = 1;
    char prev = 'R';
    repi(i, 1, n) {
        if(s[i] != prev) {
            map.push_back(cnt);
            cnt = 1;
            prev = s[i];
        } else cnt++;
    }
    map.push_back(cnt);
    for(auto itr = map.begin(); itr != map.end(); itr += 2) {
        int r = *itr, l = *(itr + 1);
        rep(i, r - 1) cout << 0 << " ";
        if(r % 2 == l % 2) {
            rep(i, 2) cout << (r + l) / 2 << " ";
        } else {
            int mid = (r + l) / 2;
            if(r > l && r % 2 == 0 || r < l && l % 2) {
                cout << mid << " " << mid + 1 << " ";
            } else {
                cout << mid + 1 << " " << mid << " ";
            } 
        }
        rep(i, l - 1) cout << 0 << " ";
    }

    return 0;
}


Measured memory_bytes: 1528
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if A[i] < 0:
    A[i] = abs(A[i])
    cnt += 1
if cnt %2 == 1:
  print(sum(A)-2*min(A))
else:
  print(sum(A))


Measured memory_bytes: 14224
function cnt(d,sz,W,K)
	if any(x->any(x->x>K,x),d)
		return 10^9
	end
	ret=sz-1
	x=zeros(Int,sz)
	for j=1:W
		x+=d[:,j]
		if any(x->x>K,x)
			ret+=1
			x=d[:,j]
		end
	end
	ret
end
function main()
	H,W,K=map(x->parse(Int,x),split(readline()))
	c=zeros(Int,H,W)
	for i=1:H
		j=0
		for d=chomp(readline())
			j+=1
			c[i,j]=Int(d)-48
		end
	end
	ans=10^9
	for z=0:2^H-1
		t=z
		sz=1
		for j=2:H
			sz+=t%2
			t>>=1
		end
		d=zeros(Int,sz,W)
		szi=1
		t=z
		for j=1:H
			d[szi,:]+=c[j,:]
			if t%2==1
				szi+=1
			end
			t>>=1
		end
		ans=min(ans,cnt(d,sz,W,K))
	end
	println(ans)
end
main()

Measured memory_bytes: 164792
#include <iostream>
#include <cmath>
#include <limits>
#include <vector>
#include <iomanip>
using namespace std;

float num;
vector<pair<double, double>> vec;
double sumOfDis;
double count = 0;


void recursive(vector<double> flag, double sum, double current){
  bool flagIsFull = true;
  for(double i=0; i<num; i++){
    if(flag[i] == 0){
      double copySum = sum;
      count++;
      double dis = sqrt(pow((vec[current].first - vec[i].first), 2)+pow((vec[current].second - vec[i].second), 2));
      copySum += dis;
      flag[i] = 1;
      recursive(flag, copySum, i);
      flag[i] = 0;
      flagIsFull = false;
    }
  }
  if(flagIsFull){
    sumOfDis += sum;
  }
}
 

int main() {
  sumOfDis = 0;
  cin >> num;
  for(double j=0; j<num; j++){
  	double a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a, b));
  }
  for(double j=0; j<num; j++){
    vector<double> flag(num, 0);
    flag[j] = 1;
    recursive(flag, 0, j);
  }
  double roots = num;
  for(double j=num-1; j>0; j--){
    roots *= j;
  }
  cout << std::fixed << std::setprecision(10) << (sumOfDis / roots) << endl;
  return 0;
}   



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
n=int(input())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    E[u].append((v,w))
    E[v].append((u,w))
color=[-1]*(n+1)

def dfs(i,j):
    color[i] = j
    for w,l in E[i]:
        if color[w] == -1:
            tj = j
            if l % 2 != 0:
                tj = int(not tj)
            dfs(w,tj)

dfs(1,0)
[print(color[i]) for i in range(1,n+1)]


Measured memory_bytes: 79408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N, M, D[202020], T[202020];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) { cin >> D[j]; }
    sort(D, D+N);
    cin >> M;
    for (int j = 0; j < M; ++j) { cin >> T[j]; }
    sort(T, T+M);

    bool ok = true;
    int di = 0, ti = 0;
    while (ti < M) {
        while (di < N && D[di] < T[ti]) {
            ++di;
        }
        if (di == N || D[di] != T[ti]) {
            ok = false;
            break;
        }
        ++di, ++ti;
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}
	


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 1005
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];
int n,k;

ll get(int s,int t)
{
	return A[t]-(s==0?0:A[s-1]);
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&A[i]);
		if(i>0) A[i]+=A[i-1];
	}
	ll now=0;
	for(int i=60;i>=0;i--)
	{
		now|=1LL<<i;
		int cnt=0;
		for(int j=0;j<n;j++)
		{
			for(int k=j;k<n;k++)
			{
				ll s=get(j,k);
				if((s&now)==now)
				{
					cnt++;
				}
			}
		}
		if(cnt<k) now-=1LL<<i;
	}
	printf("%lld\n",now);
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var arr [2][]int
	for i := 0; i < 2; i++ {
		arr[i] = make([]int, N)
		for j := 0; j < N; j++ {
			fmt.Scan(&arr[i][j])
		}
	}
	var max int
	for i := 0; i < N; i++ {
		var count int
		for j := 0; j <= i; j++ {
			count += arr[0][j]
		}
		for k := i; k < N; k++ {
			count += arr[1][k]
		}
		if count > max {
			max = count
		}
	}
	fmt.Println(max)
}


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

int n, tp=0, hp=0;
string t, h;

int main(void){
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        cin >> t >> h;
        if (t > h){
            tp += 3;
        }
        else if (t == h){
            tp++;
            hp++;
        }
        else {
            hp += 3;
        }
    }
    printf("%d %d\n", tp, hp);
    return 0;
}

Measured memory_bytes: 3236
import java.util.Arrays;
import java.util.Scanner;

//Nails
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[][] t = new int[n+1][];
		for(int i=0;i<=n;i++){
			t[i] = new int[i+2];
			Arrays.fill(t[i], -1);
		}
		while(m--!=0){
			int a = sc.nextInt(), b = sc.nextInt(), x = sc.nextInt();
			t[a][b] = Math.max(t[a][b], x);
		}
		int res = 0;
		for(int i=1;i<=n;i++)for(int j=1;j<=i;j++){
			t[i][j] = Math.max(t[i][j], Math.max(t[i-1][j]-1, t[i-1][j-1]-1));
			res+=t[i][j]>=0?1:0;
		}
		System.out.println(res);
	}

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

Measured memory_bytes: 0
loop{
  a,b,c=STDIN.gets.split
  a=a.to_i
  c=c.to_i
  
 puts(case b
  when '+' then
    a+c
  when '-' then
    a-c
  when '*' then
    a*c
  when '/' then
    a/c
  else
    break
  end)
}

Measured memory_bytes: 8612
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	// var N int
	// fmt.Scan(&N)
	N := sc.nextInt()
	// a := make([]int, N)
	a := sc.nextInts()

	// for i := 0; i < N; i++ {
	// 	fmt.Scan(&a[i])
	// }

	first := a[0]
	cnt := 1
	for i := 0; i < N; i++ {
		if a[i] < first {
			cnt++
			first = a[i]
		}

	}
	fmt.Println(cnt)
}

/* template functions */
var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
///a-b p
///b-c q
///a-c r
int main()
{
    int a[3];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

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

ll N, W;

signed main(){
  ll w1, v1, _w, _v;
  cin >> N >> W;
  
  cin >> w1 >> v1;
  
  vector<ll> v[4];
  
  v[0].pb(v1);

  REP(i, 1, N){
    cin >> _w >> _v;
    v[(_w - w1)].push_back(_v);
  }
  
  rep(i, 4){
    sort(ALL(v[i]));
    reverse(ALL(v[i]));
  }
  
  ll ans = 0;
  rep(i, v[0].size()+1){
    rep(j, v[1].size()+1){
      rep(k, v[2].size()+1){
	rep(l, v[3].size()+1){
	  _w = 0; _v = 0;
	  rep(ii, i){
	    _w += w1; _v += v[0][ii];
	  }
	  rep(ii, j){
	    _w += (w1+1); _v += v[1][ii];
	  }
	  rep(ii, k){
	    _w += (w1+2); _v += v[2][ii];
	  }
	  rep(ii, l){
	    _w += (w1+3); _v += v[3][ii];
	  }
	  if(_w <= W){
	    ans = max(ans, _v);
	  }
	}
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

int p;

template<typename T>
T power(T a, T b)
{
	T r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % p;
		a = (a * a) % p;
		b >>= 1;
	}
	return r;
}

int main()
{
	int n;
	char s[200001];
	scanf("%d%d%s", &n, &p, s);
	if (p == 2)
	{
		long long ans = 0;
		for (int i = 0; i < n; ++i)
		{
			int d = s[n - 1 - i] - '0';
			if (d % 2 == 0)
			{
				ans += n - i;
			}
		}
		printf("%lld\n", ans);
		return 0;
	}
	if (p == 5)
	{
		long long ans = 0;
		for (int i = 0; i < n; ++i)
		{
			int d = s[n - 1 - i] - '0';
			if (d % 5 == 0)
			{
				ans += n - i;
			}
		}
		printf("%lld\n", ans);
		return 0;
	}

	std::vector<int> pos[10000];
	for (int i = 0, cur = 0; i < n; ++i)
	{
		cur = (cur + ((s[n - 1 - i] - '0') * power(10, i) % p)) % p;
		pos[cur].push_back(i + 1);
	}
	long long ans = 0;
	for (int i = 0, cur = 0; i < n; ++i)
	{
		int search = cur;
		ans += pos[search].end() - std::upper_bound(pos[search].begin(), pos[search].end(), i);
		cur = (cur + ((s[n - 1 - i] - '0') * power(10, i) % p)) % p;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int n,a[105],i,j,sw;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(i=1;i<=n-1;i++)
	for(j=n;j>=i+1;j--)
	{
		if(a[j]<a[j-1])
		{
			swap(a[j],a[j-1]);
			sw++;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(i>1)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	return 0;
}


Measured memory_bytes: 3216