akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    if(a == 1) a+=13;
    if(b == 1) b+=13;
    if(a == b){
        cout << "Draw" << endl;
        return 0;
    }
    if(a > b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N =int(input())
x=input().split(" ")
flag=1
count =0
while flag==1:
    for i,k in enumerate(x):
        a =int(k)
        if a%2==0:
            x[i]=a/2
        else:
            flag=0
    if flag ==1:
        count +=1
print(count)


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

int main(){
	ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll n;
	cin>>n;
	cout<<a[n-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    char x, y;
    cin >> x >> y;
    if (x < y) {
        println("<");
    }
    else if (x == y) {
        println("=");
    }
    else {
        println(">");
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

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

    int d = 0;
    if (c - (a - b) > 0)
        d = c - (a - b);

    cout << d << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())

shima = []
ans = "IMPOSSIBLE"

for i in range(M):
  a,b = map(int ,input().split())
  if a == 1: shima.append(b-1)
  if b == N: shima.append(a-1)
    
shima.sort()
for s,t in zip(shima[:-1],shima[1:]):
  if s == t:
    ans = "POSSIBLE"
    break
 
print(ans)

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

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

using namespace std;

struct edge
{
  int to;
};

int main()
{
  int n;
  cin >> n;
  vector<edge> graph[10001];

  REP(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    edge e1 = {b};
    edge e2 = {a};
    graph[a].push_back(e1);
    graph[b].push_back(e2);
  }

  priority_queue<ll> q;
  REP(i, n)
  {
    int c;
    cin >> c;
    q.push(c);
  }

  ll result[10001] = {};
  ll ans = 0;
  queue<int> mati;
  mati.push(1);
  while (!mati.empty())
  {
    int i = mati.front();
    result[i] = q.top();
    mati.pop();
    q.pop();
    for (int j = 0; j < graph[i].size(); j++)
    {
      int to = graph[i][j].to;
      if (result[to] != 0)
      {
        ans += min(result[i], result[to]);
      }
      else
      {
        mati.push(to);
      }
    }
  }

  cout << ans << endl;
  FOR(i, 1, n)
  {
    cout << result[i] << " ";
  }
  cout << result[n] << endl;
}


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

int main()
{
    int a,b,c,d,ans = 0;
    cin >> a >> b >> c >> d;

    for(int i = 0; i <= 100; i++)
        if(a <= i && b > i && c <= i && d > i) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// cf. https://www.geeksforgeeks.org/queries-number-distinct-elements-subarray/
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500001; 
  
struct Query 
{ 
    int l, r, idx; 
}; 
  
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  

    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 

        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 

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

int main() 
{ 
    int n;
    int q;
    cin >> n >> q;
    int a[MAX];
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    Query queries[q];
    for (size_t i = 0; i < q; i++)
    {
        int l;
        int r;
        cin >> l >> r;
        queries[i].l = l - 1;
        queries[i].r = r - 1;
        queries[i].idx = i;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 17432
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> P;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

    long long res = min(accumulate(A.begin(), A.end(), 0LL), 
    accumulate(B.begin(), B.end(), 0LL));

    vector<P> C;
    for(int i=0; i<N; ++i) {
        C.push_back(P(A[i], i));
        C.push_back(P(B[i], i));
    }
    sort(C.begin(), C.end());
    long long sum = 0;
    for(int i=0; i<N; ++i) sum += C[i].first;
    
    bool flag = false;
    for(int i=0; i<N; ++i) {
        int d1 = distance(C.begin(), lower_bound(C.begin(), C.end(), P(A[i], -1)));
        int d2 = distance(C.begin(), lower_bound(C.begin(), C.end(), P(B[i], -1)));
        if(d1 < N && d2 < N) {
            flag = true;
            break;
        }
    }

    if(flag) {
        res = min(res, sum);
    } else {
        for(int w=0; w<N; ++w) {
            long long tmp = sum;
            if(A[w] <= B[w]) {
                tmp -= A[w];
                if(C[N] != P(B[w], w)) tmp += C[N].first;
                else tmp += C[N + 1].first;
            } else {
                tmp -= B[w];
                if(C[N] != P(A[w], w)) tmp += C[N].first;
                else tmp += C[N + 1].first;
            }
            res = min(res, tmp);
        }
    }

    cout << res << endl;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

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

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
struct node{
	int id,val;
	bool ty;//0->A,1->B
}a[MAXN];
bool cmp(node a,node b){return a.val<b.val;}
int n,cnt[4],ty[MAXN],sum[MAXN];
ll pre[MAXN];
int main() {
	n=read();
	for(int i=1,t=0;i<=n;++i){
		a[++t].id=i,a[t].val=read(),a[t].ty=0;
		a[++t].id=i,a[t].val=read(),a[t].ty=1;
	}
	sort(a+1,a+n*2+1,cmp);
	for(int i=1;i<=n*2;++i)pre[i]=pre[i-1]+a[i].val;
	for(int i=1;i<=n;++i){
		if(!a[i].ty)ty[a[i].id]|=1;
		else ty[a[i].id]|=2;
		sum[a[i].id]+=a[i].val;
	}
	for(int i=1;i<=n;++i)cnt[ty[i]]++;
	assert(cnt[3]==cnt[0]);
	if(cnt[0]||!cnt[1]||!cnt[2]){
		ll ans=0;
		for(int i=1;i<=n;++i)ans+=a[i].val;
		cout<<ans<<endl;
		return 0;
	}
	ll ans=1e18,s1=0,s2=0;
	for(int i=1;i<=n*2;++i)if(!a[i].ty)s1+=a[i].val;else s2+=a[i].val;
	ans=min(s1,s2);
	for(int i=n+1;i<=n*2;++i){
		if(!a[i].ty)ty[a[i].id]|=1;
		else ty[a[i].id]|=2;
		if(ty[a[i].id]==3){
			ll tmp=a[i].val;
			if(sum[a[i].id]){
				if(a[n].id!=a[i].id)tmp+=pre[n-1];
				else tmp+=pre[n]-a[n-1].val;
			}else{
				tmp+=pre[n-2];
			}
			ans=min(ans,tmp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; string S;
  cin >> N >> S;
  if(N%2) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=0, j=N/2; i<N/2; ++i, ++j) {
    if(S[i] != S[j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    for (auto &c : s) {
        c += n;
        if (c > 'Z') c -= 26;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int R,G,B;
  cin>>R>>G>>B;
  int X = 100*R + 10*G + B;
  if(X%4 == 0)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
<?php
list($n, $m) = ints();
$uf = new UnionFind($n);
for ($i = 0; $i < $m; ++$i) {
    list($a, $b) = ints();
    --$a;
    --$b;
    $uf->unite($a, $b);
}
$max = 0;
for ($i = 0; $i < $n; ++$i) {
    $max = max($max, $uf->size($i));
}
echo $max;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// Union-Find：同じグループに属するかどうかを判定する
class UnionFind
{
    private $par; // par[$i]:$iの親 自分が根の場合は自身のindexとなる
    private $size;

    function __construct($n)
    {
        for ($i = 0; $i < $n; $i++) {
            $this->par[$i] = $i; // 最初は全てが根
            $this->size[$i] = 1;
        }
    }

    function root($x)
    { // 根を返す
        if ($this->par[$x] === $x) return $x; // 根の場合
        return $this->par[$x] = $this->root($this->par[$x]); // 全ての枝の親を根にしながら再帰処理
    }

    function unite($x, $y)
    { // $xと$yの木を併合
        $ix = $this->root($x);
        $iy = $this->root($y);
        if ($ix === $iy) return;
        if ($this->size[$ix] < $this->size[$iy]) list($ix, $iy) = [$iy, $ix];
        $this->size[$ix] += $this->size[$iy];
        $this->par[$iy] = $ix; // $yの根を$xの根に付ける
    }

    function isSame($x, $y)
    { // $xと$yの根が同じか
        return $this->root($x) === $this->root($y);
    }

    function size($x)
    { // xが属するグループのサイズ
        return $this->size[$this->root($x)];
    }

    function count()
    { // グループの数
        $cnt = 0;
        foreach ($this->par as $i => $r)
            if ($i === $r) ++$cnt;
        return $cnt;
    }
}


Measured memory_bytes: 31164
/**
*    created: 27.06.2020 20:49:30
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {

    int a;
    cin >> a;
    int ans = a * a + a * a * a + a;
    cout << ans << endl;
}

Measured memory_bytes: 3616
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(input())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()
A=LI()

Aac=[A[0]]

for aidx in range(1,N):
	Aac.append(Aac[aidx-1]+A[aidx])
ans=10**18
for a in Aac[:-1]:
	ans=min(ans,abs((Aac[-1]-a)-a))
print(ans)

Measured memory_bytes: 109384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)
 
#define Left second
#define Right first
class SEGMENTS{
private:
    map<int,int> dat;
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
     
public:
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<=it->Left)break;
             
            int li = it->Left, ri = it->Right;
            dat.erase(it);
 
            if( !isInclude(li,ri,l,r) ){
                if( isInclude(l,r,li,ri) ){
                    if(li!=l) dat[l] = li;
                    if(r!=ri) dat[ri] = r;
                }else{
                    if(li<=l&&l<ri) ri = l;
                    if(l<=li&&li<r) li = r;
                    if(li!=ri) dat[ri] = li;
                }
            }
        }
    }
     
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<it->Left){
                if(dat.count(l)){
                    dat[r] = dat[l];
                    dat.erase(l);
                }
                else dat[r] = l;
                break;
            }
             
            if( isInclude(it->Left,it->Right,l,r) ) dat.erase(it);
            else{
                l = min(l,it->Left);
                r = max(r,it->Right);
            }
        }
    }
     
    int size(){ return dat.size(); }
     
    void output(){ for(auto e:dat)cout<<e.Left<<" "<<e.Right<<endl;cout<<endl; }
};
 
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
     
    SEGMENTS st;
     
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
     
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
         
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
         
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 4176
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,cnt=0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  cin >> n >> m;
  pri(abs((n-2)*(m-2)));
  return 0;
}

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

int main() {
	int a, b, c, d, e, f;
	vector<int>x, y;
	int ans,ans1;
	double maxv = 0;
	cin >> a >> b >> c >> d >> e >> f;
	for (int i = 0; i <=f; ++i) {
		for (int j = 0; j <= f; ++j) {
			if (i == 0 && j == 0)continue;
			if (100*(a * i + b * j) >f)break;
			x.push_back(100 * (a * i + b * j));
		}
	}
	for (int i = 0; i <= f; ++i) {
		for (int j = 0; j <= f; ++j) {
			if (c*i+d*j >f)break;
			y.push_back(c*i + d*j);
		}
	}
	for (int i = 0; i < x.size(); ++i) {
		for (int j = 0; j < y.size(); ++j) {
			if (x[i] + y[j] > f)continue;
			if ((double)y[j] / (double)x[i] > (double)e / (double)100)continue;
			if (maxv <= (double)100*(double)y[j]/((double)x[i] +(double) y[j])) {
				maxv =(double)100 * (double)y[j] / ((double)x[i] + (double)y[j]);
				ans1 = x[i] + y[j];
				ans = y[j];
			}
		}
	}
	cout << ans1 << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A<=0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3568
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
      int n;
      cin >> n;
      vector<vector<ll>> v(n,vector<ll> (3));
      for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
          cin >> v[i][j];
        }
      }
      for(int cx=0;cx<=100;cx++){
         for(int cy=0;cy<=100;cy++){
          set<ll> s;
          ll mxh = INT_MAX;
          bool ok = true;
           for(int i=0;i<n;i++){
              if(s.size()>1){ok=false;break;}
              if(v[i][2]==0){
                mxh = min(mxh,abs(cx-v[i][0])+abs(cy-v[i][1]));
              }
              if(v[i][2]!=0){
                s.insert(v[i][2]+abs(cx-v[i][0])+abs(cy-v[i][1]));
              }
           }
           if(s.size()>1)ok=false;
           if(ok){
             ll k = *s.begin();
             if(k <= mxh){
                cout << cx << ' ' << cy << ' ' << *s.begin();
                return;
             }
           }
         }
      }
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  
  for (int n=A;n<=B;n++){
    int arr[5];
    int n_temp = n;
    for (int i=0;i<5;i++){
      arr[i] = n_temp%10;
      n_temp /= 10;
    }
    if( (arr[0]==arr[4]) && (arr[1]==arr[3]) ){
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int R;  cin >> R;
  if(R < 1200)  cout << "ABC" << endl;
  else if(R < 2800)  cout << "ARC" << endl;
  else cout << "AGC" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	int n;
	scanf("%d",&n);
	int d=n%10;
	if(d==2 || d==4 || d==5 || d==7 || d==9){
		printf("hon\n");
	}else if(d==3){
		printf("bon\n");
	}else printf("pon\n");
}

Measured memory_bytes: 1660
#include<bits/stdc++.h> 
using namespace std;
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pii pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
# define ll long long int
#define m 1000000007
#define inf 1000000006
int main() 
{
	char mat[1001][1001];
	int h,w;
	//mat[0][0]=mat[0][1]=mat[1][0]='#';
	cin>>h>>w;
	int i,j,k;
	for(i=1;i<=h;i++)
		for(j=1;j<=w;j++)
		cin>>mat[i][j];
	ll dp[1001][1001];
	dp[1][1]=1;
	for(i=0;i<1001;i++)
		for(j=0;j<1001;j++)
			dp[i][j]=0;
		for(j=1;j<=w;j++)
			{
				if(mat[1][j]=='.')
				dp[1][j]=1;
				else
					break;
			}

		for(j=1;j<=h;j++)
		{
			if(mat[j][1]=='.')
				dp[j][1]=1;
				else
					break;
		}
		dp[1][1]=1;
		if(mat[2][1]=='.')
		dp[2][1]=1;
		if(mat[1][2]=='.')
			dp[1][2]=1;

		for(i=2;i<=h;i++)
			for(j=2;j<=w;j++)
			{
			
				if(mat[i][j]=='.')
				dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m)%m;

			}
cout<<dp[h][w]<<endl;
}

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

int main() {
    int n;
    int ans = -1;
    cin >> n;
    for(int i = 0; i  <= n; i ++){
        int tmp = i*1.08;
        if(tmp == n){
            ans = i;
            break;
        }
    }
    if(ans == -1) cout << ":(";
    else cout << ans;


    return 0;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
	  int[] nums = new int[n];
	  
	  for (int i = 0; i < n; i++) {
		  nums[i] = sc.nextInt();
	  }
	  
	  Arrays.sort(nums);
	  
	  double res = (nums[0]*1.0 + nums[1]*1.0) / 2;
	  
	  for (int i = 2; i < n; i++) {
		  res = (res + nums[i] * 1.0) / 2;
	  }
	  
	  System.out.println(res);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define SZ(x) ((int)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double pi=acos(-1);




int main() {
  int N;
  cin >> N;
  vector<int> bo(N);
  rep (i, N) {
  cin >> bo.at(i);
  }
  
  int ans = 1;
  int count = 0;
  for (int i=0; i<N+5;) {
    if(bo.at(i)==2) {
    cout << ans << endl;
    return 0;
    } 
    ans++;
    i=bo.at(i)-1;
    
    if (ans==N+4) {
    cout << "-1" << endl;
    return 0;
    }
  }
  
}


Measured memory_bytes: 640
#include <stdio.h>
  
int main()
{
  int i, sum;
  char x[1001];
  
  while (1) {
    scanf("%s", x);
    if (x[0] == '0' && x[1] == '\0') break;
    for (i = 0, sum = 0; x[i] != '\0'; i++) sum += x[i] - '0';
    printf("%d\n", sum);
  }
  
  return 0;
}


Measured memory_bytes: 2084
import java.util.Scanner;
  
public class Main {
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long max = -1000000;
        long min = 1000000;
        long sum = 0;
        for( int i = 0; i < n; i++ ){
            long a = sc.nextLong();
            if( max < a )
                max = a;
            if( a < min )
                min = a;
            sum += a;
        }
         
        System.out.println( min + " " + max + " " + sum);
 
        sc.close();
    }
}



Measured memory_bytes: 42852
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    ll N,K;
    cin >>N>>K;
    vector<ll> A(N);
    for (long long i = 0; i < N; i++) {
        cin >>A[i];
    }

    vector<bool> visit(N);
    vector<ll> v;
    ll cur=0;

    if(K<=N){
        for (long long i = 0; i < K; i++) {
            cur=A[cur]-1;
        }
        cout << cur+1 << endl;
        return 0;
    }

    while(1){
        if(visit[cur]==true){
            break;
        }
        v.push_back(cur);
        visit[cur]=true;
        cur=A[cur]-1;
    }

    auto it=find(all(v), cur);
    ll inter=distance(v.begin(), it);
    ll to_inter=inter;
    ll from_inter=v.size()-to_inter;

    K-=to_inter;
    ll r=(K)%from_inter;
    cout << v[to_inter+r]+1 << endl;

    return 0;
}


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

const int MAXN = 200010;
int fa1[MAXN] , fa2[MAXN];

int find(int* fa , int a){
	return fa[a] == a ? a : (fa[a] = find(fa , fa[a]));
}

int main(){
	int N , M , K , a , b;
	scanf("%d%d%d" , &N , &M , &K);
	for(int i = 1 ; i <= N ; i++)
		fa1[i] = fa2[i] = i;
	for(int i = 1 ; i <= M ; i++){
		scanf("%d%d" , &a , &b);
		fa1[find(fa1 , a)] = find(fa1 , b);
	}
	for(int i = 1 ; i <= K ; i++){
		scanf("%d%d" , &a , &b);
		fa2[find(fa2 , a)] = find(fa2 , b);
	}
	map < pair < int , int > , int > m;
	for(int i = 1 ; i <= N ; i++)
		m[make_pair(find(fa1 , i) , find(fa2 , i))]++;
	for(int i = 1 ; i <= N ; i++)
		cout << m.find(make_pair(find(fa1 , i) , find(fa2 , i)))->second << ' ';
	return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan

    int k,n; cin >> k >> n;

    vector< int > v(n);
    for(int i=0;i<n;i++) cin >> v[i];

    int min_distance = INT_MAX;

    for(int i=0;i<n;i++)
    {
        int start = v[i];
        int endmark;
        //clock
        if(i)
        {
            endmark=v[i-1];
            min_distance=min(min_distance,abs(start-k)+abs(0-endmark));
        }
        else
        {
            endmark=v[n-1];
            min_distance=min(min_distance,abs(start-endmark));
        }
        //anticlock
        if(i!=n-1)
        {
            endmark=v[i+1];
            min_distance=min(min_distance,abs(start-0)+abs(k-endmark));
        }
        else
        {
            endmark=v[0];
            min_distance=min(min_distance,abs(start-endmark));
        }
    }

    cout << min_distance << endl;
    return 0;
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    set<int> s;
    rep(i, n) {
        int e;
        cin>>e;
        s.insert(e);
    }

    int m;
    cin>>m;
    set<int> t;
    rep(i, m) {
        int e;
        cin>>e;
        t.insert(e);
    }

    set<int> res;
    set_intersection(s.begin(), s.end(), t.begin(), t.end(), inserter(res, res.end()));

    for (auto e : res) cout<<e<<endl;
}


Measured memory_bytes: 23780
#include <iostream>
using namespace std;
#define MAX 500000
#define INF 1000000001

int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i;
    for (i = 0 ; i < n1 ; i++) L[i] = A[left + i];
    for (i = 0 ; i < n2 ; i++) R[i] = A[mid  + i];
    L[n1] = INF;
    R[n2] = INF;
    i = 0;
    int j = 0;

    for (int k = left ; k < right ; k++) {
        cnt ++;
        if(L[i] <= R[j]) {
            A[k] = L[i];
            i ++;
        }else{
            A[k] = R[j];
            j ++;
        }
    }
}

void mergeSort(int A[], int left, int right) {
    int mid;
    if (left+1 < right) {
        mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(void) {
    int N;
    int A[MAX];
    int i;
    cnt = 0;

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

    mergeSort(A, 0, N);

    for (i = 0 ; i < N ; i++) { 
        if(i) cout << " ";
        cout << A[i];
    }
    cout << "\n";

    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
vb sieve(10000, true);
vi primes;
void sie()
{
    for (int i = 2; i * i <= 1000; i++)
    {
        if (sieve[i])
        {
            for (int j = i * i; j <= 1000; j += i)
                sieve[j] = false;
        }
    }
    for (int i = 2; i <= 1000; i++)
    {
        if (sieve[i])
            primes.pb(i);
    }
}
int power(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        b = b / 2;
        a = a * a;
    }
    return res;
}
signed main()
{
    sie();
    int n, ans = 1;
    cin >> n;
    for (auto it : primes)
    {
        int cnt = 0;
        for (int i = 1; i <= 10; i++)
        {
            cnt += (n / power(it, i));
        }
        ans = (ans * (cnt + 1)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define INFINITY 1000000
#define WHITE 0
#define BLACK 1
#define GRAY 2
void dijkstra();

int n;
float G[N][N];

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = INFINITY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int i,j,u,v,mincost;
  int d[N],color[N];

  for(i=0;i<n;i++){
    d[i] = INFINITY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    mincost = INFINITY;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INFINITY) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] != INFINITY){
	if( (d[u]+G[u][v]) < d[v]){
	  d[v] = d[u] + G[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i] != INFINITY)
    printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2088
N = int(input())
all_point_list = [input().split() for _ in range(N)]
for each_list in all_point_list:
    each_list[1] = int(each_list[1])
sorted_all_list = sorted(all_point_list, key=lambda x:(x[0], -x[1]))
for sorted_point in sorted_all_list:
    print(all_point_list.index(sorted_point) + 1)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

#define MaxValue 300000
int tree[MaxValue];

int read(int idx){
  int sum = 0;
  while (idx > 0){
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}

void update(int idx ,int val){
  while (idx < MaxValue){
    tree[idx] += val;
    idx += (idx & -idx);
  }
}

int get(long long v, vector<long long> &a) {
  int idx = lower_bound(begin(a), end(a), v) - begin(a) + 1;
  assert(a[idx-1] == v);
  return idx;
}

int main(void) {
  int n, k;
  scanf("%i %i", &n, &k);
  
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++) {
    scanf("%i", &a[i]);
  }
  
  vector<long long> ps(n+1);
  for (int i = 1; i <= n; i++) {
    ps[i] = ps[i-1] + a[i] - k;
  }
  
  vector<long long> sorted = ps;
  sort(begin(sorted), end(sorted));  
  
  update(get(0, sorted), 1);
  
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int pos = get(ps[i], sorted);
    ans += read(pos);
    update(pos, 1);
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <math.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++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a < b){
        if(a + v * t < b + w * t){
        cout << "NO" << endl;
    }
    else if(a + v * t >= b + w * t){
        cout << "YES" << endl;
    }
    }
    if(a > b){
        if(a - v * t > b - w * t){
        cout << "NO" << endl;
    }
    else if(a - v * t <= b - w * t){
        cout << "YES" << endl;
    }
    }

}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int ans = 0;
int n;
char win[10];
char mp[10][10];

void dfs(int a,int b){
	
	if(a == n-1 && b == n-1){
		ans++;
		return;
	}
	if(b == n){
		a++;
		b = 0;
	}
	
	if(a == b || mp[a][b] != '-'){
		dfs(a,b+1);
	}
	else{
		if(win[a] < (n-1) / 2){
			mp[a][b] = 'o';
			mp[b][a] = 'x';
			win[a]++;
			dfs(a,b+1);
			win[a]--;
			mp[a][b] = '-';
			mp[b][a] = '-';			
		}
		if(win[b] < (n-1) / 2){
			mp[a][b] = 'x';
			mp[b][a] = 'o';
			win[b]++;
			dfs(a,b+1);
			win[b]--;
			mp[a][b] = '-';
			mp[b][a] = '-';
		}
	}
}

void solve(){
	ans = 0;
	REP(i,10){
		win[i] = 0;
		REP(j,10){
			mp[i][j] = '-';
		}
	}
	int m;cin >> m;
	REP(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		mp[a][b] = 'o';
		mp[b][a] = 'x';
		win[a]++;
	}
	
	REP(i,n){
		if(win[i] > (n-1) / 2){
			cout << 0 << endl;
			return;
		}
	}
	
	dfs(0,0);
	
	cout << ans << endl;
}

int main(){
	
	while(cin >> n,n){
		solve();
	}
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<tuple<string, int, int>> a;//string:市,int:点数,int:番号となっている
  for (int i=1;i<=n;++i){
    string s;
    int p;
    cin >> s >> p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  
  sort(a.begin(),a.end());
  for (int i=0;i<n;++i){
    cout << get<2>(a[i]) << endl;
  }
}
//可読性考えたら、構造体にして自分でソート関数作るのがベター

Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        char[] c = new char[3];
        for(int i = 0; i < 3; i++) c[i] = s.charAt(i);
        Arrays.sort(c);
        System.out.println(c[0] == 'a' && c[1] == 'b' && c[2] == 'c' ? "Yes" : "No");
        scan.close();
    }

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


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

using namespace std;

typedef long ll;

int main(int, char**)
{
	ll n, k;
	double ans = 0;
	cin >> n >> k;

	double tmp = (double)1.0/(double)n;
	for (int i = 1; i <= n; i++) {
		double x = tmp;
		int now = i;
		while (k > now) {
			x *= (double)0.5;
			now *= 2;
		}

		ans += x;
	}

	cout << fixed << setprecision(12) <<  ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int[][] matrix = new int[3][3];
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        matrix[j][i] = sc.nextInt();
      }
    }
    int N;
    N = sc.nextInt();
    int[] keys = new int[N];
    for (int i = 0; i < N; i++) {
      keys[i] = sc.nextInt();
    }
    sc.close();

    int[][] checked = {{0,0,0},{0,0,0},{0,0,0}};

    for (int i = 0; i < N; i++) {
      for (int y = 0; y < 3; y++) {
        for (int x = 0; x < 3; x++) {
          if(matrix[y][x] == keys[i]) {
            checked[y][x] = 1;
          }
        }
      }
    }
    
    int three1 = 0;
    int three2 = 0;
    int three3 = 0;
    int three4 = 0;
    
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        three1 += checked[j][i];
      }
      if (three1 == 3) {
        System.out.println("Yes");
        return;
      }
      three1 = 0;
    }

    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        three2 += checked[i][j];
      }
      if (three2 == 3) {
        System.out.println("Yes");
        return;
      }
      three2 = 0;
    }

    for (int i = 0; i < 3; i++) {
      three3 += checked[i][i];
      three4 += checked[i][2-i];
    }

    if (three3 == 3 || three4 == 3) {
      System.out.println("Yes");
      return;
    } else {
      System.out.println("No");
      return;
    }
  }
}


Measured memory_bytes: 22612
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
using cd= complex < double > ;
//const ll mod = 998244353;
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const ll N = 3e5 +5;


int arr[N],brr[N];
vii va[N];
void solve(){
	int h,w,m;
	cin>>h>>w>>m;
	memset( arr,0,sizeof ( arr));
	memset( brr,0,sizeof ( brr));
	for ( int i=0;i<m;i++){
		int aa, bb;
		cin>>aa>>bb;
		va[aa].pb( bb);
		arr[aa]++;
		brr[bb]++;
	}	
	int ans=0;
	multiset< int > s;
	for ( int i=1;i<=w;i++){
		s.insert( brr[i]);
		ans=max( ans, brr[i]);
	}	
	for ( int i=1;i<=h;i++){
		ans=max( ans, arr[i]);
	}
	for ( int i=1;i<=h;i++){
		if ( va[i].sz()){
			int mx=0;
			for ( int j: va[i]){
				mx=max( brr[j],mx);
				s.erase( s.find(brr[j]));
			}
			if ( s.sz()!=0)	
				ans=max( ans,(int) (va[i].sz()+*s.rbegin()));
			ans=max( ans, int ( va[i].sz()+mx-1));
			for ( int j: va[i])
				s.insert( brr[j]);
		}
	}
	cout<<ans<<'\n';
}






int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){

    	solve();
    }
}


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

int main(){
	int k;
	string s;
	
	scanf("%d", &k);
	cin.ignore();
	getline(cin, s, '\n');
	int i =0;
	while(s[i] && i<=k){
		if(i==k){
			if(s[i]) printf("%s", "...") ;
		}else{
			printf("%c", s[i]) ;
		}
		i++;		
	}
	
	
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll a, b, n;
	cin >> a >> b >> n;
	n = min(n, b - 1);
	cout << a * n / b - a * (n / b);
}

Measured memory_bytes: 3652
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define MOD 1000000007

const long long INF = 10000000000000000;

using namespace std;

int exp(string s){
	int cnt=0;
	int val=1;
	while(val<s.size()){
		val*=2;
		cnt++;
	}
	return cnt;
}

int func(char target, string s){

	int cnt=0;
	int max_length=0;
	for(int i=0;i<s.size();i++){
		
		if(s[i]==target){
			cnt=0;
		}else{
			cnt++;
		}
		max_length=max(max_length,cnt);
	}
	//cout<<target<<" "<<"return "<<max_length<<endl; 
	return max_length;
}

int main(){
	string s;
	cin>>s;
	map<char,int> mp;
	for(int i=0;i<s.size();i++){
		mp[s[i]]++;
	}
	int max_num=0;
	char target;
	int ans=s.size();
	for(auto itr=mp.begin();itr!=mp.end();++itr){
		//cout<<itr->first<<" "<<itr->second<<endl;
		/*if(max_num<itr->second){
			ans=s.size();
		}
		if(max_num<=itr->second){
			ans=min(ans,func(itr->first,s));
			max_num=max(max_num,itr->second);
			target=itr->first;
		}*/
		ans=min(ans,func(itr->first,s));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
# C - Make a Rectangle
# https://atcoder.jp/contests/arc081/tasks/arc081_a

from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = sorted(list(Counter(A).items()), key=lambda x: -x[0])

ans = 0
for k, v in C:
  if v >= 4:
    if ans == 0:
      print(k ** 2)
    else:
      print(ans * k)
    exit()
  else:
    if v >= 2:
      if ans == 0:
        ans = k
      else:
        print(ans * k)
        exit()

print(0)

Measured memory_bytes: 21412
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<bitset>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
bitset<4001000> w;
int sum=0;
signed main(){
	n=read();
	w[0]=1;
	for(register int i=1;i<=n;i++){
		int x=read();
		w|=w<<x;
		sum+=x;
	}
	for(register int i=(sum+1)/2;i<=sum;i++){
		if(w[i]){
			printf("%lld\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664