akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
vector<ll> ans;

bool ok(ll n, ll k)
{
    // assert(2 <= k && k <= n);
    while (n % k == 0 && k != 1)
        n /= k;
    //cerr << k << " " << n % k << endl;
    return n % k == 1ll;
}
int main()
{
    ll n;
    cin >> n;
    int ans = 0;
    rep(p, 1, n + 1)
    {
        if (n < p * p)
            break;
        if (n % p == 0)
        {
            if (ok(n, p))
                ans++;
            if (p != n / p)
            {
                if (ok(n, n / p))
                    ans++;
            }
        }
    }
    n--;
    rep(p, 1, n + 1)
    {
        if (n < p * p)
            break;
        if (n % p == 0)
        {
            if (ok(n + 1, p))
                ans++;
            if (p != n / p)
            {
                if (ok(n + 1, n / p))
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = list(map(int,input().split()))
x = [0]*a
x1 = sum(b) - (sum(b[1::2]))*2
x[0] = x1
for i in range(1,a):
    x[i] = 2*b[i-1] - x[i-1]
for j in range(len(x)):
    print(x[j],"",end='')

Measured memory_bytes: 14092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void){
    int N; cin>>N;
    vector<int> W(N);
    for(int i=0;i<N;i++){
        cin >> W[i]; 
    }
    int S1 = 0,S2 = 0;
    int ans = 9999;
    for(int i=0;i<N;i++){
        S1 = 0;S2 = 0;
        for(int j=0;j<=i;j++){
            S1 += W[j];
        }
        for(int k=i+1;k<N;k++){
            S2 += W[k];
        }
        if(abs(S1-S2)<ans){
            ans = abs(S1-S2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    h, w = map(int,input().split())
    if h == 0 and w ==0:
        break
    else:
        x1="#"
        x2="."
        #??????????????£????????????=x1
        for i in range(0, w-1):
            if x1[-1] == "#":
                x1+="."
            else:
                x1+="#"

        for i in range(0, w-1):
            if x2[-1] == ".":
                x2+="#"
            else:
                x2+="."
        count = 0
        for i in range(0, h):
            count+=1
            if count % 2 == 1:
                print(x1)
            else:
                print(x2)
    print('')

Measured memory_bytes: 7540
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
alphas = "abcdefghijk"

from collections import deque

q = deque(['a'])
for i in range(N - 1):
    q2 = deque([])
    while len(q) > 0:
        now = q.popleft()
        for a in alphas:
            q2.append(now + a)
            if a not in now:
                break
    q = q2
for a in q:
    print(a)
    

Measured memory_bytes: 17352
#include <iostream>
#include<queue>
#define endl '\n'
using namespace std;
const int sz=1e3+1;
int h,w,warp[sz][sz],ch,cw,dh,dw,nh,nw;
bool vis[sz][sz];
char g[sz][sz];
priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>pq;
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int wd[5]={-2,-1,0,1,2};

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

    cin>>h>>w;
    for(int i=1;i<=h;++i)fill(warp[i],warp[i]+w+1,h*w+1);
    cin>>ch>>cw;
    cin>>dh>>dw;
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j)cin>>g[i][j];
    }
    pq.push(make_pair(0,make_pair(ch,cw)));
    while(!pq.empty()){
        auto curr=pq.top();
        pq.pop();
        int currwarp=curr.first;
        int currh=curr.second.first;
        int currw=curr.second.second;
        if(vis[currh][currw])continue;
        vis[currh][currw]=1;
        for(int i=0;i<4;++i){
            nh=currh+dx[i];
            nw=currw+dy[i];
            if(nh>0 && nh<=h && nw>0 && nw<=w && g[nh][nw]=='.' && warp[nh][nw]>currwarp){
                warp[nh][nw]=currwarp;
                pq.push(make_pair(currwarp,make_pair(nh,nw)));
            }
        }
        currwarp++;
        for(int i=0;i<5;++i){
            nh=currh+wd[i];
            for(int j=0;j<5;++j){
                nw=currw+wd[j];
                if(nh>0 && nh<=h && nw>0 && nw<=w && g[nh][nw]=='.' && warp[nh][nw]>currwarp){
                    warp[nh][nw]=currwarp;
                    pq.push(make_pair(currwarp,make_pair(nh,nw)));
                }
            }
        }
    }
    if(warp[dh][dw]<h*w+1)cout<<warp[dh][dw]<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 9644
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)

using namespace std;

const int N = 21;
const int N0 = 33000;

int g[N][N], t0[N0], t1[N0][N], n, m;

int f[N][N0][2];

int cut(int s1, int s2){ return t0[s1 | s2] - t0[s1] - t0[s2];}
#define g(i) (1 << (i - 1))
int main()
{
	
	scanf("%d%d", &n, &m);
	Rep(i, m) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		g[x][y] += z, g[y][x] += z;
	}
	
	Rep0(i, (1 << n) - 1) {
		Rep(j, n) if (i & (1 << (j - 1))){
			for (int k = j; k <= n; k ++)
				if (i & (1 << (k - 1))) t0[i] += g[j][k];
			Rep(k, n) t1[i][k] += g[k][j];
		}
	}
	
	Rep(i, n) Rep0(s, (1 << n) - 1) f[i][s][0] = f[i][s][1] = 1e9;
	
	f[1][1][0] = 0;
	
	Rep0(s, (1 << n) - 1) Rep(i, n) if (s & g(i)){
		int tmp = s ^ g(i);
		Rep(j, n) if ((tmp & g(j)) && g[i][j])
			f[i][s][0] = min(f[i][s][0], f[j][tmp][1] - g[i][j] + t1[tmp][i]);
		for (int s0 = tmp; ; s0 = tmp & (s0 - 1)) {
			f[i][s][1] = min(f[i][s][1], f[i][s ^ s0][0] + cut(s0, tmp ^ s0));
			if (!s0) break;
		}
	}
	
	printf("%d\n", f[n][(1 << n) - 1][1]);
	
	return 0;
}
/*
5 6
1 5 100
1 4 100
1 2 100
2 3 100
3 4 100
4 5 100

*/


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) { return find(x) == find(y);}

  int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }
    vector<int> A(n, 0);
    int ans = 0;
    rep(i, n) {
        int x = uf.find(i);
        if (A[x] == 0) ans++;
        A[x]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;
	while ( cin >> n ) {
		int act[ n+5 ][3]; memset( act, 0, sizeof (act) );
		
		for (int i = 0; i < n; ++i) cin >> act[i][0] >> act[i][1] >> act[i][2];
		
		int hap[ n+5 ][3]; memset( hap, 0, sizeof (hap) );
		hap[0][0] = act[0][0];
		hap[0][1] = act[0][1];
		hap[0][2] = act[0][2];
		
		for (int i = 1; i < n; ++i) {
			hap[i][0] = max( hap[ i-1 ][1], hap[ i-1 ][2] ) + act[i][0];
			hap[i][1] = max( hap[ i-1 ][0], hap[ i-1 ][2] ) + act[i][1];
			hap[i][2] = max( hap[ i-1 ][0], hap[ i-1 ][1] ) + act[i][2];
		}
		
		cout << max( hap[ n-1 ][0], max( hap[ n-1 ][1], hap[ n-1 ][2] ) ) << '\n';
	}
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 10000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll n,m;
    cin>>n>>m;
    if(m>=n)
        cout<<1<<endl;
    else if(n>m)
    {
        ll x=n%m;
        ll xx=n/m;
        if(x>=1)
            cout<<xx+1<<endl;
        else
            cout<<xx<<endl;
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#define NUM 200000

int main(){
  int n;
  int p[NUM],q;
  int i,j,ans = 1,s = 1;

  /*入力*/
  scanf("%d",&n);
  scanf("%d",&p[0]);
  q = p[0];
  for(i = 1;i < n;i++){
    scanf("%d",&p[i]);
    if(q > p[i]){
      ans++;
      q = p[i];
    }   
  }

  printf("%d\n",ans);

  return 0;
}


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

int main() {
  long double a,b,x,ans=0,pi=3.141592653589793;
  cin >> a >> b >> x;
  x/=a;
  if(x*2<=a*b) ans=180/(pi/atan2(b,x*2/b));
  else ans=180/(pi/atan2(2*(b-x/a),a));
  cout << fixed << setprecision(15);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n, ans = 0;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        int l, r;
        std::cin >> l >> r;
        ans += (r - l + 1);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    N = II()
    K = II()
    ans = 1
    for _ in range(N):
        if ans < K:
            ans *= 2
        else:
            ans += K
    return ans

print(main())

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
const i64 MOD = 1e9 + 7;

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
	int64_t value = 1;
	for(int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if(p & 1) value = (value * mul) % MOD;
	}
	return value;
}

int64_t invmod(int64_t x) {
	return powmod(x, MOD - 2);
}

struct Factorial {
	vector<int64_t> val;
	vector<int64_t> inv;
};

// O(N)
Factorial GetFact(int N) {
	N++;
	Factorial fact;
	fact.val = vector<int64_t>(N);
	fact.inv = vector<int64_t>(N);
	fact.val[0] = 1;
	for(int i = 1; i < N; i++) {
		fact.val[i] = int64_t(fact.val[i - 1] * i) % MOD;
	}
	fact.inv[0] = 1;
	fact.inv[N - 1] = powmod(fact.val[N - 1], MOD - 2);
	for(int i = N - 1; i > 0; i--) {
		fact.inv[i - 1] = int64_t(fact.inv[i] * i) % MOD;
	}
	return fact;
}

int64_t Permutation(int n, int m, const Factorial &f) {
	if(n < m || m < 0 || n < 0) return 0;
	return (f.val[n] * f.inv[n - m]) % MOD;
}

int64_t Combination(int n, int m, const Factorial &f) {
	if(n < m || m < 0 || n < 0) return 0;
	return ((f.val[n] * f.inv[m] % MOD) * f.inv[n - m]) % MOD;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n, -1);
    n++;
    int x, y;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
		a--;
        if(p[a] >= 0) {
            x = p[a], y = i;
        } else {
            p[a] = i;
        }
    }
    Factorial f = GetFact(n);
    for(int k = 1; k <= n; k++) {
        i64 ans = 0;
        ans += Combination(n - 2, k, f);
        ans += 2 * Combination(n - 2, k - 1, f) - Combination(n - 1 + x - y, k - 1, f) + MOD;
        ans += Combination(n - 2, k - 2, f);
        ans %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;

int H, W;
vector<vector<int>> visited;
vector<string> S;
string ans = "Yes";

vector<int> dy = {0, 0, -1, 1};
vector<int> dx = {1, -1, 0, 0};
int link = 0;

void dfs(int i, int j){
    visited[i][j] = 1;
    link++;
    
    for(int k=0; k<4; k++){
        int ny = i + dy[k];
        int nx = j + dx[k];
        if(ny>=0 && nx>=0 && ny<H && nx<W && !visited[ny][nx] && S[ny][nx]=='#')
            dfs(ny, nx);
    }
    return;
}


int main() {
    cin >> H >> W;
    for(int i=0; i<H; i++){
        string s; cin >> s;
        S.push_back(s);
    }
    
    visited.resize(H);
    for(vector<int> &v:visited) v.resize(W);

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(!visited[i][j] && S[i][j]=='#'){
                dfs(i, j);
                if(link<2) ans = "No";
                link = 0;
            }
        }
    }
    
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;

  CIN(N);

  int A[N], B[N];
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        COUT("Yes");
        return 0;
      }
    }
  }
  COUT("No");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> dx= {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
const int INF=100000000;
int main(){
    string s2,t;
    cin>>s2>>t;
    if(s2.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    int max = 51;
    for(int i=0; i<s2.size()-t.size()+1; i++){
        for(int j=0; j<t.size() ; j++){
            if(s2.at(i+j)!=t.at(j)&&s2.at(i+j)!='?') break;
            if(j==t.size()-1) max=i;
        }
    }
    if(max==51){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int k=0; k<t.size(); k++){
        s2.at(max+k)=t.at(k);
    }
    for(int l=0; l<s2.size() ; l++){
        if(s2.at(l)=='?') cout<<'a';
        else cout<<s2.at(l);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 100005

struct Node{ int p, l, r; };

Node T[N];
int n, D[N], H[N];

void setDepth(int u, int d){
	if (NIL == u) return;
	D[u] = d;
	setDepth(T[u].l, d + 1);
	setDepth(T[u].r, d + 1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if (NIL != T[u].l) h1 = setHeight(T[u].l) + 1;
	if (NIL != T[u].r) h2 = setHeight(T[u].r) + 1;

	return H[u] = max(h1, h2);
}

int getSibling(int u){
	if (NIL == T[u].p) return NIL;
	if (T[T[u].p].l != u && T[T[u].p].r != NIL) return T[T[u].p].l;
	if (T[T[u].p].r != u && T[T[u].p].l != NIL) return T[T[u].p].r;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].p);
	printf("sibling = %d, ", getSibling(u));

	int d = 0;
	if (NIL != T[u].l) d++;
	if (NIL != T[u].r) d++;

	printf("degree = %d, ", d);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (NIL == T[u].p) printf("root\n");
	else if (NIL == T[u].l && NIL == T[u].r) printf("leaf\n");
	else printf("internal node\n");
}

int main()
{
	int root = 0; cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = NIL;

	for (int i = 0; i < n; ++i){
		int v, l, r; cin >> v >> l >> r;
		T[v].l = l;
		T[v].r = r;
		if (NIL != l) T[l].p = v;
		if (NIL != r) T[r].p = v;
	}

	for (int i = 0; i < n; ++i) if (NIL == T[i].p) root = i;
	setDepth(root, 0);
	setHeight(root);

	for (int i = 0; i < n; ++i) print(i);

	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

  int n;
  cin >> n;
  if(n == 1){
    cout << "Yes" << endl;
    return 0;
  }
  for(int i = 2; i < 10; i++){
    if(n % i == 0){
      if(n / i <= 9){
      cout << "Yes" << endl;
      return 0;
      }
    }
  }
  cout << "No" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define N 100003
int bas,son;
#define orta (bas+son)/2
char s[10000000];
int main(){
	for(int i = 0;i<10000000;i++)s[i] = '?';
	string a;
	cin>>a;
	int j = 0;
	for(int i = 1000000;i<1000000+a.size();i++ ){
		s[i] = a[j];
		j++;
	}
	int l = 1000000-1,r = 1000000 + a.size();
	int q;
	cin>>q;
	bool rev = false;
	while(q--){
	    int x ;
		cin>>x;
		if(x == 1){
			rev = !rev;
		}
		if(x == 2){
			int a;
			char c;
			cin>>a>>c;
			if(a == 1){
				if(!rev){
				    s[l] = c;
				    l--;
				}
				else{
					s[r] = c;
					r++;
				}
			}
			if(a == 2){
				if(!rev){
				    s[r] = c;
				    r++;
				}
				else{
					s[l] = c;
					l--;
				}
			}
		}
		
	
	}
	//for(int i = 0;i<10000000;i++)if(s[i] != '?')cout<<s[i];
	if(rev){
	for(int i = r+1; i>=l-1;i--)
 		if(s[i] !='?')
			cout<<s[i];
		}
	else{
		for(int i = l-1 ; i<=r+1;i++)
		    if(s[i] !='?')
			cout<<s[i];
	}
    return 0;
}


Measured memory_bytes: 10496
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
	//this is a sample overloading function for sorting stl
	bool operator()(pii const &a, pii const &b)
	{
		if(a.F==b.F)
			return (a.S<b.S);
		return (a.F<b.F);
	}
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int h,w,k,ans=0;
        cin>>h>>w>>k;
        char c[h+5][w+5];
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++) cin>>c[i][j];
        }
        for(int maskh=0;maskh<(1 << h);maskh++)
        {
            for(int maskw=0;maskw<(1 << w);maskw++)
            {

                int cntBlack=0;
                for(int i=0;i<h;i++)
                {
                    for(int j=0;j<w;j++)
                    {
                       /// if( ((maskh >> i) & 1)==0 && ((maskw >> j) & 1)==0 && c[i][j]=='#' ) cntBlack++;   ///same
                       if( (maskh & (1<<i))==0 && (maskw & (1<<j))==0 && c[i][j]=='#' ) cntBlack++;           ///same
                    }
                }
                //cout<<cntBlack<<endl;
                if(cntBlack==k) ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
//author:happylkx
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
using namespace std;
typedef long long LL;

int main()
{
	int n;
	cin >> n;
	list <int> li;
	bool rev = false;
	while (n--) {
		int temp;
		cin >> temp;
		if (rev)li.push_front(temp);
		else li.push_back(temp);
		rev = !rev;
	}
	if (rev) {
		li.reverse();
		for (auto i : li) {
			cout << i << " ";
		}
	}
	else {
		for (auto i : li) {
			cout << i << " ";
		}
	}

	return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    string s, p;
     
    getline(cin, s);
    getline(cin, p);
     
    s=s+s;
     
    if(s.find(p)==-1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 3220
import itertools

S=input()

for i in itertools.product(["+","-"],repeat=3):
    ans=""
    for j in range(len(i)):
        if i[j]=="+":
            ans+=S[j]+i[j]
        elif i[j]=="-":
            ans+=S[j]+i[j]
    ans+=S[-1]
    sum_num=eval(ans)
    if sum_num==7:
        print(ans+"=7")
        break


Measured memory_bytes: 8920
#include "bits/stdc++.h"
using namespace std;

int main(){
	long long int n,k;
	cin>>n>>k;
	
	long long int ans=0;
	
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	
	for(int i=k+1;i<=n;i++){
		long long int tmp;
		tmp=n/i;
		ans+=tmp*(i-k);
		long long int tmp2=(n%i)-k+1;
		if(tmp2<0)tmp2=0;
		ans+=tmp2;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    int cnt[9] = {0};
    REP(i,N)
    {
        int s; cin >> s;
        if(s < 400) cnt[0]++;
        else if(s < 800) cnt[1]++;
        else if(s < 1200) cnt[2]++;
        else if(s < 1600) cnt[3]++;
        else if(s < 2000) cnt[4]++;
        else if(s < 2400) cnt[5]++;
        else if(s < 2800) cnt[6]++;
        else if(s < 3200) cnt[7]++;
        else cnt[8]++;

    }
    LL ans1 = 0; 
    LL ans2 = 0;
    REP(i,8)
    {
        if(cnt[i] != 0) ans1++;
    }
    ans2 = ans1 + cnt[8];
    if(ans1 == 0) ans1 = 1;
    cout << ans1 << " " << ans2 << endl;

}


Measured memory_bytes: 256
from heapq import heappush, heappop
X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

S = []
for a in A:
    for b in B:
        S.append(a+b)
S.sort()
que = []
L = X*Y
for c in C:
    heappush(que, (-S[-1]-c, L-1, c))
T = C

ans = []
for _ in range(K):
    v, i, c = heappop(que)
    ans.append(-v)
    if i > 0:
        heappush(que, (-S[i-1]-c, i-1, c))
print(*ans[:K], sep='\n')

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

using namespace std;
typedef long long ll;
const int N = 1000010;
ll d[N];

void sieve(int n) {
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j * i < n; ++j) {
      d[i*j]++;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  sieve(n);
  ll ans = 0;
  for (int i = 1; i < n; ++i) ans += d[i];
  cout << ans << '\n';
}

Measured memory_bytes: 11388
n=int(input())
dp=[0]*(n)
for i in range(n):
    dp[i]=[int(i) for i in input().split()]
for i in range(1,n):
    for j in range(3):
        dp[i][j]+=max([dp[i-1][k] for k in range(3) if k!=j])
print(max(dp[-1]))

Measured memory_bytes: 24340
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    string S;
    cin >> S;
    ll s = S.size();
    rep(i,s){
        if(S[i] == 'h' && S[i + 1] == 'i'){
            i++;
        }
        else {
            cout << "No" << endl;
            return 0; 
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    
    int ans = 0, x = 1, keta = 2;
    rep(i, 29) {
        vi aa(n), bb(n);
        rep(j, n) {
            aa[j] = a[j] % keta;
            bb[j] = b[j] % keta;
        }
        sort(all(bb));
        int s = 0;
        rep(j, n) {
            if (aa[j] < x) {
                int le = lower_bound(all(bb), x-aa[j]) - bb.begin();
                int ri = lower_bound(all(bb), x*2-aa[j]) - bb.begin();
                s += (ri - le);
            } else {
                auto ri = lower_bound(all(bb), x*2-aa[j]) - bb.begin();
                s += ri;
                auto le = bb.end() - lower_bound(all(bb), x*3-aa[j]);
                s += le;
            }
        }
        ans += (1ll << i) * (s % 2);
        x *= 2ll;
        keta *= 2ll;
    }

    std::cout << ans << std::endl;

    return 0;
}







Measured memory_bytes: 6612
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
vector<int> sum[10][50];
 
int main()
{
//	cut here before submit 
//	freopen ("testcase.sum_of_integers", "r", stdin );
	int n, s;
	while (scanf ("%d %d", &n, &s ) ){
		if (n == 0 && s == 0 ) break;
		rep (i, 10 )rep (j, 50 ) sum[i][j].clear();

		rep (i, 10 ){
			sum[0][i].push_back (1<<i);
		} // end rep

		for (int i = 1; i < n; i++ ){
			for (int j = 0; j < 50; j++ ){
				if (!sum[i-1][j].empty() ){
					rep (k, sum[i-1][j].size() ){
						rep (num, 10 ){
							if (!(sum[i-1][j][k] & (1<<num) ) && j+num < 50 ){
								sum[i][j+num].push_back (sum[i-1][j][k] | (1<<num) );
							} // end if
						} // end rep
					} // end rep
				} // end if
			} // end for
		} // end for

		set<int> ans; ans.clear();
		rep (i, sum[n-1][s].size() ){
			ans.insert (sum[n-1][s][i] );
		} // end rep
		int res = ans.size();
		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 30316
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

struct UnionFind{
  std::vector<int> parent;
  int& Root(int id){
    if(this->parent[id] == id){ return this->parent[id]; }
    else{ return this->parent[id] = this->Root(this->parent[id]); }
  }

  UnionFind(int N) : parent(N)
  {
    for(int i = 0; i < N; ++i){ this->Root(i) = i; }
  }

  void Union(int lhs, int rhs){
    if(this->Root(lhs) != this->Root(rhs)){ this->Root(this->Root(rhs)) = this->Root(lhs); }
  }

};

int main(void)
{
  int N;
  std::cin >> N;

  std::vector<std::pair<int, long long int> > x(N), y(N);
  for(int i = 0; i < N; ++i){
    long long int a, b;
    std::cin >> a >> b;
    x[i] = std::make_pair(i, a);
    y[i] = std::make_pair(i, b);
  }

  std::sort(x.begin(), x.end(), [](auto const& lhs, auto const& rhs){ return lhs.second < rhs.second; });
  std::sort(y.begin(), y.end(), [](auto const& lhs, auto const& rhs){ return lhs.second < rhs.second; });

  struct Cost{ long long int cost; int left; int right; };
  std::vector<Cost> cost((N-1)*2);
  for(int i = 0; i < N-1; ++i){
    cost[i*2] = {x[i+1].second-x[i].second, x[i].first, x[i+1].first};
    cost[i*2+1] = {y[i+1].second-y[i].second, y[i].first, y[i+1].first};
  }
  std::sort(cost.begin(), cost.end(), [](auto const& lhs, auto const& rhs){ return lhs.cost < rhs.cost; });

  std::vector<bool> checked(N, false);
  long long int sumCost = 0, sumCost2 = 0;
  UnionFind uf(N);

  for(auto it = cost.begin(), end = cost.end(); it != end; ++it){
    if(!checked[it->left] || !checked[it->right]){
      sumCost += it->cost;
      checked[it->left] = checked[it->right] = true;
    }
    if(uf.Root(it->left) != uf.Root(it->right)){
      uf.Union(it->left, it->right);
      sumCost2 += it->cost;
    }
  }

  std::cout << sumCost2 << std::endl;

  return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int br = 0, br1 = 0;
  int x = a + b;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'a') {
      if(br < x){
        cout << "Yes" << "\n";
        br++;
      }
      else 
        cout << "No" << "\n";
    }
    else if(s[i] == 'b') {
      if((br < x) && (br1 < b)) {
        cout << "Yes" << "\n";
        br++; br1++;
      }
      else 
        cout << "No" << "\n";
    }
    else {
      cout << "No" << "\n";
    }
  }

}


Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int a, b, c;
  while (scanf("%d %d %d\n", &a, &b, &c) == 3) {
    int ans = b + min(c, a + b + 1);
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int N, mini = 200005, cnt, tmp;
int main()
{
    cin>>N;
    while(N--)
    {
        cin>>tmp;
        if(tmp<=mini)
        {
            //cout<<"tmp = "<<tmp<<"\n";
            cnt++;
            mini = tmp;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>

using namespace std;

int main(void)
{
	int n;
	string l;
	int p,a,b,c,d,e,f,s,m;
	int i1,i2;

	int income;
	int time_;
	double ratio;
	
	while(1){
		cin >> n;
		if(n==0) break;

		map<double,set<string> > farm;

		for(i1=0;i1<n;i1++){
			cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;

			income=f*s*m-p;
			time_=a+b+c+(d+e)*m;
			ratio=(double)income/(double)time_;

			farm[ratio].insert(l);
		}

		for(map<double,set<string> >::reverse_iterator it=farm.rbegin(); it!=farm.rend();it++){
			for(set<string>::iterator it2=(*it).second.begin(); it2!=(*it).second.end();it2++){
				cout<<(*it2)<<endl;
			}
		}
		cout<<"#"<<endl;
	}

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define ll long long
#define bpm %1000000007

using namespace std;

ll powAns(ll,ll);

int main(){
    int n,u,k;
    int a;
    cin>>n;
    int vec[n][n];

    rep(i,n)rep(j,n)vec[i][j]=0;

    rep(i,n){
        cin>>u>>k;
        rep(j,k){
            cin>>a;
            vec[u-1][a-1]=1;
        }
    }
    rep(i,n){
        rep(j,n-1)cout<<vec[i][j]<<" ";
        cout<<vec[i][n-1]<<endl;
    }
}

ll powAns(ll m ,ll n){
    ll res=1;
    while(n>0){
        if(n & 1)res = res*m bpm;

        m=m*m bpm;
        n>>=1;
    }

    return res;
}



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

int main(){
    double x;
    cin>>x;
    long long now=100;
    int cnt=0;
    while(now<x){
        now=(long long)((double)now*1.01);
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
 ll a,b,c,d;
  cin >> a >> b >>c;
  cout<<(abs(a-b)>abs(a-c)?"B":"A");
    }

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

pair<LL, LL> f(LL v1, LL v2) {
  LL v = v1 + v2;
  LL cnt = 0;
  while (v > 9) {
    LL k2 = v / 10;
    LL k1 = v % 10;
    v = k1 + k2;
    ++cnt;
  }
  return {v, cnt};
}

int main() {
  int M; cin >> M;
  LL keta = 0, sum = 0;
  for (int i = 0; i < M; ++i) {
    LL d, c; cin >> d >> c;
    sum += d * c;
    keta += c;
  }
  cout << (keta-1) + ((sum-1)/9) << endl;
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

#define int ll

void solve(ll n) {
	if(n == 2) {
		cout << 1;
		return;
	}
	vi div, div2;
	for(ll i = 2; i*i <= n; i++) {
		if(n%i == 0) {
			div.pb(i);
			if(i != n/i)
				div.pb(n/i);
		}
	}
	for(ll i = 2; i*i <= n - 1; i++) {
		if((n - 1)%i == 0) {
			div2.pb(i);
			if(i != (n - 1)/i)
				div2.pb((n - 1)/i);
		}
	}
	ll res = 0;
	for(ll x : div) {
		ll tmp = n;
		while(tmp%x == 0)
			tmp /= x;
		res += (tmp%x == 1);
	}
	res += sz(div2);
	cout << res + 2;
}

int32_t main() {
	ll n;
	cin >> n;
	solve(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  double x[n],y[n];
  REP(i,n){
    cin>>x[i]>>y[i];
  }
  
  vector<int> v(n);
  REP(i,n){
    v[i] = i;
  }
  
  double sum_ = 0;
  int cnt = 0;

  do {
    cnt++;
    double temp = 0;
    REP(i,n-1){
      temp += hypot(x[v[i+1]]-x[v[i]], y[v[i+1]]-y[v[i]]);
    }
    sum_ += temp;
  } while (next_permutation(ALL(v)));
  
  double ans = sum_/(double)cnt;
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};

vector<LL> fact;
vector<LL> inver(3000001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(LL i=1;i<=3000000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[3000000]=fpow(fact[3000000],mod-2);
    for(LL i=2999999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}

LL f(LL r, LL c){
    return ((r + 2) * combi(r + c + 2, r + 2) %mod - (c + 1 %mod) + mod) %mod * fpow(c + 1, mod - 2) %mod;
}

int main(){
    set_combi();
    LL r1,c1,r2,c2;cin >> r1 >> c1 >> r2 >> c2;
    cout << (f(r2,c2) + f(r1-1,c1-1) - (f(r2,c1-1) + f(r1-1,c2) %mod) + mod) %mod << endl;
    return 0;
}


Measured memory_bytes: 58596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi= vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll a = n % k;
    ll b = -1LL * (a - k);
    ll c = min(a, b);
    cout << c << endl;
    return 0;
}


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

class Main {




  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    int K = in.nextInt();
    int[] hs = new int[N];
    for (int i = 0; i < N; i++) {
      hs[i] = in.nextInt();
    }

    int[] dp = new int[N];
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    dp[1] = Math.abs(hs[1] - hs[0]);


    for (int i = 2; i < N; i++) {
      for (int j = 1; j <= K; j++) {
        if (i - j < 0) break;
        dp[i] = Math.min(dp[i], 
                       dp[i - j] + Math.abs(hs[i] - hs[i - j]));
      }
    }

    System.out.println(dp[N - 1]);
  }

  

  
}

Measured memory_bytes: 49256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int A = 0,B = 0;
    cin >> A >> B;
    A += B;
    if(A == 3) cout << 3;
    else if(A == 4) cout << 2;
    else if(A == 5) cout << 1;
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
ans = 10**20

for i in range(2*10**5+1):
    ai = max(0, x-i//2)
    bi = max(0, y-i//2)
    ans = min(ans, ai*a + bi*b + i*c)

print(ans)



Measured memory_bytes: 40428