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

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

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

int main()
{
	int a[3][3];

	rep(i, 3) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}

	int n;
	cin >> n;

	vector<int> b(n);
	rep(i, n)
	{
		cin >> b[i];
	}

	bool v[3][3];

	rep(i, 3) {
		rep(j, 3) {
			v[i][j] = false;
		}
	}

	rep(i, 3) {
		rep(j, 3) {
			rep(k, n) {
				if (a[i][j] == b[k]) v[i][j] = true;
			}
		}
	}

	if ((v[0][0] && v[0][1] && v[0][2]) ||
		(v[1][0] && v[1][1] && v[1][2]) ||
		(v[2][0] && v[2][1] && v[2][2]) ||

		(v[0][0] && v[1][0] && v[2][0]) ||
		(v[0][1] && v[1][1] && v[2][1]) ||
		(v[0][2] && v[1][2] && v[2][2]) ||

		(v[0][0] && v[1][1] && v[2][2]) ||
		(v[0][2] && v[1][1] && v[2][0]))
	{
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	//rep(i, 3) {
	//	rep(j, 3) {
	//		cout << v[i][j] << " ";
	//	}
	//	cout << endl;
	//}

	return 0;
}



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

int main(){
	int n,w,ans[31],from,to;
	char com;
	cin>>w>>n;
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=0;i<n;i++){
		cin>>from>>com>>to;
		int tmp=ans[from];
		ans[from]=ans[to];
		ans[to]=tmp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}

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

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	bool sugar[3001]={0};
	for (int i=0; i<=3000; i++){
		for (int j=0; j<=3000; j++){
           if (c*i+d*j<=3000) {sugar[c*i+d*j] = true;}
	    }
	}
  int w = -1;
  int s = -1;
  double dense=0;
  for (int i=0; i<=31; i++){
    for (int j=0; j<=31; j++){
      int water = a*i*100+b*j*100;
      for (int k=0; k<=3000; k++){
        if (sugar[k]){ 
          //k/(water+k) < e/(100+e)------k*(100+e)<e*(water+k)
          if (k*(e+100) <= e*(water+k) and (water +k) <=f ){
            if (dense<=(double)k/(water+k)) {
              w = water;
              s = k;
              dense = (double)k/(water+k);
            }
          }
        }
      }
	}
  }
  cout << w + s << endl;
  cout << s << endl;
}


Measured memory_bytes: 3196
from collections import defaultdict,deque
N,M = map(int,input().split())
es = [[int(x) for x in input().split()] for _ in range(N+M-1)]
ins = defaultdict(int)
outs = defaultdict(list)
for v1,v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1
q = deque(v1 for v1 in range(N) if ins[v1]==0)
res = []
ans,c = [0 for i in range(N+1)],0
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2]==0:
            q.append(v2)
            ans[v2]=v1

for i in range(1,N+1):
    print(ans[i])


Measured memory_bytes: 103896
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Long> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            long value = sc.nextLong();
            if (set.contains(value)) {
                set.remove(value);
            } else {
                set.add(value);
            }
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 66876
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	
	if(a<=b && b<=c){
		printf("%d %d %d\n", a, b, c);
	}else if(a<=c && c<=b){
		printf("%d %d %d\n", a, c, b);
	}else if(b<=a && a<=c){
		printf("%d %d %d\n", b, a, c);
	}else if(b<=c && c<=a){
		printf("%d %d %d\n", b, c, a);
	}else if(c<=a && a<=b){
		printf("%d %d %d\n", c, a, b);
	}else if(c<=b && b<=a){
		printf("%d %d %d\n", c, b, a);
	}
}


Measured memory_bytes: 2052
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
edge = [[] for _ in range(n)]
ab = []
for _ in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
    ab.append((a,b))

def check(a,b):
    visited = [False for _ in range(n)]
    stack = [0]
    while len(stack)>0:
        e = stack.pop()
        visited[e] = True
        for v in edge[e]:
            if (e==a and v==b) or (e==b and v==a):
                continue
            if not visited[v]:
                stack.append(v)
    return all(visited)

res = 0
for a,b in ab:
    if not check(a,b):
        res += 1
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N,M,X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));
    for (int i=0; i<N; ++i){
        cin >> C[i];
        for (int j=0; j<M; ++j) cin >> A[i][j];
    }    
    ll res = 1e9;
    for (int bit=0; bit<(1<<N); ++bit){
        bool can = true;
        ll cost = 0;
        vector<int> B(M, 0);
        for (int i=0; i<N; ++i){
            if (bit & (1<<i)) {
                for (int j=0; j<M; ++j) B[j] += A[i][j];
                cost += C[i];
            }
        }
        for (int j=0; j<M; ++j) if (B[j]<X) can = false;
        if (can) res = min(res, cost);
    }
    if (res==(ll)1e9) {
        cout << "-1"<< endl;
    }else{
        cout << res << endl;    }
    
    return 0;
}

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

int main(void){
	int X, Y;
	cin >> X >> Y;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j < 100; j++) {
			int sum = i + j;
			int sum_l = 2*i + 4*j;
			if ((sum==X) && (sum_l==Y)){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = tmp = sum(p[:k])
for i in range(k,n):
    tmp += p[i]-p[i-k]
    ans = max(ans, tmp)
print('{:.12f}'.format(ans))


Measured memory_bytes: 23524
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;


//common
typedef int  i32;
typedef long long i64,ll;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );

		while(true){
			string r,a;cin >> r >>a;
			if(r=="0")break;
			int Sz=4;

			int h=0,b=0;
			REP(i,4){
				REP(j,4){
					if(a[i]==r[j]){
						if(i==j)h++;
						else b++;
					}
				}
			}
			cout << h<<" "<<b<<endl;
		}
	}
};
 int main(){
	ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/numeric>
/**
    PROGRESS IS PROGRESS
    NO MATTER HOW SMALL
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define MOD 1000000007


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

const int N = 3e3 + 5;
string s, t;
int n, m;
int dp[N][N];
int solve(int i = 0, int j = 0){
    if(i==n || j==m) return 0;

    int &ret = dp[i][j];
    if(~ret) return ret;

    if(s[i]==t[j])
       return ret = 1 + solve(i+1, j+1);

    int cnt = 0;
    cnt = max(solve(i+1, j), solve(i, j+1));

    return ret = cnt;
}

int cnt;
void print(int i = 0, int j = 0){
    if(i==n || j==m) return;

    int ans = solve(i, j);
    if(ans==solve(i+1, j)) print(i+1, j);
    else if(ans== solve(i, j+1))print(i, j+1);
    else{
        cout<<s[i];
        print(i+1, j+1);
        cnt++;
    }


}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout) ;
     cin>>s>>t;
     n = sz(s), m = sz(t);
     mem(dp, -1);
     solve(), print();
     if(!cnt)cout<<"";
	return 0;
}


Measured memory_bytes: 35840
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

set<int> sieve_eratosthenes(int n) {
	vector<bool> v(n+1, 1);
	set<int> p;
	int k = 2;
	while (k * k <= n) {
		if (v[k]) {
			for(int i=k*k; i<=n; i+=k) {
				v[i] = 0; 
			}
		}
		k++;
	}
	for(int i=2; i<=n; i++) {
		if (v[i]) p.insert(i);	
	}
	return p;
}

int main() {
	int n;
	cin >> n;
	vector<int> v(n); 
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	auto p = sieve_eratosthenes(1e6);
	map<int, int> mp;
	for(int i=0; i<n; i++) {
		int k = v[i];
		for(auto it = p.begin(); pow(*it,2) <= k and it != p.end(); it++) {
			int x = *it;
			if (k % x == 0) {
				while (k % x == 0) k /= x; 
				mp[x]++;
			}
		}
		if (k != 1) mp[k]++;
	}

	int ans = 0;
	for(auto it = p.begin(); it != p.end(); it++) {
		ans = max(mp[*it], ans);
//		if (mp[*it] > 0) cout << *it << " " << mp[*it] << endl; 
	}
	if (ans <= 1) cout << "pairwise coprime" << endl;
	else if (ans < n) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;

}


Measured memory_bytes: 14100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int A;
  string ans;

  cin >> A;

  int len = 0, sum = 0;
  while(sum < A) sum += ++len;

  for (int i=0; i<len-(sum-A); i++)
    ans += ')';

  ans += '(';

  for (int i=0; i<sum-A; i++)
    ans += ')';

  for (int i=0; i<len-1; i++)
    ans += '(';

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3324
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n;
vector<int> a, b;

int main(){
    cin >> n;
    a.resize(n);
    for(auto&& i : a){
        cin >> i;
    }
    for(int i = n; i > 0; i--){
        if(a[i - 1]){
            b.push_back(i);
            for(int j = 1; j * j <= i; j++){
                if(i % j) continue;
                a[j - 1] = !a[j - 1];
                if(j * j < i){
                    a[i / j - 1] = !a[i / j - 1];
                }
            }
        }
    }
    cout << b.size() << "\n";
    if(b.size()){
        cout << b[0];
        for(int i = 1; i < b.size(); i++){
            cout << " " << b[i];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 2424
#include <bits//stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n,m,x,y;
	int a[100],b[100];
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);
	for(int i=-100;i<=100;i++){
		if(x<i && i<=y && a[n-1]<i && i<=b[0]){
			cout<<"No War\n";
			return 0;
		}
	}
	cout<<"War\n";
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: u64 = sc.read();
    let b: u64 = sc.read();
    let x: Vec<u64> = sc.vec(n);

    let mut ans = 0;
    for i in 0..(n - 1) {
        let cur = x[i];
        let next = x[i + 1];
        let d = next - cur;
        if b > a * d {
            ans += a * d;
        } else {
            ans += b;
        }
    }

    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2792
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

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

string s ;
int cnt , ans ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> s ;

	for (int i = 0 ; i < _sz(s) ; i ++) {
		if (s[i] == 'B') cnt ++ ;
		else ans += cnt ;
	}

	cout << ans << '\n' ;
}

Measured memory_bytes: 720
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

multiset<pair<int, int>> sl;
multiset<pair<int, int>> sr;

ll solve(int x) {
	ll ans = 0;
	ll cur = 0;
	int fl = 0;
	for (int i = x; !sl.empty() && fl < 2; ++i) {
		pair<int, int> p;
		if (i % 2 == 0) {
			p = *sl.rbegin();
			if (p.first <= cur && p.second >= cur) {
				fl += 1;
				continue;
			}
			sl.erase(sl.find(p));
			sr.erase(sr.find(make_pair(p.second, p.first)));
		}
		else {
			p = *sr.begin();
			swap(p.first, p.second);
			if (p.first <= cur && p.second >= cur) {
				fl += 1;
				continue;
			}
			sl.erase(sl.find(p));
			sr.erase(sr.find(make_pair(p.second, p.first)));
		}
		fl = 0;
		if (cur < p.first) {
			ans += abs(p.first - cur);
			cur = p.first;
		}
		else {
			ans += abs(p.second - cur);
			cur = p.second;
		}
	}
	ans += abs(cur);
	return ans;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int l, r;
		cin >> l >> r;
		sl.insert(make_pair(l, r));
		sr.insert(make_pair(r, l));
	}
	auto tmpl = sl;
	auto tmpr = sr;
	ll ans = solve(0);
	sl = tmpl;
	sr = tmpr;
	ans = max(ans, solve(1));
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename V> class segtree{
private:
    int n,sz; vector<V> node, lazy;
public:
    segtree(vector<V>& v){
        sz = (int)v.size(); n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1); lazy.resize(2*n-1, 0);
        rep(i,sz) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1],node[i*2+2]);
    }
    void eval(int k, int l, int r){
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k]; lazy[2*k+2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    void range(int a, int b, V x, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] += x; eval(k, l, r);
        }else{
            range(a, b, x, 2*k+1, l, (l+r)/2); range(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }
    V query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return numeric_limits<V>::max();
        if(a <= l && r <= b) return node[k];
        V vl = query(a, b, 2*k+1, l, (l+r)/2), vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl,vr);
    }
    void print(){rep(i,sz)cout<<query(i,i+1)<< " ";cout<<endl;}
};


int main(){
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> v(n);
	set<int>st;
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			v[i]=1;
		}else{
			v[i] = -1;
			st.insert(i);
		}
	}
	for(int i=1;i<n;i++){
		v[i] += v[i-1];
	}
	segtree<int> sg(v);
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		a--;
		if(s[a]=='('){
			s[a] = ')';
			sg.range(a,n,-2);
			st.insert(a);
			int x = *st.begin();
			cout << x+1 << endl;
			s[x] = '(';
			sg.range(x,n,2);
			st.erase(st.begin());
		}else{
			s[a] = '(';
			st.erase(a);
			sg.range(a,n,2);
			int ok = n-1,ng =-1;
			while(abs(ok-ng)!=1){
				int mid = (ok+ng)/2;
				if(sg.query(mid,n)>=2){
					ok = mid;
				}else{
					ng = mid;
				}
			}
			sg.range(ok,n,-2);
			s[ok] = ')';
			st.insert(ok);
			cout << ok+1 << endl;
		}
	}





	return 0;
}


Measured memory_bytes: 19584
def solve
  n, m = gets.split.map!(&:to_i)
  arr = []
  flg = true
  (0..(m - 1)).each do |i|
    arr[i] = gets.split.map!(&:to_i)
  end

  (0..1001).each do |j|
    return - 1 if j == 1000
    next if j.to_s.length != n

    arr.each do |v|
      if j.to_s[v[0] - 1] != v[1].to_s
        flg = false
        break
      else
        flg = true
      end
    end

    return j if flg
  end
end
print solve


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

int cup[100],stat[100],sum[100],wat[200];
int N,SET;

int search(int cc,int left,int look){
	int i;

	if(look<N)stat[look]=1;

	if(left==0){
		if(cc<N)stat[cc]=2;
		for(i=N-1;i>=0;i--){if(stat[i]==0)break;}
		if(i<0)return 1;
		for(i=N-1;i>=0;i--){
			if(stat[i]==0)break;
			if(stat[i]==1 && search(i,cup[i],99))return 1;
		}
		if(look<N)stat[look]=0;
		stat[cc]=1;
		return 0;
	}

	int ccc=(look<N) ? look:cc;

	for(i=ccc-1;i>=0;i--){
		if(left<cup[i])continue;
		if(sum[i]<left)break;
		if(stat[i]==0 && search(cc,left-cup[i],i))return 1;
		if(i==cc-1 && stat[i]==0)break;
	}

	if(look<N)stat[look]=0;

	return 0;
}

int main(){
    int i,j,k;

    while(scanf("%d",&N)*N){
		SET++;

		for(i=0;i<=100;i++)wat[i]=0;
		for(i=0;i<N;i++){
			scanf("%d",&k);
			wat[k]++;
		}
		for(i=0,j=0,k=0;i<=100,j<N;i++){
			for(;wat[i]>0;wat[i]--){
				k+=i;
				cup[j]=i;
				stat[j]=0;
				sum[j]=k;
				j++;
			}
		}

		if(search(99,0,N-1))printf("YES\n"); else printf("NO\n");

    }
 
    return 0;
}

Measured memory_bytes: 584
/**So..a**/
#include<bits/stdc++.h>

using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>

#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(int i= a;i <=b; i++)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define NL_ "\n"

#define MAX 2000000000
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define mod(a) a%1000000007


int main()
{
    FAST;
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0; i< n; i++)
    {
        cin >> arr[i];
    }
    ll mn = LLONG_MAX;
    ll cnt= 0;
    for(int i = 0; i< n; i++)
    {
           mn = min(arr[i], mn);
           if(mn>=arr[i]) cnt++;
    }
     cout << cnt<<NL_;

    return 0;
}

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

int main() {
    int a[13] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    if(a[x-1] ==  a[y-1]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let h: usize = read(&mut stdin_lock, &mut buf, b' ');
    let w: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut cv = vec!['.'; h * w];
    for i in 0..h {
        let l: String = read(&mut stdin_lock, &mut buf, b'\n');
        let cs: Vec<char> = l.chars().collect();
        for j in 0..w {
            cv[i * w + j] = cs[j];
        }
    }

    let mut skip_y: Vec<usize> = Vec::new();
    for y in 0..h {
        let mut has_black = false;
        for x in 0..w {
            if cv[y * w + x] == '#' {
                has_black = true;
            }
        }
        if !has_black {
            skip_y.push(y);
        }
    }

    let mut skip_x: Vec<usize> = Vec::new();
    for x in 0..w {
        let mut has_black = false;
        for y in 0..h {
            if cv[y * w + x] == '#' {
                has_black = true;
            }
        }
        if !has_black {
            skip_x.push(x);
        }
    }

    for y in 0..h {
        if skip_y.contains(&y) {
            continue;
        }
        for x in 0..w {
            if skip_x.contains(&x) {
                continue;
            }
            print!("{}", cv[y * w + x]);
        }
        println!();
    }
}


Measured memory_bytes: 4352
from math import factorial
N, K = map(int, input().split())

# 逆元を利用した組み合わせの計算
#############################################################
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

mod = 10**9 + 7
NN = 2200

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, NN + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
#############################################################
"""
x_1 + x_2 + ... x_k = n
x_i >= 0
k個の箱にn個のボールを入れる重複組み合わせ　n+k-1_C_k-1
n個の玉とk-1個の仕切りを並べる

x_1 + x_2 + ... x_k = n
x_i >= 1
k個の箱にn個のボールを1個以上入れる重複組み合わせ　n-1_C_k-1
n個の玉の仕切りn-1個の中に、k-1箇所仕切りを入れる
"""

"""
まず赤だけ並べ、赤の間、左端、右端のN-K+1箇所から、i箇所を選ぶ -> N-K+1_C_i
選んだi箇所について、青を1個以上配置する -> 青の間K-1箇所からi-1箇所選ぶ -> K-1_C_i-1
"""

# i = 1,2,...,K
for i in range(1, K + 1):
    # まず赤だけ並べ、赤の間、左端、右端のN-K+1箇所から、i箇所を選ぶ
    c1 = cmb(N - K + 1, i, mod)
    # i箇所について、青を1個以上配置する、青の間K-1箇所からi-1個選ぶ
    c2 = cmb(K - 1, i - 1, mod)

    ans = (c1 * c2) % mod
    print(ans)


Measured memory_bytes: 69052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

struct Edge {
  int to, cost;
  Edge(int to_, int cost_) {
    to = to_; cost = cost_;
  }
};

struct State {
  int room, cost, bit;
  State(int room_, int cost_, int bit_) {
    room = room_; cost = cost_; bit = bit_;
  }
  bool operator<(const State& s) const {
    return cost < s.cost;
  }
  bool operator>(const State& s) const {
    return cost > s.cost;
  }
};

int N, M, L, K;
int S, G;
int ball_room[8];
vector<Edge> graph[51];

int dij()
{
  priority_queue<State, vector<State>, greater<State> > q;
  int used[51][1 << 8] = {{0}};
  int cnt = 0; //これがKになったらコストを返す

  Rep(i, L) {
    if( ball_room[i] == S ) {
      q.push( State(S, 0, 1 << i) );
      break;
    }
    if( i == L-1 ) q.push( State(S, 0, 0) );
  }

  while( !q.empty() ) {
    State p = q.top(); q.pop();
    int room = p.room, cost = p.cost, bit = p.bit;
    if( room == G && bit == (1 << L)-1 ) {
      cnt++;
      if( cnt == K ) return cost;
    }
  
    if( used[room][bit] >= K ) continue;
    used[room][bit]++;

    vector<Edge> e = graph[room];
    Rep(i, e.size()) {
      int next = e[i].to, next_bit = bit, next_cost = cost + e[i].cost;
      Rep(j, L) {
	if( ball_room[j] == next ) {
	  next_bit = (next_bit | (1 << j)); 
	  break;
	}
      }
      if( used[next][next_bit] >= K ) continue;
      q.push( State(next, next_cost, next_bit) );
    }
  }

  return -1;
}



int main()
{
  while( cin >> N >> M >> L >> K, N ) {
    Rep(i, 51) graph[i].clear();
    Rep(i, M) {
      int a, b, c;
      cin >> a >> b >> c;
      a--; b--;
      graph[a].pb( Edge(b, c) );
      graph[b].pb( Edge(a, c) );
    }
    
    cin >> S >> G;
    S--; G--;
    
    Rep(i, L) {
      cin >> ball_room[i];
      ball_room[i]--;
    }
    
    int ans = dij();
    if( ans == -1 ) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 40648
{-# LANGUAGE OverloadedStrings #-}

import Data.List
import Control.Applicative
import qualified Data.Text as T
import qualified Data.Text.IO as T

textToInt :: T.Text -> Int
textToInt t = (read . T.unpack) t :: Int

passHorizontalLine :: (Int, Int) -> Int -> Int
passHorizontalLine (p1, p2) n
    | p1 == n   = p2
    | p2 == n   = p1
    | otherwise = n

passHorizontalLines :: [(Int, Int)] -> Int -> Int
passHorizontalLines [] n = n
passHorizontalLines (p:ps) n = passHorizontalLines ps $ passHorizontalLine p n

passAmidakuji :: [(Int, Int)] -> [Int] -> [Int]
passAmidakuji hs ps = map snd $ sort $ zip [passHorizontalLines hs p | p <- ps] ps

main :: IO ()
main = do
    ps <- (\w -> [1 .. w]) . textToInt <$> T.getLine
    _ <- T.getLine
    hs <- map (\[a, b] -> (a, b)) . map (map textToInt) . map (T.splitOn ",") . T.lines <$> T.getContents
    putStr . unlines . map show $ passAmidakuji hs ps

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n>>m;
	vl A,B;
	rep(i,m){
		cin>>a>>b;
		a--;
		A.push_back(a);
		B.push_back(b);
	}

	rep(i,1000){
		vl X;
		t=i;
		if(t!=0){
		while(t>0){
			X.push_back(t%10);
			t=t/10;
		}
		reverse(all(X));
		}
		else{
			X.push_back(0);
		}

		if(X.size()==n){
			k=1;
			rep(j,m){
				if(n<=A[j]||X[A[j]]!=B[j])k=0;
			}

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

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

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

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

    ll lcm_cd = c * d / gcd(c, d);
    ll ans = 0;
    ans = b - (a - 1) - ((b / c + b / d - b / lcm_cd) - ((a - 1) / c + (a - 1) / d - (a - 1) / lcm_cd));
    cout << ans << endl;
}


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

using namespace std;

int main(){
    vector<string> v;
    int n, l;
    cin >> n >> l;
    for(int i = 0; i < n; ++i){
        string s; cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; ++i){
        cout << v[i];
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final char c = scanner.next().charAt(0);
        if(Character.isUpperCase(c)){
            System.out.println('A');
        }else{
            System.out.println('a');
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

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

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

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

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


Measured memory_bytes: 32728
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll count(9, 0);
  rep(i, N) {
    ll a;
    cin >> a;
    if (a <= 399) {
      count[0]++;
    } else if (a <= 799) {
      count[1]++;
    } else if (a <= 1199) {
      count[2]++;
    } else if (a <= 1599) {
      count[3]++;
    } else if (a <= 1999) {
      count[4]++;
    } else if (a <= 2399) {
      count[5]++;
    } else if (a <= 2799) {
      count[6]++;
    } else if (a <= 3199) {
      count[7]++;
    } else {
      count[8]++;
    }
  }

  ll ans_min = 0;
  ll ans_max = 0;
  rep(i, 8) {
    if (count[i] != 0) {
      ans_min++;
      ans_max++;
    }
  }
  ans_max = ans_min + count[8];
  if (ans_min == 0 && count[8] != 0) ans_min = 1;

  cout << ans_min << " " << ans_max << endl;
  return 0;
}

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

int main(void){

	double n, a, sum = 0.0;

	scanf("%lf", &n);


	for(int i = 0;i < n;i++){
		scanf("%lf", &a);
		a = 1 / a;
		sum += a;
	}

	printf("%lf\n", 1 / sum);

	return 0;
}


Measured memory_bytes: 128
import math

a,b,h,m = map(int,input().split())

d_h = (30 * h) + ((30 * m)/60)
d_m = (6 * m)

diff = abs(d_h - d_m)
'''if diff > 180 :
    diff -= 180'''

d2 = (a ** 2) + (b ** 2) - (2 * a * b * math.cos((diff/180) * math.pi))

d = (d2 ** 0.5)

print(d)

Measured memory_bytes: 9516
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int mt[10];
	for(int i=0;i<10;i++)
	 cin >> mt[i];
	sort(mt,mt+10,greater<int>());
	for(int i=0;i<3;i++)
		cout << mt[i] << endl;
}

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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> A(N); cin >> A;
    
    double ans = 0.0;

    rep(i, N) {
        ans += 1.0 / A[i];
    }
    ans = 1.0 / ans;

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		
		char x = b.charAt(0);
		
		if(x == 'A') {
			System.out.println("T");
		} else if(x == 'T') {
			System.out.println("A");
		} else if(x == 'G') {
			System.out.println("C");
		} else if(x == 'C') {
			System.out.println("G");
		}
		
	}
}


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

int main(){
    int A = 0, B = 0;
    for(long i = 0; i < 1000000000000000; i++)
      if(1 < 2) continue;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;

public class Main {
	public static int dividable (int n){
	    if (n%2 != 0) return 0;
	    else return 1 + dividable(n/2);
	}
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int n=0;n<N;n++) a[n]=sc.nextInt();
        
        int ans = 0;
        for(int n=0;n<N;n++) ans += dividable(a[n]);
        System.out.println(ans);
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> cards;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        cards.push_back(a);
    }
    sort(cards.begin(), cards.end());
    int cntAlice = 0;
    int cntBob = 0;
    int i = N - 1;
    while (i >= 0) {
        cntAlice += cards[i];
        i--;
        if (i >= 0){
            cntBob += cards[i];
            i--;
        }
    }
    cout << cntAlice - cntBob << endl;
}


Measured memory_bytes: 256
function main(input) {
   input = input.trim();
  const a = input.split(" ");

  console.log(a[0]=="Sunny"?"Cloudy"
			 :a[0]=="Cloudy"?"Rainy"
			 :"Sunny");
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29460
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    if(c == b) cout << a << endl;
    if(a == c) cout << b << endl;
    return 0;
}

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

typedef long long ll;

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

    vector<int> A;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            ans = max(ans, abs(A[i] - A[j]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int n,q;
	int c;
	int i,j;
	int low,high,key;
	int s[100001],t[50001];
	
	c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&t[i]);
	}
	for(i=0;i<q;i++){
		low=0;
		high=n-1;
		while(low<=high){
			key=(low+high)/2;
			if(s[key]<t[i]){
				low=key+1;
			}
			else if(s[key]>t[i]){
				high=key-1;
			}
			else {
				c++;
				break;
			}
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1612
import java.util.Scanner;

//AtCoder Beginner Contest 147
//B	Palindrome-philia
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		int ans = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) != S.charAt(S.length() - 1 - i)) {
				ans++;
			}
			if (i >= (S.length() / 2 - 1)) {
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
N=int(input())
d=list(map(int,input().split()))

e=[0 for i in range(100000)]

for i in range(N):
	e[d[i]-1]=e[d[i]-1]+1

k = 0
c = 0
for i in range(100000):
	k = k + e[i]
	if k==int(N/2):
		c = c+1

print(c)

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

ll n, a, max_x;
vector<ll> nums(50);
ll dp[55][55][2600];

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

    cin >> n >> a;
    rep(i, n) cin >> nums[i];
    array_fill(dp, 0);

    /*  dp[i][j][k] = nums[0:i]まででj枚を使ってkを作れる総数
        nums[i]を 使う or 使わないでそれぞれ考える
        - 使わないとき
            d[i+1][j][k] += dp[i][j][k]
        - 使うとき
            d[i+1][j+1][k+nums[i]] += dp[i][j][k]
    */

    // 0枚のカードから0枚を選んで0を作れる並びは1つ
    dp[0][0][0] = 1;

    rep(i, n + 1){
        rep(j, n + 1){
            rep(k, 2600){
                if(dp[i][j][k] == 0) continue;

                // 使わない
                dp[i+1][j][k] += dp[i][j][k];
                // 使う
                dp[i+1][j+1][k+nums[i]] += dp[i][j][k];
            }
        }
    }

    // 全てのカードから[i]枚を使ってi * aを作れる数を合計する
    ll ans = 0;
    repi(i, 1, n+1){
        ans += dp[n][i][i * a];
    }

    cout << ans << endl;
}


Measured memory_bytes: 61824
def change_dict_key(D, old_key, new_key, default_value=None):
  if new_key not in D:
    D[new_key] = D.pop(old_key, default_value)
  else:
    D[new_key] += D.pop(old_key, default_value)

n=int(input())
A=list(map(int,input().split()))+[100001]
q=int(input())
BC=[list(map(int,input().split())) for _ in range(q)]
ans,pre,count=sum(A)-A[n],A[0],0
D=dict()

A.sort()
for a in A:
  if pre != a:
    D[pre]=count
    count,pre=1,a
    continue
  count += 1

for b,c in BC:
  if b not in D:
    print(ans)
    continue
  num = D[b]
  change_dict_key(D,b,c)
  ans += num*(c-b)
  print(ans)  

Measured memory_bytes: 37228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)

	for i := range A {
		A[i] = nextInt()
	}
	P, i := partition(A, 0)
	for j := range A {
		if j == i {
			fmt.Printf("[%d] ", P[j])
		} else if j == n-1 {
			fmt.Println(A[j])
		} else {
			fmt.Printf("%d ", P[j])
		}
	}
}
func partition(A []int, p int) ([]int, int) {
	x := A[len(A)-1]
	i := p - 1
	for j := p; j < len(A)-1; j++ {
		if A[j] <= x {
			i++
			temp := A[i]
			A[i] = A[j]
			A[j] = temp
		}
	}
	temp2 := A[len(A)-1]
	A[len(A)-1] = A[i+1]
	A[i+1] = temp2
	return A, i + 1
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}



Measured memory_bytes: 3176
A,B,C,D,E,F = map(int,input().split())

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,31):
    for j in range(1,31):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(101):
    for j in range(101):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)

for c,w,s in ans:
    if w <= F:
        print(w,s)
        break


Measured memory_bytes: 3188
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: usize,
        v: [i64; n],
    }
    let mut ma = 0;
    for lft in 0..min(n, k) + 1 {
        for rgt in 0..min(n, k) + 1 - lft {
            let mut hand = vec![];
            for i in 0..lft {
                hand.push(v[i]);
            }
            for i in 0..rgt {
                hand.push(v[n - 1 - i]);
            }
            hand.sort();
            hand.reverse();
            let rem = k - lft - rgt;
            for _ in 0..rem {
                if let Some(x) = hand.pop() {
                    if x >= 0 {
                        hand.push(x);
                    }
                }
            }
            let sum: i64 = hand.iter().sum();
            ma = max(ma, sum);
        }
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572