akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
 using namespace std;

 int main(){
 int x[10000] ;
 for (int i=1; i<10001; i=i+1 )
 {
 cin >> x[i] ;
 }

 for (int i=1; i<10001; i=i+1 )
 {
 if( x[i] == 0 )
 {
 break;
}else{
 cout<< "Case "<< i << ": "<< x[i] << endl;
 }
}
 return 0;
 }


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Simple Knapsack

int dp[105][305];
int n,W;
int w[1000005],v[1000005];
int d,ans=0;
int main()
{
	int i,j,k;
	scanf("%d%d",&n,&W);
	for(i=1;i<=n;i++)scanf("%d%d",&w[i],&v[i]);
	for(i=0;i<=n;i++)for(j=0;j<=300;j++)dp[i][j]=0;
	for(i=1;i<=n;i++)
		for(j=n;j>0;j--)
			for(k=300;k>=0;k--)
			{
				d=w[i]-w[1];
				if(k<d)break;
				dp[j][k]=max(dp[j][k],dp[j-1][k-d]+v[i]);
			}
	for(i=0;i<=n;i++)for(j=0;j<=300;j++)
		if(1ll*i*w[1]+1ll*j<=1ll*W)ans=max(ans,dp[i][j]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main()	{
  	int n, l;
  	cin >> n >> l;
  	string dict[n];
  	for (int i = 0; i < n; i++)	{
      	cin >> dict[i];
    }
  	sort(dict, dict + n);
  	for (int i = 0; i < n; i++)
      	cout << dict[i];
  	cout << endl;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n;
int c[501], s[501], f[501];
int main()
{
	cin >> n;
	REP(i, 0, n - 1) cin >> c[i] >> s[i] >> f[i];

	REP(i, 0, n - 1) {
		int sum = s[i] + c[i];

		REP(j, i + 1, n - 1) {
			if (sum > s[j]) {
				int cnt = 0;
				while (sum > (s[j] + f[j] * cnt)) cnt++;
				sum = (s[j] + f[j] * cnt) + c[j];
			}
			else {
				sum = s[j] + c[j];
			}
		}
		cout << sum << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

void update(vector<vi> &cell, int h, int w) {
  REP(j, w) {
    for (int i = h - 1; i > 0; i--) {
      if (cell[i][j] != -1)
        continue;
      for (int di = -1; di + i >= 0; di--) {
        if (cell[i + di][j] == -1)
          continue;
        cell[i][j] = cell[i + di][j];
        cell[i + di][j] = -1;
        break;
      }
    }
  }
}

int calc(vector<vi> &c, int h, int w, int k) {
  int ret = 0;
  REP(i, h) {
    REP(j, w) {
      if (c[i][j] == -1)
        continue;
      for (int dj = 1; j + dj < w; dj++) {
        if (c[i][j] != c[i][j + dj]) {
          if (dj >= k) {
            ret += c[i][j] * dj;
            REP(ddj, dj) { c[i][j + ddj] = -1; }
          }
          j = j + dj - 1;
          break;
        }
        if (j + dj == w - 1) {
          if (dj + 1 >= k) {
            ret += c[i][j] * (dj + 1);
            REP(ddj, dj + 1) { c[i][j + ddj] = -1; }
            j = w - 1;
            break;
          }
        }
      }
    }
  }
  return ret;
}

void print(vector<vi> &c, int h, int w) {
  cout << endl;
  REP(i, h) {
    REP(j, w) { cout << c[i][j] << (j == w - 1 ? "\n" : " "); }
  }
  cout << endl;
}

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

  int h, w, k;
  cin >> h >> w >> k;
  vector<vi> cell(h, vi(w, 0));
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, w) { cell[i][j] = s[j] - '0'; }
  }

  int ans = 0;
  vector<vi> c(h, vi(w, 0));
  REP(i, h) {
    REP(j, w) {
      int tmp = 0;
      copy(ALL(cell), c.begin());
      c[i][j] = -1;
      for (int i = 0, changed = true; changed; i++) {
        changed = false;
        update(c, h, w);
        int ret = calc(c, h, w, k) * (1 << i);
        if (ret != 0)
          changed = true;
        tmp += ret;
      }
      chmax(ans, tmp);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n=0,p=0;
    int box=0;
    // int hand[51]={0};
    int winner[10000]={-1};
    int count=0;
    while(1){
        int  hand[51]={0};
        winner[count]=-1;
        
        scanf("%d %d",&n,&p);
        if(n==0&&p==0){
            break;
        }
        box=p;
        while(1){
            for(int i=0;i<n;i++){
                if(box>0){
                    box-=1;
                    hand[i]+=1;
                    if(hand[i]==p){
                       
                        winner[count]=i;
                        break;
                    }
                }
                else if(box==0){
                    box=hand[i];
                    hand[i]=0;
                }
            }
            if(winner[count]!=-1){
               
                break;
            }
       
        }
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",winner[i]);
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


ll H,W;
ll dx[4]={0,0,1,-1}, dy[4]={1,-1,0,0};
vector<string> S;

ll bfs(ll x, ll y){
  queue<pair<ll, ll>> q;
  vector<vector<ll>> Dist(H, vector<ll>(W, INF));
  q.push({x, y});
  Dist[x][y]=0;
  while(!q.empty()){
    pair<ll, ll> p=q.front();
    q.pop();
    for(int i=0; i<4; i++){
      ll nx=p.first+dx[i], ny=p.second+dy[i];
      if(0<=nx && nx<H && 0<=ny && ny<=W){
        if(S[nx][ny]=='.' && Dist[nx][ny]==INF){
          Dist[nx][ny]=Dist[p.first][p.second]+1;
          q.push({nx, ny});
        }
      }
    }
  }
  ll MAX=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(Dist[i][j]!=INF){
        MAX=max(MAX, Dist[i][j]);
      }
    }
  }
  return MAX;
}

int main(){
  cin>>H>>W;
  S.resize(H);
  for(int i=0; i<H; i++){
    cin>>S[i];
  }
  ll ans=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]=='.'){
        ans=max(ans, bfs(i,j));
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int r0, w, c, r;
  while (1) {
    cin >> r0 >> w >> c >> r;
    if (r0 + w + c + r == 0) return 0;
    if (double(r0) / w >= c) {
      cout << 0 << endl;
      continue;
    }
    cout << ceil(double(c * w - r0) / r) << endl;
  }
}



Measured memory_bytes: 3276
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int n = nextInt();

        Map<Integer, Integer> axMap = new HashMap<>();

        for (int i = 0 ;i < n; i++) {
            int ax = nextInt();

            if (axMap.containsKey(ax)) {
                axMap.put(ax, axMap.get(ax) + 1);
            } else {
                axMap.put(ax, 1);
            }
        }

        // キーの降順ソート
        Integer[] mapkey = axMap.keySet().toArray(new Integer[axMap.size()]);
        Arrays.sort(mapkey, Comparator.reverseOrder());

        int max = 0;
        int second = 0;
        for (Integer key : mapkey) {
            Integer value = axMap.get(key);

            if (value <= 1) {
                continue;
            }

            if (key > max) {
                max = key;

                if (value >= 4) {
                    second = key;
                    break;
                }
            } else if (key > second) {
                second = key;
            }

            if (max > 0 && second > 0) {
                break;
            }
        }

        out((long) max * second);

    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 63680
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
arr.sort()

mod=10**9+7

#nCk
factorial=[1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)

inv_factorial = [-1] * (n+1)
inv_factorial[-1] = pow(factorial[-1], mod-2, mod)
for i in reversed(range(n)):
    inv_factorial[i] = inv_factorial[i+1] * (i+1) % mod

def fact(n):
    return factorial[n]

def nck(n, k):
    if k>n or k<0:
        return 0
    else:
        return factorial[n] * inv_factorial[n-k] * inv_factorial[k] %mod

m=0
for i in range(n):
  m%=mod
  m+=arr[i]*nck(n-i-1, k-1)


M=0
for i in range(n-1, -1, -1):
  M%=mod
  M+=arr[i]*nck(i, k-1)

print((M-m)%mod)
  

Measured memory_bytes: 14996
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=1e9+7;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}
ll cnt=0;
ll vis[300000]={0};
vector<ll> v[300000];
void dfs(ll i){
  cnt++;
  vis[i]=1;
  for(auto it:v[i]){
    if(!vis[it]){
      dfs(it);
    }
  }
}
 int main(){
   IOS;
  ll n,m;
  cin>>n>>m;
  ll a,b;
  for(ll i=1;i<=m;i++){
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
  }
  ll v_cc=0;
  vector<ll> v;
  for(ll i=1;i<=n;i++){
     if(!vis[i]){
       v_cc++;
       cnt=0;
       dfs(i);
       v.pb(cnt);
     }
  }
  sort(v.begin(),v.end());
  cout<<v[v.size()-1]<<endl;
 }

Measured memory_bytes: 24712
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

const int N = 3010;

pair<int, int> cnt[N];
bool mat[N][N];

void solve(int n, int m, int a, int b) {
  memset(mat, 0, sizeof(mat));
  for (int _i = 0; _i <= n; ++_i)
    for (int _j = 0; _j <= m; ++_j)
      if (_i * a + (n - _i) * (m - a) == _j * b + (m - _j) * (n - b)) {
        for (int k = 1; k <= m - _j; ++k)
          cnt[k].first = n - b;
        for (int k = m - _j + 1; k <= m; ++k)
          cnt[k].first = b;
        for (int k = 1; k <= m; ++k)
          cnt[k].second = k;
        for (int i = 1; i <= n; ++i) {
          int cn;
          if (i <= n - _i)
            cn = m - a;
          else
            cn = a;
          nth_element(cnt + 1, cnt + cn, cnt + m + 1, greater<pair<int, int>>());
          for (int j = 1; j <= cn; ++j) {
            assert(cnt[j].first);
            --cnt[j].first;
            mat[i][cnt[j].second] = true;
          }
        }
        for (int i = 1; i <= n; ++i) {
          for (int j = 1; j <= m; ++j)
            putchar(mat[i][j] + '0');
          putchar('\n');
        }
        return ;
      }
  puts("-1");
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n, m, a, b;
  while (scanf("%d%d%d%d", &n, &m, &a, &b) != EOF) {
    solve(n, m, a, b);
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int        long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
bool cust(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} 
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,k;
	cin>>n>>k;
	map<ll,ll>m;
	for(int i=0;i<k;i++){
		ll y;cin>>y;
		for(int j=0;j<y;j++){
			ll a;cin>>a;
			m[a]+=1;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(m[i]){continue;}
		else{ans+=1;}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <typeinfo>

struct Card {
	char suit;
	int value;
};

void traceALDS12C(Card arr[], int max) {
	for (int i = 0; i < max; ++i) {
		if (i)
			std::cout << " ";
		std::cout << arr[i].suit << arr[i].value;
	}
	std::cout << std::endl;
}

void BubbleSort(Card arr[], int N) {

	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (arr[j - 1].value > arr[j].value) {
				std::swap(arr[j - 1], arr[j]);
			}
		}
	}
	traceALDS12C(arr, N);
	std::cout << "Stable" << std::endl;
}

void SelectionSort(Card arr[], int N) {

	for (int i = 0; i < N; ++i) {
		int minIdx = i;
		for (int j = i; j < N; ++j) {
			if (arr[minIdx].value > arr[j].value) {
				minIdx = j;
			}
		}
		if (minIdx != i) {
			std::swap(arr[minIdx], arr[i]);
		}
	}
	traceALDS12C(arr, N);
}

bool check(Card str1[], Card str2[], int N) {
	for (int i = 0; i < N; ++i) {
		if (str1[i].suit != str2[i].suit || str1[i].value != str2[i].value) {
			return false;
		}
	}
	return true;
}

int main() {

	int N;
	std::cin >> N;

	Card cards[N];
	for (int i = 0; i < N; ++i) {
		std::cin >> cards[i].suit >> cards[i].value;
	}

	Card cards2[N];
	for (int i = 0; i < N; ++i)
		cards2[i] = cards[i];

	BubbleSort(cards, N);
	SelectionSort(cards2, N);

	if (check(cards, cards2, N)) {
		std::cout << "Stable" << std::endl;
	} else {
		std::cout << "Not stable" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


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

vector<ll> fac[100005];
ll sumfac[100005];


int main(){
    ll n, k;
    cin >> n >> k;
    //setPrime(k);
    mint ans(0);
    for (ll i=1; i<=k; i++) {
        if (i==1) {
            mint aa(k);
            ans += aa.pow(n);
            continue;
        }
        
        fac[i].push_back(1);
        for (ll j=2; j*j<=i; j++) {
            if (i%j==0) {
                fac[i].push_back(j);
                if (j*j!=i) {
                    fac[i].push_back(i/j);
                }
            }
        }
        ll sum = 0;
        for (ll e:fac[i]) {
            sum += e;
            sum -= sumfac[e];
        }
        sumfac[i] = sum;
        mint x(k/i);
        mint num;
        num = x.pow(n);
        num *= (i-sum);
        ans += num;
        //cout << num.x << endl;
    }

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


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

typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;

#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

lli mod = 1e9 +7;
lli dp[100001], presum[100001], a[100002], n, k;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i=1; i<=n; i++)cin>>a[i];
	for(int i=1; i<=k+1; i++)presum[i]=1;
    for(int i=1; i<=n; i++)
    {
    	for(lli j=0; j<=k; j++)
    		dp[j] = (presum[j+1] - presum[max(0LL, j-a[i])] + 2*mod)%mod;
    	for(int x=1; x<=k+1; x++)
    		presum[x] = (presum[x-1]+dp[x-1])%mod;
    	// cout << "\n";
    }
    cout << dp[k];
}

Measured memory_bytes: 5228
import sys

d = {"A": 0, "B": 1, "AB": 2, "O": 3}
L = [0] * 4

for line in sys.stdin:
  try:
    n, t = [i.rstrip() for i in line.split(',')]
    L[d[t]] += 1
  except:
    break
for l in L:
  print(l)

Measured memory_bytes: 5568
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);

    int cnt=0;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(tmp>=k) {
            cnt++;
        }
    }
    printf("%d\n", cnt);


    return 0;
}


Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if((a+b)%2==1) cout<<"Borys"<<endl;else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
import math
k = int(input())

memo = [[-1] * (k+1) for _ in range(k+1)]

total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        if memo[a][b] != -1:
            ab = memo[a][b]
        else:
            ab = math.gcd(a, b)
            memo[a][b] = ab
            memo[b][a] = ab
        for c in range(1, k+1):
            if memo[ab][c] != -1:
                total += memo[ab][c]
            else:
                abc = math.gcd(ab, c)
                memo[ab][c] = abc
                memo[c][ab] = abc
                total += abc
print(total)

Measured memory_bytes: 68552
#include <bits/stdc++.h>
int main() {
	int N;
	char IS[10000];
	char Alph[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
	std::cin >> N >> IS;
	for (int i = 0; i < strlen(IS); i++) {
		for (int I = 0; I < 26 ;I++)
		{
			if (IS[i] == Alph[I]) {
				std::cout << Alph[(I+N)%26];
			}
		}
	};
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        Double a,b,angle;
        
        a=scan.nextDouble();
        b=scan.nextDouble();
        angle=scan.nextDouble()*2*Math.PI/360;
        System.out.println(0.5*a*b*Math.sin(angle));
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(angle))+a+b);
        System.out.println(b*Math.sin(angle));
    }
}


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int num[3];
	for(int i = 0; i < 3; i++) cin >> num[i];
	int ans = 0;
	while(!(num[0] == num[1] && num[1] == num[2])){
		ans++;
		sort(num, num+3);
		if(num[0] == num[1] && num[1]+1 == num[2]){
			num[0]++; num[1]++;
		}else if(num[1] == num[2] && num[0]+2 == num[1]){
			num[0]+= 2;
		}else{
			num[0] += 2;
		}

	}

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

Measured memory_bytes: 256
def main():
	n,m = map(int,input().split())
	a = []
	for i in range(n):
		a += [int(input())]
	for i in range(1,m+1):
		for j in range(n-1):
			if a[j] % i > a[j+1] % i:
				a[j], a[j+1] = a[j+1], a[j]
	print("\n".join(map(str,a)))

main()


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ? -5

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;


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

Measured memory_bytes: 0
def cutSequence(piles, threshold):
    for i in xrange(len(piles)-1):
        if piles[i]+piles[i+1]>=threshold:
            return range(0, i)+range(len(piles)-2, i-1, -1)
    return []

def main():
    n, m = [int(x) for x in raw_input().strip().split()]
    a = [int(x) for x in raw_input().strip().split()]
    foo = cutSequence(a, m)
    if len(foo)==0:
        print 'Impossible'
    else:
        print 'Possible'
        for x in foo:
            print x+1

if __name__ == '__main__':
    main()

Measured memory_bytes: 11852
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            var x = 0;
            foreach(var c in s){
                if(c == 'o'){
                    x += 1;
                }
            }

            Console.WriteLine(x * 100 + 700);
        }
    }
}


Measured memory_bytes: 13140
//Link : https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_e

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

ll mypow(ll x,ll c) {
    ll ret = 1;
    while(c>0 ) {
        if(c&1) {
            ret = ret*x;
        }
        x = x*x;
        c/=2;
    }
    return ret;
}
ll getMinCost(ll x,ll eat) {
    ll p = pow(x,1.0/eat);
    ll g= 1;
    for(int i=0;i<eat;++i) {
        g *= p;
        if(g>=x) {
            return p*eat;
        }
    }
    
    for(int i=0;i<=eat;++i) {
        if(g>=x) {
            return (p+1)*i + p*(eat-i);
        }
        g/=p;
        g *= p+1;        
    }
    assert(0);
}

ll c[50];
void solve() {
    ll n,A;
    scanf("%lld %lld",&n,&A);
    ll ret = n;
    ll g = 1;
    for(int eat = 2;;++eat,g*=2) {
        ret = min(ret,(eat-1)*A +  getMinCost(n,eat));
        if(g>n) {
            break;
        }
    }
    printf("%lld\n",ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
	val ab = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val a1 = List(1,2,3,4,5,6,7,8,9)
	val a2 = List(0,1,2,3,4,5,6,7,8,9)
	val a3 = List(0,1,2,3,4,5,6,7,8,9)

	var cnt = Set[Int]()

	for(x <- a1){
		val temp = x + 10*x + 100*x + 1000*x + 10000*x
		if(ab(0) <= temp && temp <= ab(1)){
			cnt = cnt + temp
		}
	}

	for(x <- a1){
		for(y <- a2){
			val t1 = 10000*x + 1000*x + 100*y + 10*x + x
			val t2 = 10000*x + 1000*y + 100*y + 10*y + x

			if(ab(0) <= t1 && t1 <= ab(1)){
				cnt = cnt + t1
			}
			if(ab(0) <= t2 && t2 <= ab(1)){
				cnt = cnt + t2
			}

			for(z <- a3){
				val t3 = 10000*x + 1000*y + 100*z + 10*y + x
				if(ab(0) <= t3 && t3 <= ab(1)){
					cnt = cnt + t3
				}
			}
		}
	}

	println(cnt.size)
}

Measured memory_bytes: 27324
#include <bits/stdc++.h>
 
int main() {
    int K, A, B;
    std::cin >> K >> A >> B;

    std::string ret = "NG";
    for (int i = A; i <= B; ++i) {
        if (i % K == 0) {
            ret = "OK";
            break;
        }
    }
    std::cout << ret << std::endl;            
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

/*
1つだけ同じ整数が入っている。
2つの同じ整数をのぞいたときにできる長さkの部分数列の個数は(n-1)Ck
同じ数列ができる場合を考える
a1,a2が同じ整数だとする
a1より前の数列の長さをl、a2より後の数列の長さをmとする
l+m+1>=kであれば同じ数列ができる場合がある。
SUM = sumation(0<=i<=k-1) lCi + mC(k-1-i)
(n+1)Ck - SUM

1 2 3 2 5 6
n = 5
m_i = 3
*/

int mod = 1000000000+7;
ll x[100010];
ll x_inv[100010];
int nCk(int n, int k){
  if(n<k) return 0;
  return x[n]*x_inv[k]%mod*x_inv[n-k]%mod;
}

int power_x_k(ll x, ll k,int mod){
  int ans = 1;
  while(k>0){
    if(k%2){
      ans = (ans*x)%mod;
      k--;
    }else{
      x = (x*x)%mod;
      k/=2;
    }
  }
  return ans;
}

int n;
bool visit[100010]={false};
int a[100010];
int tyouhuku;
int m;
int l;
int main(){
  scanf("%d",&n);
  REP(i,n+1){
    scanf("%d",&a[i]);
    if(visit[a[i]]){
      m = i;
      tyouhuku = a[i];
    }
    visit[a[i]]=true;
  }
  REP(i,m){
    if(tyouhuku == a[i]){
      l = i;
      break;
    }
  }
  x[0] = 1;
  x_inv[0] = 1;
  for(int i = 1; i<=n+1;i++){
    x[i] = (x[i-1]*i)%mod;
    x_inv[i] = power_x_k(x[i],mod-2,mod);
  }
  for(int i = 1;i<=n+1;i++){
    int sum = 0;
    sum = nCk(l+n-m,i-1);
    //printf("%d %d\n",nCk(n+1,i), sum);
    printf("%d\n",(nCk(n+1,i)+mod-sum)%mod);
  }
}


Measured memory_bytes: 3200
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x float64
	fmt.Scan(&a, &b, &x)

	if a*a*b/2 >= x {
		h := x / (b * a / 2)
		fmt.Println(math.Atan(b/h) / math.Pi * 180)
	} else {
		b = 2 * (b - x/(a*a))
		fmt.Println(math.Atan(b/a) / math.Pi * 180)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<double> b(n);
  double sum=0.0;
  double ans;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=1.0/a[i];
  }
  ans=1.0/sum;
  //  cout<<ans<<endl;
  printf("%.16lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    println!("{}", std::cmp::min(b / a, c));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

ll N, A, B;
vector<ll> v;


ll combination(ll n,ll m){
	ll ans = 1;
	for(int i=0;i<m;i++){
		ans *= n-i;
		ans /= i+1;
	}
	return ans;
}

ll count_num(ll n){
	ll ans=0;
	for(int i=0;i<v.size();i++){
		if(v[i] == n) ans++;
	}
	return ans;
}


int solve(){
	double ans_1=0;
	ll ans_2=0;
	ll count=0;
	sort(v.begin(),v.end(), greater<ll>());
	ll cur = v[0];
	for(int i=0;i<A;i++){
		if(cur != v[i]){
			count += count_num(cur);
			cur = v[i];
		} 
		ans_1 += v[i];
	}
	ans_1 /= A;

	if(count==0){
		ll n = count_num(v[0]);
		for(int m=A;m<=n && m<=B; m++){
			ans_2 += combination(n,m);
			//cout << m << " : " << combination(n,m) << endl;
		}
	}else{
		ll n = count_num(cur);
		ll m = A - count;
		// cout << n << " " << m << endl;
		ans_2 = combination(n,m);
	}

	cout.precision(20);

	cout << ans_1 << endl;
	cout << ans_2 << endl;

	return 0;
}



int main(){
	cin >> N >> A >> B;
	v.resize(N);
	for(int i=0;i<N;i++){
		cin >> v[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int las[20000],rlas[20000];
typedef pair<int,int>pii;
int solve(string sa,string sb)
{
	int num=sa.size();
	sa=sa+sa+sa+sa+sa,sb=sb+sb+sb+sb+sb;
	for(int i=1;i<sb.size();i++)
	{
		las[i]=las[i-1];
		if(sb[i]=='1')las[i]=i;
	}
	for(int i=sb.size()-2;i>=0;i--)
	{
		rlas[i]=rlas[i+1];
		if(sb[i]=='1')rlas[i]=i;
	}
	int mini=1000000000;
	for(int p=0;p<num;p++)
	{
		vector<pii>v;
		int cnt=0;
		//printf("- %d\n",p);
		for(int i=num+num;i<num+num+num;i++)
		{
			if(sa[i]==sb[i+p])continue;
			pii z=make_pair(0,0);
			if(las[i+p]<i)z.first=i-las[i+p];
			if(rlas[i]>i+p)z.second=rlas[i]-(i+p);
			v.push_back(z);
			cnt++;
			//printf("%d %d %d\n",i-num-num,z.first,z.second);
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		int now=0;
		int mi=1000000000;
		for(int i=0;i<v.size();i++)
		{
			mi=min(mi,(v[i].first+now)*2+cnt+p);
			now=max(now,v[i].second);
		}
		mi=min(mi,now*2+cnt+p);
		mi=min(mi,num+cnt+p);
		//printf(" %d\n",mi);
		mini=min(mini,mi);
	}
	return mini;
}
int main()
{
	string sa,sb;
	cin>>sa>>sb;
	if(sa==sb)
	{
		printf("0\n");
		return 0;
	}
	int cnt=0;
	for(int i=0;i<sb.size();i++)if(sb[i]=='1')cnt++;
	if(cnt==0)
	{
		printf("-1\n");
		return 0;
	}
	int ans1=solve(sa,sb);
	reverse(sa.begin(),sa.end());
	reverse(sb.begin(),sb.end());
	int ans2=solve(sa,sb);
	printf("%d\n",min(ans1,ans2));
}

Measured memory_bytes: 384
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

enemy = 0
for i in range(N):
    if A[i] >= B[i]:
        enemy += B[i]
    else:
        q = B[i]-A[i]
        if q <= A[i+1]:
            enemy += B[i]
            A[i+1] -= q
        else:
            enemy += A[i]+A[i+1]
            A[i+1] = 0

print(enemy)


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

using ll = long long;

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vector<ll> A, B;
    for(int i = 0;i < N;i++){
        A.push_back(x[i] + y[i]);
        B.push_back(x[i] - y[i]);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    cout<<max(abs(A.back() - A.front()), abs(B.back() - B.front()))<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


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

using namespace std;

const int INF = 1 << 29;
using int64 = long long;

const int N = 4e6 + 10;

int main() {
  int n;
  scanf("%d", &n);
  bitset<N> visit;
  visit[0] = true;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    visit |= (visit << x);
    sum += x;
  }
  int ret = sum / 2;
  for (; ret >= 0; --ret) {
    if (visit[ret]) break;
  }
  printf("%d\n", sum - ret);
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Add.num;
        var ar = new int[num];
        for (var i = 0; i < num; i++)
            ar[i] = Add.num;
        var res = 0L;
        for(var i = 0; i < num; i++)
        {
            res += ar[i] / 2;
            ar[i] %= 2;
            if (i != num - 1)
            {
                var min = Min(ar[i], ar[i + 1]);
                ar[i] -= min;
                ar[i + 1] -= min;
                res += min;
            }
        }
        WriteLine(res);
    }
}

public class Add
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

int main(){
  int N, ans = 0;

  cin >>N;

  if(N >= 105){
    for (int i = 105; i <= N ;i++){
      int cnt = 0;
      if(i%2){
        for(int j = 1;j <= i;j++){
          if(!(i%j))cnt++;
        }
        if(cnt == 8)ans++;
      }
    }
  }

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


Measured memory_bytes: 384
N = int(input())
a = list(map(int,input().split()))
color_count = [0 for i in range(8)]
tourist = 0
for i in range(N):
    if a[i] >= 3200:
        tourist += 1
    else:
        A = int(a[i]/400)
        if color_count[A]!=1:
            color_count[A]+=1
        else:
            pass
MIN = sum(color_count)
if MIN != 0:
    print(MIN,(MIN+tourist))
else:
    print(1,tourist)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int x[4][3][10];

int main()
{
	int n, b, f, r, v;
	cin >> n;
	while (n--) {
		cin >> b >> f >> r >> v;
		x[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << ' ' << x[i][j][k];
			}
			cout << endl;
		}
		if (i + 1 < 4) {
			cout << "####################" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    string ans="second";
    for(auto a:A){
        if(a%2) ans="first";
    }

    cout<<ans<<endl;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if (a*b==15) cout<<"*";
	else if (a+b==15) cout<<"+";
	else cout<<"x";
	return 0;
}

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

int main(){
  int w,n;
  int a[30],b[30],ans[100],tmp;
  cin >> w >> n;

  for(int i=0;i<n;i++)scanf("%d,%d",&a[i],&b[i]);
  

    for(int j=1;j<=w;j++){
      tmp=j;
      for(int i=0;i<n;i++){
	if(j==a[i]||j==b[i]){
	  if(j!=a[i])j=a[i];
	  else j=b[i];
	}
      }
      ans[j]=tmp;
      j=tmp;
    }
    for(int i=1;i<=w;i++)cout << ans[i]<<endl;


  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    ll res = 0;
    REP(i, N){
    	REP(j, N){
    		if(i<j){
    			//dump(i)
    			//dump(j)
    			ll now1 = L[i] + L[j];
    			ll now2 = L[j] - L[i];
                //dump(now1)
    			ll pos1 = lower_bound(L.begin()+j+1, L.end(), now1) -  (L.begin()+j+1);
    			ll pos2 = lower_bound(L.begin()+j+1, L.end(), now2+1) - (L.begin()+j+1);
    			//dump(pos1)
    			//dump(pos2)
    			if(pos1-pos2 > 0){
    				ll tmp = pos1 - pos2;
	    			//dump(tmp)
	    			res += tmp;
	    		}
    		}
    	}
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define endl '\n'
using namespace std;
int arr[maxn],ans[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i=0;i<n;i++)
		arr[i+1] = (s[i] == 'o' ? 0 : 1);
	for(int i=0;i<=1;i++)
		for(int j=0;j<=1;j++) {
			ans[1] = i;
			ans[2] = j;
			for(int k=3;k<=n;k++)
				ans[k] = (arr[k-1] ^ ans[k-1] ^ ans[k-2]);
			if(arr[n] == (ans[n-1] ^ ans[1] ^ ans[n]) && arr[1] == (ans[n] ^ ans[2] ^ ans[1])) {
				for(int i=1;i<=n;i++)
					cout << (ans[i] == 0 ? 'S' : 'W');
				cout << endl;
				return 0;
			}
		}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1360
N = int(input())
H = list(map(int, input().split()))
bl = True

for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1

for i in range(N-1):
    if H[i] > H[i+1]:
        bl = False

print('Yes' if bl else 'No')

Measured memory_bytes: 63856
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let r = read!(usize);
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

double pi=atan(1.0)*4;

double angleDiff(double a,double c){
	double dif=a-c;
	if(dif>pi)dif-=pi*2;
	if(dif<-pi)dif+=pi*2;
	return dif;
}

int main(void){
	double xa,ya,xb,yb,xc,yc,xd,yd,a,b,c;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
		a=atan2(xb-xa,yb-ya);
		b=atan2(xd-xa,yd-ya);
		c=atan2(xc-xa,yc-ya);
		if(angleDiff(a,c)*angleDiff(b,c)>0){printf("NO\n");continue;}
		a=atan2(xa-xb,ya-yb);
		b=atan2(xc-xb,yc-yb);
		c=atan2(xd-xb,yd-yb);
		if(angleDiff(a,c)*angleDiff(b,c)>0){printf("NO\n");continue;}
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 664
import gc

MOD = (10 ** 9) + 7

S = input()
N = len(S)

dp = [[0] * (N + 1) for _ in range(4)]

dp[0][0] = 1
dp[1][0] = 0
dp[2][0] = 0
dp[3][0] = 0

for i in range(1, N + 1):
    for j in range(4):
        s = S[i - 1]
        m = 3 if s == "?" else 1
        dp[j][i] += m * dp[j][i - 1]
        if j == 1:
            if s == "A" or s == "?":
                dp[j][i] += dp[j - 1][i - 1]
        elif j == 2:
            if s == "B" or s == "?":
                dp[j][i] += dp[j - 1][i - 1]
        elif j == 3:
            if s == "C" or s == "?":
                dp[j][i] += dp[j - 1][i - 1]
        dp[j][i] = dp[j][i] % MOD

print(dp[3][N] % MOD)


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

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

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

    sort(time.begin(), time.end());

    ll count = 1;
    ll j = 0;
    for (ll i = 0; i < N; i++) {
        if (time[i] > time[j] + K || i - j + 1 > C) {
            // cout << i << endl;
            j = i;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4052
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e10

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
VI x(101);

signed main()
{
	cin >> n;
	x.resize(n);
	REP(i, n) {
		cin >> x[i];
	}
	sort(ALL(x));
	int mi = INF;
	FOR(p,1, x.back()+1){
		int cnt = 0;
		REP(i, n){
			cnt += (p - x[i]) * (p - x[i]);
		}
		mi = min(mi, cnt);
	}

	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define M 2000000
int h,a[M+1];
void maxH (int );
int main()
{
  int i;
  scanf("%d",&h);

  for(i=1;i<=h;i++)scanf("%d",&a[i]);

  for(i=h/2;i>=1;i--)maxH(i);
  for(i=1;i<=h;i++)
    {
      printf(" ");
      printf("%d",a[i]);
      if(i==h)printf("\n");
    }


  return 0;
}

void maxH (int i)
{
  int l,r,L,temp;
  l =2*i;
  r =2*i+1;

  if( l<=h && a[l]> a[i])L=l;
  else L =i;
  if(r <=h && a[r]> a[L])L=r;


  if(L !=i){
    temp=a[i];
    a[i]=a[L];
    a[L]=temp;
    maxH(L);
  }
}


  










 



Measured memory_bytes: 3756
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        String[] nums = new String[n];
        if (k <= n) {
            for (int i = 0; i < n; i++) {
                if (i < k) {
                    nums[i] = Integer.toString(s);
                } else {
                    nums[i] = s != 1000000000 ? Integer.toString(s + 1) : "1";
                }
            }
        } else {
            int diff = k - n;
            nums[0] = Integer.toString(s);
            for (int i = 1; i < n; i++) {
                if (0 < diff) {
                    nums[i] = Integer.toString(0);
                    diff--;
                } else {
                    nums[i] = Integer.toString(s);
                }
            }
        }

        String result = String.join(" ", nums);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 37204