akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

vll G[N];
ll visa[N];
ll vist[N];
ll dpa[N];
ll dpt[N];
ll U,V;
void bfs1()
{
	ll i,node;
	node=U;
	queue<ll> q;
	vist[node]=1;
	q.push(node);
	while(!q.empty())
	{
		node=q.front();
		q.pop();
		for(i=0;i<sz(G[node]);i++)
		{
			if(vist[G[node][i]]==0)
			{
				vist[G[node][i]]=1;
				q.push(G[node][i]);
				dpt[G[node][i]]=dpt[node]+1;
			}
		}
	}
}

void bfs2()
{
	ll i,node;
	node=V;
	queue<ll> q;
	visa[node]=1;
	q.push(node);
	while(!q.empty())
	{
		node=q.front();
		q.pop();
		for(i=0;i<sz(G[node]);i++)
		{
			if(visa[G[node][i]]==0)
			{
				visa[G[node][i]]=1;
				q.push(G[node][i]);
				dpa[G[node][i]]=dpa[node]+1;
			}
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,u,v,ma;
    cin>>n>>U>>V;
    for(i=1;i<n;i++)
    {
    	cin>>u>>v;
    	G[u].pb(v);
    	G[v].pb(u);
    }
    bfs1();
    bfs2();
    ma=1;
    for(i=1;i<=n;i++)
    {
    	if(dpt[i]<dpa[i])
    	{
    		if(dpa[i]>ma)
    		{
    			ma=dpa[i];
    		}
    	}
    }
    cout<<ma-1<<"\n";
	return 0;
}

Measured memory_bytes: 33972
def resolve():

    A = [ list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]

    memo = [[0] * 3 for _ in range(3)]    

    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                memo[i][j] = 1

    for i in range(3):
        if memo[i][0] == 1 and memo[i][1] == 1 and memo[i][2] == 1:
            print("Yes")
            return
    
    for j in range(3):
        if memo[0][j] == 1 and memo[1][j] == 1 and memo[2][j] == 1:
            print("Yes")
            return

    if memo[0][0] == 1 and memo[1][1] == 1 and memo[2][2] == 1:
        print('Yes')
        return
    
    if memo[0][2] == 1 and memo[1][1] == 1 and memo[2][0] == 1:
        print("Yes")
        return
    
    print("No")


if __name__ == "__main__":
    resolve()

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

int main(){
    string values;
    int count = 0;

    cin >> values;

    for(int i = 0; i < values.size(); i++) {
      count += atoi(values.substr(i, 1).c_str());
    }
    cout << count << endl;
}


Measured memory_bytes: 3516
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n, a, b, c, d;
vector<pair<int, int>> red;
vector<pair<int, int>> blue;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
    sort(red.begin(), red.begin() + n);
    sort(blue.begin(), blue.begin() + n);
    int pos = 0;
    int ans = 0;
    multiset<int> st;
    for (int i = 0; i < n; ++i) {
        //青よりx座標の小さい赤をピックアップ
        while(red[pos].first < blue[i].first) st.insert(red[pos++].second);
        //青のy座標より大きい赤を選ぶ
        auto itr = st.lower_bound(blue[i].second);
        if (itr != st.begin()) {
            //青のy座標より大きい赤の次にはペアとなれる赤の中で最もy座標が大きい赤が存在するので
            //ペアとしてカウント
            st.erase(--itr);
            ans++;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    cin >> n;
    red.resize(n + 1);
    blue.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        red[i] = make_pair(a, b);
    }
    red[n] = make_pair(INF, INF);
    for (int i = 0; i < n; ++i) {
        cin >> c >> d;
        blue[i] = make_pair(c, d);
    }
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  if (A + B > 2 * C) {
    if (X < Y) {
      if (B > 2*C) {
        printf("%d\n", 2*Y*C);
      } else {
        printf("%d\n", 2*X*C + (Y-X)*B);
      }
    } else {
      if (A > 2*C) {
        printf("%d\n", 2*X*C);
      } else {
        printf("%d\n", 2*Y*C + (X-Y)*A);
      }
    }
  } else {
    printf("%d\n", X*A + Y*B);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	while(cin>>n){
        ll sum=0;
        for(ll i=1;i<=n;i++){
            if(i%3!=0&& i%5!=0){
                sum+=i;
            }
        }
        cout<<sum<<endl;
	}
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}
ll modinv(ll a){return modpow(a,MOD-2);}

int n,k;

int main(){
  cin>>n>>k;
  ll ans = 0;
  REP(i,k){
    ll comb = 0;
    { // k C i
      ll a = 1, b = 1;
      FOR(j,1,i+1){
        a = a*(k-j+1)%MOD;
        b = b*j%MOD;
      }
      comb = a * modinv(b) % MOD;
    }
    ll pw = modpow(k-i,n);
    int sign = i%2==0 ? 1 : -1;
    ans += MOD + sign*comb*pw%MOD;
    ans %= MOD;
  }
  printf("%lld\n",ans);
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

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

  vi a(N), b(N);
  for (ll i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }

  ll x = 0;
  for (ll i = 0; i < N; i++) {
    x = max(x, a[i]);
  }

  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());

  ll ans = INF;

  for (ll i = 1; i < N; i++) {
    b[i] = b[i] + b[i - 1];
  }

  for (ll i = 0; i <= N; i++) {
    if (i == 0) {
      ans = min(ans, (H + x - 1) / x);
    } else {
      if (H < b[i - 1]) {
        ans = min(ans, i);
      } else {
        ans = min(ans, i + (H - b[i - 1] + x - 1) / x);
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
    string forecast, result;
    
    cin >> forecast >> result;
    int cnt = 0;
    
    for(int i = 0; i < 3; i++){
        if(forecast[i] == result[i]) cnt++;
    }
    
    cout << cnt;
    
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item
{
    int value,weight;
};

int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1],G[NMAX+1][WMAX+1];

void compute(int &maxValue, vector<int> &selection)
{
    //????????§?°?w???0?????????????????°i???0??¶?????????????????????0?????????C???w=0???i=0????????????????´??????¨??¨????§???????0.
    for(int w=0;w<=W;w++)
    {
        C[0][w]=0;
        G[0][w]=DIAGONAL;//????????????
    }
    
    for(int i=1;i<=N;i++)
        C[i][0]=0;
    
    for(int i=1;i<=N;i++)
    {
        for(int w=1;w<=W;w++)
        {
            C[i][w]=C[i-1][w];
            G[i][w]=TOP;
            if(items[i].weight>w)
                continue;
            if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w])
            {
                C[i][w]=items[i].value+C[i-1][w-items[i].weight];
                G[i][w]=DIAGONAL;
            }
        }
    }
    maxValue=C[N][W];
    selection.clear();
    for(int i=N,w=W;i>=1;i--)
    {
        if(G[i][w]==DIAGONAL)
        {
            selection.push_back(items[i].value);
            w-=items[i].weight;
        }
    }
    reverse(selection.begin(), selection.end());
}

void input()
{
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>items[i].value>>items[i].weight;
}

int main()
{
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue,selection);
    
    cout<<maxValue<<endl;
    
    /*cout<<endl;
    for(int n=0;n<=N;n++)
    {
        for(int m=0;m<=W;m++)
        cout<<G[n][m]<<" ";
        cout<<endl;
    }*/
    /*cout<<"??????????????????????????????";
    for(int i=0;i<selection.size();i++)cout<<selection[i]<<" ";*/
}

Measured memory_bytes: 11064
#include <iostream>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  int result = 0;
  int N = static_cast<int>(S.size());
  for (int i = 0; i < N / 2; ++i) {
    if (S[i] != S[N - 1 - i]) ++result;
  }
  cout << result << endl;
  return 0;
}


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

struct point{
	double x;
	double y;
};

void koch(int n, struct point a, struct point b){
	if(n == 0){
		return;
	}
	struct point s,t,u;
	double th = M_PI * 60.0 / 180.0;
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}

int main(void){
	int n;
	struct point a,b; 
	scanf("%d", &n);
	a.x = 0;
	a.y = 0;
	b.x = 100.0;
	b.y = 0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}


Measured memory_bytes: 2104
l = []
for i in range(3):
  a,b = map(int, input().split())
  l.append(a)
  l.append(b)

for i in range(1,5):
  cnt=0
  for itm in l:
    if i==itm:
      cnt+=1
  if cnt>=3:
    print("NO")
    exit()
print("YES")
  	
  

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

int main() {
  float n;cin>>n;
  vector<float> a(n),b(n);
  float l,r;
  float sum=0.0;
  for(int i=0;i<n;++i)cin>>a[i],b[i]=a[i],sum+=a[i];
  float ave=sum/n;

  sort(a.begin(),a.end());
  int temp_ans=0,Temp_ans=101,ans=105;
  //cout<<ave<<endl;
  for(int i=0;i<n;++i){
    if(ave<a[i]){
      l=abs(ave-a[i-1]);
      r=abs(ave-a[i]);
      if(l<r)temp_ans=a[i-1];
      else if(l>r)temp_ans=a[i];
      else temp_ans=a[i],Temp_ans=a[i-1];
      break;
    }
  }
  for(int i=0;i<n;++i){
  	if(temp_ans==b[i] || Temp_ans==b[i])ans=min(ans,i);
  }
  //cout<<temp_ans<<" "<<Temp_ans<<endl;
  //cout<<l<<" "<<r<<endl;
  cout<<ans<<endl;
}

Measured memory_bytes: 888
//
// Created on 2020/05/11.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int a,p;
    cin>>a>>p;

    p += a*3;
    ans = p/2;

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


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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n-1);
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int dis;
            dis = min(abs(j-i), abs(x-i)+1+abs(y-j));
            ans[dis-1]++;
        }
    }
    for(int k = 0; k < n-1; k++){
        cout << ans[k] << endl;
    }
    return 0;
}

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

using namespace std;

int pow(int a, int b)
{
    int e=1;
    for (int i=1; i<=b; i++) e*=a;
    return e;
}

int main()
{
    set<int> S;
    int x;
    cin>>x;
    for (int i=1; i<32; i++)
    {
        for (int j=2; j<=9; j++)
        {
            if (pow(i, j)<=x) S.insert(pow(i, j));
        }
    }
    auto it=S.end();
    it--;
    cout<<*it<<'\n';
    return 0;
}


Measured memory_bytes: 256
import numpy as np
MOD = 10**9 + 7

def fact_table(N, MOD):
    N += 1
    inv = np.empty(N, np.int64)
    inv[0] = 0
    inv[1] = 1
    for n in range(2, N):
        q, r = divmod(MOD, n)
        inv[n] = inv[r] * (-q) % MOD
    fact = np.empty(N, np.int64)
    fact[0] = 1
    for n in range(1, N):
        fact[n] = n * fact[n - 1] % MOD
    fact_inv = np.empty(N, np.int64)
    fact_inv[0] = 1
    for n in range(1, N):
        fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
    return fact, fact_inv, inv

f, fi, inv = fact_table(2000, MOD)
# print(f[5] * fi[2] % MOD * fi[5-2] % MOD) # 5C2

n, k =  map(int,input().split())
for i in range(1, k+1):
    if n-k+1 < i:
        print(0)
        continue
    c1 = f[n-k+1] * fi[i] % MOD * fi[n-k+1-i] % MOD
    c2 = f[k-1] * fi[i-1] % MOD * fi[k-i] % MOD
    print(c1 * c2 % MOD)

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

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double PI = acos(-1);
  double th = double(60*h+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th), xm = b*cos(tm);
  double yh = a*sin(th), ym = b*sin(tm);
  double dx = xh - xm, dy = yh - ym;
  double ans = sqrt(dx*dx + dy*dy);
  
  cout << printf("%.10f", ans) << endl;
 
}


Measured memory_bytes: 3972
#!/usr/bin/env python3

import math
import itertools


INVALID = -1
INF = 10 ** 12


def dijkstra_dense(num_vs, adj_matrix, source, dest):
    dist = [INF for _ in range(num_vs)]
    visited = [False for _ in range(num_vs)]
    dist[source] = 0
    while True:
        u = min((j for j in range(num_vs) if not visited[j]),
                key=lambda i: dist[i], default=INVALID)
        if u == INVALID or dist[u] == INF:
            break
        visited[u] = True
        for v in range(num_vs):
            w = adj_matrix[u][v]
            if u != v and w < INF:
                new_len = dist[u] + w
                if new_len < dist[v]:
                    dist[v] = new_len
    return dist[dest]


def main():
    # 始点を頂点0、終点を頂点N + 1とする
    x0, y0, xf, yf = (int(x) for x in input().split())
    n = int(input())
    xs = [None for _ in range(n + 2)]
    ys = [None for _ in range(n + 2)]
    rs = [None for _ in range(n + 2)]
    xs[0], ys[0], rs[0] = x0, y0, 0
    xs[n + 1], ys[n + 1], rs[n + 1] = xf, yf, 0
    for i in range(1, n + 1):
        xs[i], ys[i], rs[i] = (int(z) for z in input().split())
    adj_matrix = [[INF for _ in range(n + 2)] for _ in range(n + 2)]
    for i, j in itertools.product(range(n + 2), repeat=2):
        adj_matrix[i][j] = max(0, math.hypot(xs[i] - xs[j],
                                             ys[i] - ys[j]) - (rs[i] + rs[j]))
    res = dijkstra_dense(n + 2, adj_matrix, 0, n + 1)
    print("{:.12f}".format(res))


if __name__ == '__main__':
    main()


Measured memory_bytes: 35956
#include <stdio.h>

int main()
{
  int i,n, a, b, sum = 0, k = 1000000, dig1, dig2;
  scanf("%d", &n);
 
  for(i=1; i<n; i++){
    a = i;
    b = n - i;
    while(a || b){
      dig1 = a % 10;
      dig2 = b % 10;
      sum = sum + dig1 + dig2;
      a = a/10;
      b = b/10;
    }
    if (k>sum) k=sum;
    sum = 0;
  }
  
  printf("%d\n", k);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n, k;
 
	cin >> n;
	cin >> k;
 
	if (((n+1) / 2)  >= k) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
 
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = false;
  if(a <= c && c <= b) flag = true;
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int n;
    cin >> n;
    vl a(n), b(n);
    fori (i, n) {
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        a[i] += ans;
        ll kek = (a[i] + b[i] - 1) / b[i] * b[i];
        ans += kek - a[i];
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main ()
{
     long long a,b,s,rem,c=0;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        s=a+b;
        while(s!=0)
        {

            s=s/10;
            c++;
        }

        printf("%lld\n",c);
        c=0;

    }





}



Measured memory_bytes: 2024
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

int main()
{
  string n;
  in n;
  if(n=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;

}


Measured memory_bytes: 3628
#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>;

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

int main() {
  int h, w;
  cin >> h >> w;
  int sx = 0, sy = 0, gx = h - 1, gy = w - 1;
  vector<string> maze(h);
  rep(i, h) cin >> maze[i];
  vector<vector<int>> dist(h, vector<int>(w, -1));

  queue<P> q;
  q.push(P(sx, sy));
  dist[sx][sy] = 0;
  while (!q.empty()) {
    P p = q.front();
    q.pop();
    int cx = p.first;
    int cy = p.second;
    // if (cx == gx && cy == gy) break;
    rep(i, 2) {
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if (0 > nx || nx >= h || 0 > ny || ny >= w) continue;
      if (maze[nx][ny] != '#' || dist[nx][ny] != -1) continue;
      dist[nx][ny] = dist[cx][cy] + 1;
      q.push(P(nx, ny));
      break;
      // cout << nx << " " << ny << endl;
    }
    // rep(i, h) {
    //   rep(j, w) printf("%+d", dist[i][j]);
    //   cout << endl;
    // }
    // cout << endl;
  }

  rep(i, h) {
    rep(j, w) {
      if (dist[i][j] == -1 && maze[i][j] == '#') {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void)
{
    int n, i, T = 0, H = 0;
    char s1[100], s2[100];
     
    scanf("%d", &n);
 
    for(i = 0; i < n; i++)
    {
 
        scanf("%s %s", s1, s2);
 
        if(strcmp(s1, s2) == 0)
        {
            T++;
            H++;
        }
        else if(strcmp(s1, s2) > 0)
        {
            T += 3;
        }
        else if(strcmp(s1, s2) < 0)
        {
            H += 3;
        }
    }
 
    printf("%d %d\n", T, H);
     
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int counter=0;
    if(s[0]=='1') ++counter;
    if(s[1]=='1') ++counter;
    if(s[2]=='1') ++counter;
    cout << counter << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(a < b) {
    if(a + v*t >= b + w*t) cout << "YES" << "\n";
    else cout << "NO" << "\n";
  }
  else {
    if(a - v*t <= b - w*t) cout << "YES" << "\n";
    else cout << "NO" << "\n";
  }
  return 0;
}


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

int main()
{
    int N, L;
    cin >> N >> L;
    string S[N];
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    sort(S, S + N);
    string ans = "";
    for (int i = 0; i < N; i++)
    {
        ans += S[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int Triangle(int side0,int side1,int side2) {
  int side[3];
  side[0]=side0;
  side[1]=side1;
  side[2]=side2;
  sort(side, side + 3, greater<int>());

  if(side[1]+side[2]<=side[0]){
    return 0;
  }
  return 1;
}

int main() {
  int i,j,k,N,L[100],c=0;
  cin >> N;
  for(i=0;i<N;i++){
   cin >> L[i];
  }
  for(i=0;i<N-2;i++){
    for(j=i+1;j<N-1;j++){
      if(L[i]==L[j]){continue;}
      for(k=j+1;k<N;k++){
        if(L[k]==L[i]||L[k]==L[j]){continue;}
        c+=Triangle(L[i],L[j],L[k]);
      }  
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3608
use std::io::Read;

fn solve(s: String) {
    let str: String = "A".to_string() + s.chars().nth(0).unwrap().to_string().as_str() + "C";
    println!("{}", str);
}
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let _a: String = iter.next().unwrap().parse().unwrap();
    let s: String = iter.next().unwrap().parse().unwrap();
    let _c: String = iter.next().unwrap().parse().unwrap();
    solve(s);
}

Measured memory_bytes: 4352
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll a(n); REP(i, n) cin >> a[i];
    vll acca(n + 1, 0);
    rep(i, 1, n + 1) acca[i] = acca[i - 1] + a[i - 1];

    map<ll, ll> sc;
    ll ans = 0;
    REP(i, n + 1) {
        ans += sc[(acca[i] - i) % k];
        sc[(acca[i] - i) % k]++;
        if (i >= k - 1) sc[(acca[i - k + 1] - (i - k + 1)) % k]--;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 2e5, LOG = 18;
int a[N];
int sp[N][LOG];
int plen[N + 1];

int getmin(int l, int r) {
  int len = plen[r - l + 1];
  return min(sp[l][len], sp[r - (1 << len) + 1][len]);
}

void solve() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sp[i][0] = a[i];
  }
  for (int i = 2; i <= n; i++) {
    plen[i] = plen[i / 2] + 1;
  }
  for (int lvl = 1; lvl < LOG; lvl++) {
    for (int i = 0; i + (1 << lvl) - 1 < n; i++) {
      sp[i][lvl] = min(sp[i][lvl - 1], sp[i + (1 << (lvl - 1))][lvl - 1]);
    }
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int l = 0, r = i - 1, ansl = i, ansr = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (getmin(mid, i - 1) > a[i])
        r = mid - 1, ansl = mid;
      else
        l = mid + 1;
    }
    l = i + 1, r = n - 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (getmin(i + 1, mid) > a[i])
        l = mid + 1, ansr = mid;
      else
        r = mid - 1;
    }
    ll cntl = i - ansl + 1, cntr = ansr - i + 1;
    ans += cntl * cntr * a[i];
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> a(N),b(N);
  for(int i(0);i<N;i++){
    cin>>a[i].second>>a[i].first;
  }
  for(int i(0);i<N;i++){
    cin>>b[i].first>>b[i].second;
  }
  sort(a.rbegin(),a.rend());
  sort(b.begin(),b.end());
  int ans(0);
  int used[100] = {0};
  for(int i(0);i<N;i++){
    for(int j(0);j<N;j++){
      if(a[j].second < b[i].first){
        if(used[j] == 0 && a[j].first < b[i].second){
          used[j] = 1;
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <vector <int> > g;
vector <vector <int> > g2;
vector <int> test;

 void bfs_all(int n);

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector <int> row;
    g.resize(n+1,row);
    g2.resize(n+1,row);
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for(int i=0;i<k;i++)
    {
        int u,v;
        cin>>u>>v;
        g2[u].push_back(v);
        g2[v].push_back(u);
    }

    test.resize(n+1);

    bfs_all(n);
    for(int i=1;i<=n;i++)
        cout<<test[i]<<" ";
    cout<<endl;




    return 0;   
}

void bfs_all(int n)
{
    vector <bool> visited;
    visited.resize(n+1,0);
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==1)
            continue;
        queue <int> q;
        q.push(i);
        set <int> s;
        set <int>::iterator it;
        visited[i]=1;
        s.insert(i);
        while(q.size()>0)
        {
            int x=q.front();
            q.pop();
            for(int i=0;i<g[x].size();i++)
            {
                if(visited[g[x][i]]==0)
                {
                    visited[g[x][i]]=1;
                    s.insert(g[x][i]);
                    q.push(g[x][i]);
                }
            }

        }

        for(it=s.begin();it!=s.end();it++)
        {
            int x=*it;
            test[x]=s.size()-1-g[x].size();
            for(int i=0;i<g2[x].size();i++)
                if(s.find(g2[x][i])!=s.end())
                    test[x]--;
        }

    }
}
 
 


Measured memory_bytes: 17272
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
        long long int temp=x/d;
        if(temp>=k)
        {
            long long int a=d*k;
            a=x-a;
            cout<<a;
            return 0;
        }
        long long int ppos=x%d;
        long long int npos=ppos-d;
        long long int leftp=k-temp;
        long long int leftn=leftp+1;
        if(abs(npos)>=abs(ppos))
        {
            if(leftp%2==0)
            {
                cout<<ppos;
            }
            else
            {
                cout<<abs(npos);
            }
        }
        else
        {
            if(leftn%2==0)
            {
                cout<<abs(npos);
            }
            else
            {
                cout<<ppos;
            }
        }
    
    
    

    return 0;
}


Measured memory_bytes: 3528
n, *h = map(int, open(0).read().split())

ans = 0
i = 0
while i < n:
    j = i
    while j + 1 < n and h[j] >= h[j + 1]:
        j += 1
    ans = max(ans, j - i)
    i = j + 1
print(ans)


Measured memory_bytes: 19852
S = input()

t = 'i'
for l in S:
    if t == 'h' and l == 'i':
        t = 'i'
    elif t == 'i' and l == 'h':
        t = 'h'
    else:
        print('No')
        exit()
            

if t == 'h':
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=998244353;
int main(){
  int64_t N,S;
  cin>>N>>S;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<vector<int64_t>>dp(N+1,vector<int64_t>(S+1,0));
  for(int64_t i=1;i<=N;i++)
    for(int64_t j=1;j<=S;j++){
    if(j<A[i-1])
      dp[i][j]=dp[i-1][j];
      else
        if(j==A[i-1])
          dp[i][j]=(dp[i-1][j]+i)%mod;
      else
        dp[i][j]=(dp[i-1][j]+dp[i-1][j-A[i-1]])%mod;
    }int64_t ans=0;
  for(int64_t i=1;i<=N;i++)
    ans=(ans+dp[i][S])%mod;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int N , Y ;
  cin >> N >> Y ;
  int a = -1 ; int b = -1 ; int c = -1 ;
  for(int i = 0 ; i<=N ; i++){
    for(int j = 0; i+j<=N ; j++){
      int k = N-i-j ;
      if(10000*i+5000*j+1000*k==Y){
        a = i ; b= j ; c = k ;
      }
    }
  }
  
  cout << a << ' ' << b << ' ' << c << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char s[110]; cin >> s;
	bool oddflag=true, evenflag=true;
	for(int i=0; s[i]!='\0' && s[i]!='\n'; i++){
		if(i%2==0 && s[i]=='L') oddflag=false;
		else if(i%2==1 && s[i]=='R') evenflag=false;
	}
	if(oddflag && evenflag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 45

int FIB[MAX] = {0};

int fibonacci(int n) {
	if (n == 0 || n == 1) {
		FIB[n] = 1;
	}
	if (FIB[n] != 0) {
		return FIB[n];
	}
	FIB[n] = fibonacci(n-2) + fibonacci(n-1);
	return FIB[n];
}

int main(void) {
	int n;
	scanf("%d", &n);
	printf("%d\n", fibonacci(n));

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (unsigned)!((int)0)
#define pb push_back
#define popb pop_back
#define elif else if
typedef long long ll;
typedef unsigned long long int ull;
int main()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <map>

using namespace std;

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

    vector<string> str(n);
    string s;
    map<string, int> dic;
    int max = 0;
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (dic[s] != 0)
        {
            dic[s]++;
            if (dic[s] > max)
            {
                max = dic[s];
            }
        }
        else
        {
            dic[s] = 1;
            if (dic[s] > max)
            {
                max = dic[s];
            }
            str[j] = s;
            j++;
        }
    }

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

    for (int i = 0; i < str.size(); i++)
    {
        if (dic[str[i]] == max)
        {
            cout << str[i] << endl;
        }
    }

    return 0;
}

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

int main() {
  int a, b, c, d;
  int left, right;
  cin >> a >> b >> c >> d;
  left = a + b;
  right = c + d;
  if ( left > right ) cout << "Left" << endl;
  else if ( left < right ) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations

def main():
    N, M = map(int, input().split())
    g = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    ans = 0
    for route in permutations(range(2, N + 1), N - 1):
        ok = True
        now = 1
        for r in route:
            if r in g[now]:
                now = r
            else:
                ok = False
        if ok:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
	int x,y,n,temp;
	scanf("%d %d",&x,&y);
	if( x > y){temp=x;x=y;y=temp;}
	if(x==y){printf("%d\n",x);return 0;}
	for(n=y%x;n>=1;n--){
		if(x%n==0 && y%n==0){break;}
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,i;
	cin>>a>>b;
	for(i=b*10;i<b*10+10;i++){
		if((i*8)/100==a){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
nums = sorted(list(map(int,input().split())))
ans = 0

if (nums[1] - nums[0]) % 2 == 1:
    nums[0] += 1
    nums[2] += 1
    ans += 1
while nums[0] != nums[1]:
    nums[0] += 2
    ans += 1
while nums[0] != nums[2]:
    nums[0] += 1
    nums[1] += 1
    ans += 1

print(ans)

Measured memory_bytes: 3064
N = int(input())
P = []
for i in range(N):
  P.append(int(input()) - 1)

A = [0] * N
for i in range(N):
  A[P[i]] = i

ans,cnt = 0,0
work = -1
for i in range(N):
  if work < A[i]:
    cnt += 1
    ans = max(ans, cnt)
  else:
    cnt = 1
  work = A[i]

print(N-ans)

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

ll attack(ll h) {
	if (h == 1) return 1;
	else return 1 + attack(h/2) * 2;
}

int main() {
	
	ll H; cin >> H;
	cout << attack(H);

	return 0;
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
mod = 10**9 + 7
def fact(x):
  ret = 1
  for i in range(1, x+1):
    ret = ret * i % mod
  return ret
if n == m:
  print(fact(n)**2 * 2 % mod)
elif n+1 == m or n-1 == m:
  print(fact(n) * fact(m) % mod)
else:
  print(0)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	vector<int>vec;
	for (int i = 0; i < 3; ++i) {
		int tmp; cin >> tmp;
		vec.push_back(tmp);
	}
	sort(vec.begin(), vec.end());
	int big = vec[2];
	int d0 = big - vec[0];
	int d1 = big - vec[1];
	if ((d0 - d1) % 2 == 0) {
		cout << (d0 - d1) / 2 + d1 << endl;
	}
	else {
		//d0++;
		d1++;

		cout << 1 + (d0 - d1) / 2 + d1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;

int main() {
	cin >> N;
	cout << beki(N, 3) << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var str=Arr.shift();
   if(str=="#")break;
   var p="A";
   for(var i=0;i<str.length;i++){
      var s=str[i]-0;
      if(p=="A" && s===0)p="X";
      else if(p=="A" && s===1)p="Y";
      else if(p=="B" && s===0)p="Y";
      else if(p=="B" && s===1)p="X";
      else if(p=="W" && s===0)p="B";
      else if(p=="W" && s===1)p="Y";
      else if(p=="X" && s===0)p="";
      else if(p=="X" && s===1)p="Z";
      else if(p=="Y" && s===0)p="X";
      else if(p=="Y" && s===1)p="";
      else if(p=="Z" && s===0)p="W";
      else if(p=="Z" && s===1)p="B";
   }
   console.log((p=="B")?"Yes":"No");
}

Measured memory_bytes: 7648
N = int(input())
h = list(map(int, input().split()))
     
dp = [10**9]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
     
for i in range(2, N):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
     
print(dp[N-1])

Measured memory_bytes: 13924
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, l;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> l;
    int ans = 0;
    if (l + n - 1 < 0)
    {
        for (int i = l; i < n + l - 1; i++)
        {
            ans += i;
        }
    }
    else if (l <= 0)
    {
        for (int i = l; i <= n + l - 1; i++)
        {
            ans += i;
        }
    }
    else
    {
        for (int i = l + 1; i <= n - 1 + l; i++)
        {
            ans += i;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    N = int(input())
    S = [None] * N
    for i in range(N):
        S[i] = input()
    
    S = sorted(S)

    ans = 1
    for i in range(1, N):
        if S[i] != S[i-1]:
            ans += 1
    
    return ans


print(main())


Measured memory_bytes: 25560
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = getLine >> solve <$> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: [Int] -> Int
solve = fst . foldl f (0, 0)
  where
    f (tc, mh) a
      | mh <= a = (tc, a)
      | otherwise = (tc + mh - a, mh)

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


Measured memory_bytes: 10252
main(n){while(scanf("%d",&n),n){int m[15][15]={0},x=n/2,y=n/2+1,c;for(c=0;c<n*n;m[x++%n][y++%n]=++c)for(;m[x%n][y%n];y++)x--;for(y=0;y<n;y++,printf("\n"))for(x=0;x<n;x++)printf("%4d",m[x][y]);}exit(0);}

Measured memory_bytes: 0
s=list(input())

n=1
yes=True
for i in s:
	if n%2!=0:
		if (i=="R" or i=="U" or i=="D"):
			pass

		else:
			yes=False

	else:
		if  (i=="L" or i=="U" or i=="D"):

			pass
		else:
			yes=False
	n+=1

if yes:
	print("Yes")

else:
	print("No")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n = s.size();
    if(s[n-1]=='s')
    {
        s+='e';
        s+='s';
    }
    else
    {
        s+='s';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    lli N = n;
    string s;
    while(n != 0){
        lli r = n%2;
        if(r < 0) r+=2;
        n=(n-r)/(-2);
        s = char('0'+r)+s;
    }
    lli f = 0;
    lli g = 1;
    for(int i = s.size()-1; i >= 0; i--){
        if(s[i] == '1') f+=g;
        g*=-2;
    }
    assert(N==f);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3608
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function abmp(a,b,p)
	if b == 0
		1
	elseif b%2 == 0
		k = abmp(a,div(b,2),p)
		(k*k)%p
	else
		(a*abmp(a,b-1,p))%p
	end
end
function binarr(n,p)
	z = 1
	for i in 1:n
		z = z*i%p
	end
	fac = Array{Int}(n+1)
	inv = Array{Int}(n+1)
	inv[n+1] = abmp(z,p-2,p)
	for i in 0:n-1
		inv[n-i] = (inv[n+1-i]*(n-i))%p
	end
	for i in 0:n
		fac[i+1] = (((z*inv[i+1])%p)*inv[n+1-i])%p
	end
	fac
end

function euc(a,m)
	b = m
	x = 1
	u = 0
	while b>0
		q = div(a,b)
		tmp = u
		u = x-q*u
		x = tmp
		tmp = b
		b = a-q*b
		a = tmp
	end
	x<0?x+abs(m):x
end

function main()
	mod = 10^9+7
	n = readline() |> parseInt
	e = [Int[] for i in 1:n]
	for i in 1:n-1
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
	end
	layer = -ones(Int,n)
	layer[1] = 0
	stack = Int[1]
	head = zeros(Int,n)
	while !isempty(stack)
		now = shift!(stack)
		for i in e[now]
			if layer[i]<0
				layer[i] = layer[now] + 1
				push!(stack,i)
			else
				head[now] = i
			end
		end
	end
	ls = Tuple{Int,Int}[(layer[i],i) for i in 1:n]
	ls = sort(ls,by=x->x[1],rev=true)
	d = zeros(Int,n)
	da = [Int[] for i in 1:n]
	for i in 1:n-1
		u = ls[i][2]
		push!(da[head[u]],d[u]+1)
		d[head[u]] += d[u]+1
	end
	ct = zeros(Int,n)
	bt = zeros(Int,n+1)
	bt[1] = 1
	for i in 1:n
		bt[i+1] = (bt[i]*2)%mod
	end
	z = 1
	if length(da[1])>1
		for j in da[1]
			z = (z+bt[j+1]-1)%mod
		end
		ct[1] = (bt[n]-z+mod)%mod
	end
	for i in 2:n
		if !isempty(da[i])
			s = 0
			z = 1
			for j in da[i]
				s += j
				z = (z+bt[j+1]-1)%mod
			end
			z = (z+bt[n-s]-1)%mod
			ct[i] = (bt[n]-z+mod)%mod
		end
	end
	x = euc(bt[n+1],mod)
	println(((sum(ct)%mod)*x)%mod)
end

main()

Measured memory_bytes: 197680
#include <stdio.h>
#define N 200
int main(void){
  char a[N]={0},b[N]={0},c[N]={0};
  int i,n,ct=0;
  scanf("%d",&n);
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  for(i=0;i<n;i++){
    if(a[i]==b[i]){
      if(b[i]!=c[i]){
        c[i]=b[i];
        ct++;
      }
    }else if(a[i]==c[i]){
      b[i]=a[i];
      ct++;
    }else if(b[i]==c[i]){
      a[i]=b[i];
      ct++;
    }else{
      b[i]=a[i];
      c[i]=a[i];
      ct+=2;
    }
  }
  printf("%d\n",ct);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
	     Scanner sc = new Scanner(System.in);
	     int n = sc.nextInt();
	     if(n == 1){
	     	System.out.println("Hello World");
	     }else{
	     	int a = sc.nextInt();
	     	int b = sc.nextInt();
	     	System.out.println(a + b);
	     }
	}
}

Measured memory_bytes: 21204