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

using namespace std;

const double EPS = 1e-8;
const complex<double> I = complex<double>(0.0, 1.0);

int main(){
  int N;
  cin >> N;
  
  vector<complex<double>> p(N);
  for(int i = 0; i < N; i++){
    double re, im;
    cin >> re >> im;
    p[i] = complex<double>(re, im);
  }
  
  double t = 2000.0;
  double b = 0.0;
  double R = -1.0;
  for(int k = 0; k < 50; k++){
    R = (t + b) / 2.0;
    vector<complex<double>> intersections;
    for(int i = 0; i < N - 1; i++){
      for(int j = i + 1; j < N; j++){
        double d = abs(p[i] - p[j]);
        if(d > 2.0 * R + EPS) continue;
        complex<double> dir = (p[i] - p[j]) / d * sqrt(R * R + EPS - d * d / 4.0) * I;
        intersections.push_back((p[i] + p[j]) / 2.0 + dir);
        intersections.push_back((p[i] + p[j]) / 2.0 - dir);
      }
    }
    
    bool encloses = false;
    for(complex<double> intersection : intersections){
      encloses = true;
      for(int i = 0; i < N; i++){
        if(abs(p[i] - intersection) > R + EPS){
          encloses = false;
        }
      }
      if(encloses) break;
    }
    (encloses ? t : b) = R;
  }
  
  cout << fixed << setprecision(10) << R << endl;
  
  return 0;
}

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

int main() {
  int K;
  cin >> K;
  if(K % 2 == 0) {
    cout << ( K / 2 ) * ( K / 2 ) << endl;
  } else {
    cout << ( K / 2 ) * ( K / 2 + 1 ) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool s[110];
int n,k,cnt=0;
int main(){
	cin>>n>>k;
	while(k--){
		int v; cin>>v;
		while(v--){
			int p;cin>>p;
			s[p]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(s[i]==0)cnt+=1;
	}
	cout<<cnt<<endl;
} 

Measured memory_bytes: 3624
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = Array.new(n + 1, 0)
n.times do |i|
  c[i + 1] = c[i] + a[i]
end
d = Array.new(m + 1, 0)
m.times do |i|
  d[i + 1] = d[i] + b[i]
end
cnt = 0
0.upto(n) do |i|
  sum = c[i]
  break if sum > k
  e = d.bsearch_index{_1 > k - sum}
  if e.nil?
    cnt = i + m if cnt < i + m
  else
    cnt = i + e - 1 if cnt < i + e - 1
  end
end
puts cnt

Measured memory_bytes: 44836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
const int MN = 100000;
vector<int> G[MN];
bool matched[MN];

void dfs(int v,int p=-1){
	for(int u:G[v]) if(u!=p) dfs(u,v);
	if(matched[v]) return;
	if(p!=-1 && !matched[p]){
		matched[v] = 1;
		matched[p] = 1;
		return;
	}
}
int main(){
	cin>>N;
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	dfs(0);
	rep(i,N) if(!matched[i]){
		puts("First");
		return 0;
	}
	puts("Second");
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum*i%MOD)%MOD;
    }
    return sum;
}

//nCr
ll permutationMethod(ll n,ll r){
    ll n_sum,r_sum;
    ll i;
	ll rr = n - r;
    n_sum = facctorialMethod(n);
    r_sum = (facctorialMethod(rr)*facctorialMethod(r))%MOD;
	print(n_sum);
	print(r_sum);
    return n_sum/r_sum;
}

int main(){
	int n,a; cin>>n>>a;
	cout << (n < a? 0:10) << endl;
}

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

int main(){
    int H1, H2, M1, M2;
    int K;
    cin >> H1 >> M1 >> H2 >> M2;
    cin >> K;

    int interval;
    interval = (H2-H1)*60 + (M2-M1) - K;

    cout << interval << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    K = ii()
    X = il()

    ret = 0
    for n in range(N):
        ret += min(X[n] * 2, abs(K - X[n]) * 2)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10132
/**
 *   created: 02 August 2020 (Sunday)  17:29:11
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define int long long

void solve(){
	int i; cin>>i;
	if(i<30) cout<<"No\n";
	else cout<<"Yes\n";
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

int main()
{
    int N, imin, res=1;
    cin >> N >> imin;
    for(int n=1; n<N; n++){
        int P;
        cin >> P;
        if(imin >= P){
            res += 1;
            imin = P;
        }           
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int MAXN = 500 + 3;
int n;
vector<vec> cnt(MAXN,vec(MAXN,0));
vector<vecbl> occ(MAXN,vecbl(MAXN,false));
vec dx = {1,0,-1,0};
vec dy = {0,1,0,-1};

void bfs(int x,int y){
    if(min(x,y)<=0 || n < max(x,y))return;
    rep(i,4){
        int x1=x+dx[i];
        int y1=y+dy[i];
        int plus = occ[x][y]?1:0;
        int z = cnt[x][y] + plus;
        if(cnt[x1][y1] > z){
            cnt[x1][y1] = z;
            bfs(x1,y1);
        }
    }
    return;
}


int main(){
    n=in();
    int ans=0;
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
        cnt[i][j]=min(min((i-1)%n,n-1-(i-1)%n),min((j-1)%n,n-1-(j-1)%n));
        occ[i][j]=true;
    }
    rep(i,n*n){
        int k=in()-1;
        int x=k%n+1;
        int y=k/n+1;
        ans+=cnt[x][y];
        occ[x][y]=false;
        bfs(x,y);
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll N, D;
  cin >> N >> D;

  vector<vector<ll>> A(N,vector<ll>(2));
  rep(i,N)cin >> A.at(i).at(0) >> A.at(i).at(1);

  ll ans = 0;
  rep(i, N){
    if((pow(abs(A.at(i).at(0)), 2) + pow(abs(A.at(i).at(1)),2)) <= (double)pow(D, 2) + 0.2) ++ans;
    //cout << pow(A.at(i).at(0), 2) + pow(A.at(i).at(1), 2) << endl;
    //cout << ans << endl;
    //cout << pow(D,2) << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 14344
#include<stdio.h>

int main(void){
  int N,i,min,max;
  int a[101];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  max = a[0];
  min = a[0];
  for(i=0;i<N;i++){
    if(a[i] > max) max = a[i];
    if(a[i] < min) min = a[i];
  }
  printf("%d\n",max-min);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,a[120];
int main()
{
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    double p=ceil(sum/(4.0*m));
    int cnt=0;
    for(int i=0;i<n;i++){
        if(p<=a[i]){
            cnt++;
        }
    }
    if(cnt>=m) cout<<"Yes";
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
void Erato(vector<int> &A, int mx) {
  int a[100000];
  for (int i = 2; i <= mx; i++) {
    if (a[i] != 0) continue;
    for (int j = 2; j * i <= mx; j++) {
      a[i * j] = 1;
    }
  }
  for (int i = 2; i <= mx; i++) {
    if (a[i] == 0) A.push_back(i);
  }
}
int main() {
  int N;
  cin >> N;
  vector<int> Sosuu(0);
  Erato(Sosuu, 55555);
  int sum = 0, id = 0;
  for (int i = 0;; i++) {
    if (id >= N) break;
    if ((Sosuu[i] % 5) != 1) continue;
    cout << Sosuu[i];
    if (id != N - 1) cout << " ";
    id++;
  }
  cout << endl;
}

Measured memory_bytes: 3884
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    int c = 0;
    for (int i = 0; i < n; i++) {
        int x = a[a[i]-1];
        if (i+1 == x) {
            c++;
        }
    }
    std::cout << c/2 << std::endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int moveTo[][2] = {{-1,0},{1,0},{0,-1},{0,1}};

int stage[100][100];

void paint(int c,int d,int x,int y){
	//c:1~5 d: 0:horizonal 1:vertical
	if(d==0){
		for(int i=x;i<x+4;i++){
			for(int j=y;j<y+2;j++){
				stage[j][i] = c;
			}
		}
	}
	else{
		for(int i=x;i<x+2;i++){
			for(int j=y;j<y+4;j++){
				stage[j][i] = c;
			}
		}
	}
}

bool bfs(int w, int h, int xs, int ys, int xg, int yg){
	int cs = stage[ys][xs];
	int cg = stage[yg][xg];
	if(cs != cg) return false;

	queue<P> que;
	que.push(P(xs,ys));

	while(!que.empty()){
		int sx = que.front().first;
		int sy = que.front().second;
		
		if(sx == xg && sy == yg) return true;
		que.pop();

		stage[sy][sx] = -1;

		for(int i=0;i<4;i++){
			int dx = sx + moveTo[i][0];
			int dy = sy + moveTo[i][1];

			if(dx < 0 || dx >= w || dy < 0 || dy >= h) continue;
			if(stage[dy][dx] != cs || stage[dy][dx] == -1) continue;
			que.push(P(dx,dy));

		}

	}
	return false;
}

int main(){
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==h && h==0) break;
		memset(stage,-1,sizeof(stage));
		int xs,ys;
		scanf("%d %d",&xs,&ys);

		int xg,yg;
		scanf("%d %d",&xg,&yg);

		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			int c,d,x,y;
			//c:1~5 d: 0:horizonal 1:vertical
			scanf("%d %d %d %d",&c,&d,&x,&y);
			paint(c,d,x-1,y-1);
		}

		printf("%s\n",bfs(w,h,xs-1,ys-1,xg-1,yg-1) ? "OK" : "NG");
	}
}

Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int ll;

int main(){
	int N;
	cin >> N;
	map<int, int> mpa;
	bool flag = true;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		if(a != 0) flag = false;
		mpa[a]++;
	}
	if(flag){
		cout << "Yes" << endl;
		return 0;
	}
	if(N % 3 != 0){
		cout << "No" << endl;
		return 0;
	}
	vector<pair<int, int> > va;
	map<int, int>::iterator itr;
	for(itr = mpa.begin(); itr != mpa.end(); itr++){
		va.push_back(make_pair(itr->first, itr->second));
	}
	if(va.size() == 2){
		if(va[0].second > va[1].second) swap(va[0], va[1]);
		if(va[1].second != va[0].second * 2 || va[0].first != 0){
			cout << "No" << endl;
			return 0;
		}else{
			cout << "Yes" << endl;
			return 0;
		}
	}
	if(va.size() != 3){
		cout << "No" << endl;
		return 0;
	}
	if((va[0].first ^ va[1].first) != va[2].first){
		cout << "No" << endl;
		return 0;
	}
	if(va[0].second != va[1].second || va[1].second != va[2].second || va[2].second != va[0].second){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
  int a, b, c, d, e, k;
  
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e - a > k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  int s1=0;
  int sum=0;
  int s2;
  int ans;
  vector<int> data(n);
  for(int i=0;i<n;i++){
    cin >> data[i];
    sum += data[i];
  }
  
  for(int i=0;i<n;i++){
    s1 += data[i];
    s2 = sum - s1;
    if(s1>s2){
      ans = min(s1-s2,s2-s1+2*data[i]);
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int N;
string s;
ll ans;

ll dfs(int i, ll left, ll sum)
{
    if (i == N)
        return left + sum;
    else 
        return dfs(i+1, s[i]-'0', sum + left)
        + dfs(i+1, left*10 + (s[i]-'0'), sum);
}

int main()
{
    cin >> s;
    N = s.size();
    cout << dfs(1, s[0] - '0', 0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int X, A, B;
	cin >> X >> A >> B;
	if (B <= A)
		cout << "delicious" << endl;
	else if (B <= X + A)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
H_list = list(map(int,input().split()))
#N,A,B = map(int,input().split())
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]
ans = 0
cnt = 0
for i in range(N-1):
    if H_list[i] >= H_list[i +1]:
         cnt += 1
         #print(ans)
         ans = max(ans,cnt)
    else:
        cnt = 0
print(ans)


Measured memory_bytes: 14252
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// kuch ni ho rha to kya pta binary search ho
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e18;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string s;
  cin>>s;
  ll n=s.length();
  if(s[n-1]=='s')
    s+="es";
  else
    s+='s';
  cout<<s<<'\n';
  return 0;
}

Measured memory_bytes: 3664
local n=io.read("n","l")
local s=io.read()

local _,white=s:gsub("%.","")
local black=0
local result=black+white
for i=1,n do
    if s:sub(i,i)=="#" then
        black=black+1
    else
        white=white-1
    end
    result=math.min(result,black+white)
end
print(result)

Measured memory_bytes: 3016
#!/usr/bin/env python3
import sys


def solve(H: int):
    ans = 0
    tmp = 1
    while H:
        ans += tmp
        H //= 2
        tmp *= 2
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#!/usr/bin/env python
# coding: utf-8

# In[13]:


N = int(input())
s = []
a = 0
b = 0
ab = 0
cnt = 0
for _ in range(N):
    tmp = input()
    cnt += tmp.count("AB")
    if tmp[0] == "B" and tmp[-1] == "A":
        ab += 1
    elif tmp[0] == "B":
        b += 1
    elif tmp[-1] == "A":
        a += 1
    s.append(tmp)


# In[14]:


if ab==0:
    ans = cnt + min(a,b)
else:
    if a+b>0:
        ans = cnt + ab + min(a,b)
    else:
        ans = cnt + ab-1
print(ans)


# In[ ]:






Measured memory_bytes: 74960
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >>n;
    int k = n/1000 + (n%1000 > 0);
    cout <<1000*k - n <<endl;

    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(){
  int x,y,i,tmp,r;

scanf("%d%d",&x,&y);

if(x<y){
tmp = x;
x = y;
y = tmp;
}

r = x%y;
while(r != 0){
  x = y;
  y = r;
  r = x%y;
}
printf("%d\n",y);
return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i,j,k,x;
    cin>>a>>b;
    x=0;
    if(a==1)
    {
        x=x+300000;
    }
    if(a==2)
    {
        x=x+200000;
    }
    if(a==3)
    {
        x=x+100000;
    }
    if(b==1)
    {
        x=x+300000;
    }
    if(b==2)
    {
        x=x+200000;
    }
    if(b==3)
    {
        x=x+100000;
    }
    if(a==1 && b==1)
    {
        x=x+400000;
    }
    cout<<x<<endl;
}


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

using namespace std;

const int maxn = 100010;

vector<int> tree[maxn];

int dp[maxn];

int n = 0;

void dfs(int u) {
	vector<int> vec;
	for (int i = 0; i < tree[u].size(); i++) {
		int v = tree[u][i];
		dfs(v);
		vec.push_back(dp[v]);
	}
	int sz = int (vec.size());
	sort(vec.begin(), vec.end());
	for (int i = 0; i < vec.size(); i++) {
		dp[u] = max(dp[u], vec[i] + sz - i);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		int p = 0; scanf("%d", &p);
		tree[p].push_back(i);
	}
	dfs(1);
	printf("%d\n", dp[1]);
	return 0;
}

Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define MAXC 100000
int dp[100005],a[100005],n,k=2;
//int max(int a, int b, int c){
//	return (max(a, max(b,c)));
//}
int main()
{
	int n, W;
	cin>>n>>W;
	int wt[n];int val[n];
	for(int i=0;i<n;i++) cin>>wt[i]>>val[i];
	ll knap[n+1][W+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=W;j++){
			if(i==0 || j==0) knap[i][j]=0;
			else if(j>=wt[i-1]) 
			knap[i][j] = max(val[i-1]+knap[i-1][j-wt[i-1]], knap[i-1][j]);
			else knap[i][j] = knap[i-1][j];
		}
	}
	cout<<knap[n][W];
}   

Measured memory_bytes: 79104
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#define MAXN 100005
#define LL long long
using namespace std;
int n, x;
int star[MAXN];
int main()
{
    cin >> n >> x;
    for(int i = 0; i < n; i++) scanf("%d", &star[i]);
    LL ans = 0;
    for(int i = 0; i < n - 1; i++)
    {
        if(star[i] > x)
        {
            ans += (LL)(star[i] - x);
            ans += (LL)(star[i + 1]);
            star[i] = x;
            star[i + 1] = 0;
        }
        else
        {
            if(star[i] + star[i + 1] > x)
            {
                ans += (LL)(star[i] + star[i + 1] - x);
                star[i + 1] -= (star[i] + star[i + 1] - x);
            }
        }
    }
    //for(int i = 0; i < n; i++) cout << star[i] << endl;
    //if(star[n - 1] > x) ans += (LL)(star[n - 1] - x);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int N;
	int t[100];
	int M;
	int px[100][2];

	int time=0;
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> t[i];
	}
	cin >> M;
	for(int i=0;i<M;i++)
	{
		cin >> px[i][0] >> px[i][1];
	}

	for(int i=0;i<M;i++)
	{
		for(int j=0;j<N;j++)
		{
			if((px[i][0]-1)==j)
			{
				time += px[i][1];
			}else{
				time += t[j];
			}
		}
		cout << time <<endl;
		time =0;
	}
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  string true_str = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i,s.size()){
    if(true_str[i] != s[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    ll K;
    vector<ll> a;

    ll Q,N;
    string S;
    cin>>N;
    ll flag=0;
    ll t1=0;
    ll t2=0;

    for(i=(int)(sqrt(N));i>0;i--){
        if(N%i==0){
            
            cout<< i+N/i-2<<endl;
            return 0;
            
        }
    }
   
    return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	string S; cin >> S;
	int a = -1, z = -1;
	for(int i=0; i<SZ(S); i++) {
		if(S[i] == 'A') {a = i; break;}
	}
	for(int i=SZ(S)-1; i>=0; i--) {
		if(S[i] == 'Z') {z = i; break;}
	}
	cout << z - a + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
	int a[120000],n,inp;
	for(int i=1; i<=100000;i++) a[i] = 0;
	int hapus = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&inp);
		if(inp>100000) hapus++;
		else
		{
			a[inp]++;
		}	
	}
	
	for(int i=1; i<=100000;i++)
	{
		if(a[i]>0)
		{
			if(a[i] > i) hapus = hapus + (a[i]-i);
			else if(a[i] < i) hapus = hapus + a[i];
		}
	} 
	
	printf("%d\n",hapus);
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    Int N, M; cin >> N >> M;
    vector<Int> A(N);
    priority_queue<Int, vector<Int>> pq;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        pq.push(A[i]);
    }
    for (int i = 0; i < M; i++) {
        Int top = pq.top();
        pq.pop();
        pq.push(top/2);
    }
    Int ans = 0;
    while (!pq.empty()) {
        Int top = pq.top();
        pq.pop();
        ans += top;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
N, A, B = map(int, input().split())
x = tuple(map(int, input().split()))
k = B//A

res = 0
for i in range(N-1):
    if x[i+1]-x[i] > k:
        res += B
    else:
        res += (x[i+1]-x[i])*A
print(res)

Measured memory_bytes: 15148
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		long total = 0, ans = 0;
		for(int i = 0; i < M; i++) {
			long d = sc.nextLong();
			long c = sc.nextLong();
			total += c*d;
			ans += c;
		}
		System.out.println(ans - 1 + (total-1)/9);

	}

}

Measured memory_bytes: 93820
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/
int a[200];

int main() {
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++) {
		a[s[i] - 'A'] += 1;
	}
	int sum = 0;
	for (int i = 0; i < 200; i++) {
		if (a[i] == 2) { sum++; }
	}

	Tof(sum == 2);

	return 0;
}


Measured memory_bytes: 764
def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    dp = [0]*(n)

    for i in range(1, n):
        temp = 10**10
        for j in range(1, min(i, k)+1):
            temp = min(temp, dp[i-j]+abs(h[i]-h[i-j]))
        dp[i] = temp

    print(dp[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 54752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, m;
    cin>>n>>m;
    ll a[n];
    priority_queue<ll> pq;
    for (int i=0; i<n; i++){
        cin>>a[i];
        pq.push(a[i]);
    }
    ll cnt = 0;
    while(!pq.empty() && cnt<m){
        ll x = pq.top();
        pq.pop();
        x /= 2;
        if (x!=0)pq.push(x);
        cnt++;
    }
    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

ll solve(string s) {
    ll ans = 0, cur = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '+') {
            ans += cur;
            cur = 0;
        } else {
            cur *= 10;
            cur += s[i]-'0';
        }
    }
    ans += cur;
    return ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0;; ++i) {
        if (i >= 1<<(s.size()-1)) break;
        string aux;
        for (int j = 0; j < s.size()-1; ++j) {
            aux.push_back(s[j]);
            if (i & (1<<j)) aux.push_back('+');
        }
        aux.push_back(s[s.size()-1]);
        ans += solve(aux);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

string s;

int main(){
      cin >> s;

      s[0] = '2';
      s[1] = '0';
      s[2] = '1';
      s[3] = '8';

      cout << s << endl;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vector<P> ba(n);
    rep(i, n) cin >> ba[i].second >> ba[i].first;

    sort(ba.rbegin(), ba.rend());
    int time = ba[0].first;
    for(auto t : ba){
        time = min(time, t.first);
        time -= t.second;
        if(time < 0){
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  int a,b;
  char op;
  cin>>a>>op>>b;

  int ans;
  if(op=='+') ans=a+b;
  else ans=a-b;

  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == "AC":
        ac += 1
    elif S[i] == "WA":
        wa += 1
    elif S[i] == "TLE":
        tle += 1
    elif S[i] == "RE":
        re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)


Measured memory_bytes: 16300
#include<iostream>
using namespace std;
const int N=1e5+5;
int a[N]={0};
int main(){
int n;
cin>>n;
int ai;
while(n--){
	scanf("%d",&ai);
	a[ai+2]++;    
	a[ai+1]++;
	a[ai]++;
}
int max=0;
for(int i=0;i<N-1;i++){
if(max<a[i])
	max=a[i];
}
cout<<max<<endl;
 
return 0;
 
}

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


int main() {
  vector<int> num;
  for(int i = 1; i <= 200; i += 2) {
    int y = 0;
    for(int j = 1; j <= i; j++) {
      if(i % j == 0) y++;
    }
    if(y == 8) num.push_back(i);
  }

  int n;
  cin >> n;
  int out = 0;
  for(auto x: num) {
    if(x <= n) out++;
  }

  cout << out << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        var mod = 1_000_000_007L;

        var sumA = new long[N];
        sumA[0] = A[^1];
        for (int i = 1; i < A.Length; i++)
            sumA[i] = (sumA[i - 1] + A[^(i + 1)]) % mod;
        sumA = sumA.Reverse().ToArray();

        var ans = 0L;

        for (int i = 0; i < A.Length - 1; i++)
            ans = ((A[i] * sumA[i + 1]) % mod + ans) % mod;

        WriteLine(ans);
    }
}


Measured memory_bytes: 50812
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    map<string,vector<pii>> str_po;

    string s;
    int n;
    REP(i,N){
        cin >> s >> n;
        pii p = {n,i+1};
        str_po[s].emplace_back(p);
    }

    for (auto &x : str_po) {
        sort(ALL(x.second),greater<>());
        //cout << x.first << endl;
    }

    for (auto x : str_po) for (auto p : x.second) {
        cout << p.second << endl;
    }

    return 0;
}

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

public class Main {

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

        final Solver solver = new Solver();
        solver.solve(S);
    }
}

class Solver {
    public void solve(String S) {
        for (int i = 0; i < 3; i++) {
            if (S.charAt(i) == S.charAt(i+1)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}



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

int main()
{
    int s;
    cin >> s;
    int front = s/100, back = s%100;
    if(0<front && front<=12 && 0<back && back<=12)
        cout << "AMBIGUOUS" << endl;
    else if(0<front && front<=12)
        cout << "MMYY" << endl;
    else if(0<back && back<=12)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA = _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => -x)
                .Where((x, i)=> i % 2 == 0 ).Sum();

                PointA -= B.Taste.Sum(x => x);
                return PointA;
            }


        }


    public class Person{
            public long[] Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(long[] taste)
            {
                Taste = taste;
            }

        }


        public string Resolve()
        {
            var range = Enumerable.Range(0, n);

            var a = new Person(range.Select(i => ls[i][0]).ToArray());
            var b = new Person(range.Select(i => ls[i][1]).ToArray());

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 35508
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
int t=1;
if(a==b&&b==c)
{cout<<1;
}
else if(a==b||b==c||c==a)
{cout<<2;}
else
{
cout<<3;}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};

void score(int D,vector<int> c,vector<vector<int>> s,vector<int> t){
    vector<int> last(26,0);  
    int ans = 0;
    rep(i,D){
        last[t[i]-1] = i+1;
        ans += s[i][t[i]-1];
        int tmp =  0;
        rep(j,26){
            tmp += c[j] * (i+1-last[j]);
        }
        ans -= tmp;
        cout << ans << endl;   
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int> (26,0));
    vector<int> smax(D,0);
    vector<int> t(D);
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
            int old = smax[i];
            smax[i] = max(smax[i],s[i][j]);
            if(old != smax[i]){
                t[i] = j+1;
            }
        }
    }
    rep(i,D) {
        cout << t[i] << endl;
    }    
    
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  sort(a.rbegin(), a.rend(), [](auto &x, auto &y){return abs(x) < abs(y);});

  vector<ll> neg, pos;
  for (int i = 0; i < k; i++) {
    if (a[i] < 0) neg.push_back(a[i]);
    else if (a[i] > 0) pos.push_back(a[i]);
    else {
      cout << 0 << endl;
      return 0;
    }
  }
  if (neg.size() % 2 == 1) {
    ll next_neg = 0;
    bool next_neg_found = false;
    ll next_pos = 0;
    bool next_pos_found = false;
    for (int i = k; i < n; i++) {
      if (a[i] < 0) {
        next_neg = a[i];
        next_neg_found = true;
        break;
      }
    }
    for (int i = k; i < n; i++) {
      if (a[i] > 0) {
        next_pos = a[i];
        next_pos_found = true;
        break;
      }
    }
    if ((!next_neg_found && !next_pos_found) || (pos.size() == 0 && !next_pos_found)) {
      ll ans = 1;
      for (int i = n-1; i >= n - k; i--) {
        ans = (ans * a[i]) % mod;
        if (ans < 0) ans += mod;
      }
      cout << ans << endl;
      return 0;
    }
    else if (pos.size() == 0) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else if (!next_neg_found) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else if (!next_pos_found) {
      pos.pop_back();
      neg.push_back(next_neg);
    }
    else if (pos[pos.size()-1] * next_pos > neg[neg.size()-1] * next_neg) {
      neg.pop_back();
      pos.push_back(next_pos);
    }
    else {
      pos.pop_back();
      neg.push_back(next_neg);
    }
  }

  ll ans = 1;
  for (auto &x: pos) {
    ans = (ans * x) % mod;
  }
  for (auto &x: neg) {
    ans = (ans * x) % mod;
    if (ans < 0) ans += mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6820
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 2e5 + 10;
#define singleCase
// #define multipleCase
int n,q,a[N],freq[N];
map <int , int> lie,l;

void printmap(map <int , int> &m) {
   printf("========\n");
   for (ii x : m) {
      printf("%d %d\n" , x.fi , x.se);
   }
}

void printSetting() {
   for (int i = 1 ; i <= n ; i++) {
      printf("%d" , lie[i]);
   } puts("");
   return;
}

void inputAndInit() {
   in(n); in(q);
   for (int i = 1 ; i <= n ; i++) {
      in(a[i]);
      freq[a[i]]++;
   }
   for (int i = 1 ; i <= n ; i++) {
      l[i] = i - freq[i] + 1;
      for (int j = l[i] ; j <= i ; j++) {
         lie[j]++;
      }
   }
}

void work() {
   inputAndInit();
   int valid = 0;
   for (int i = 1 ; i <= n ; i++) {
      valid += (lie[i] > 0);
   }
   while (q--) {
      int pos,val; in(pos); in(val);
      if (lie[l[a[pos]]] == 1 && l[a[pos]] >= 1) {
         valid--;
      }
      // printSetting();
      --lie[l[a[pos]]];
      ++l[a[pos]];
      a[pos] = val;
      if (lie[l[a[pos]] - 1] == 0 && l[a[pos]] - 1 >= 1) {
         valid++;
      }
      // printSetting();
      ++lie[l[a[pos]] - 1];
      --l[a[pos]];
      // printSetting();
      printf("%d\n" , n - valid);
   }
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 32576
n=int(input())
A=[]
for i in range(n):
    A.append(list(map(int,input().split())))

A.sort(key=lambda x:x[2],reverse=True)

#print(A)

a1=0
a2=0
a3=0

for i in range(0,101):
    for j in range(0,101):
        col=0
        h=abs(A[0][0]-i)+abs(A[0][1]-j)+A[0][2]
        for k in range(1,n):
            if max(0,h-abs(A[k][0]-i)-abs(A[k][1]-j))!=A[k][2] :
                col=1
        if col==0 :
            a1=i
            a2=j
            a3=h

print(str(a1)+" "+str(a2)+" "+str(a3))


Measured memory_bytes: 3064
n,a,b,c=map(int,input().split())
if a+b+c>2:
    ans=[]
    for i in range(n):
        s=input()
        if s=="AB":
            if a==0 and b==0:
                print("No")
                break
            else:
                if a>b:
                    ans.append("B")
                    a-=1
                    b+=1
                else:
                    ans.append("A")
                    a+=1
                    b-=1
        elif s=="AC":
            if a==0 and c==0:
                print("No")
                break
            else:
                if a>c:
                    ans.append("C")
                    a-=1
                    c+=1
                else:
                    ans.append("A")
                    a+=1
                    c-=1
        elif s=="BC":
            if b==0 and c==0:
                print("No")
                break
            else:
                if b>c:
                    ans.append("C")
                    b-=1
                    c+=1
                else:
                    ans.append("B")
                    b+=1
                    c-=1
    else:
        print("Yes")
        for i in ans:
            print(i)
    quit()
s=[input() for i in range(n)]
ans=[]
d=dict()
d["A"]=a
d["B"]=b
d["C"]=c
i=0
while i<n:
    if d[s[i][0]]==0 and d[s[i][1]]==0:
        print("No")
        quit()
    elif d[s[i][0]]==0:
        ans.append(s[i][0])
        d[s[i][0]]+=1
        d[s[i][1]]-=1
    elif d[s[i][1]]==0:
        ans.append(s[i][1])
        d[s[i][0]]-=1
        d[s[i][1]]+=1
    else:
        if i==n-1:
            ans.append(s[i][0])
            break
        if s[i][1] in s[i+1]:
            ans.append(s[i][1])
            d[s[i][0]]-=1
            d[s[i][1]]+=1
        else:
            ans.append(s[i][0])
            d[s[i][0]]+=1
            d[s[i][1]]-=1
    i+=1
print("Yes")
for i in ans:
    print(i)

Measured memory_bytes: 90232