akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

const double PI=4*atan(1.0);

void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

FILE *fp=stdout;
//#define RED_FILE

#ifdef RED_FILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

int n;
int d[11][3];
vector<int> times[11];


void PrintTime(int t){
	int h=t/3600;
	t%=3600;
	int m=t/60;
	t%=60;
	int s=t;
	fprintf(fp,"%02d:%02d:%02d",h,m,s);
}

int minMergine;
int st,ft;

void dfs(int idx,int lb,int ub){
	if(idx==n){
		if(minMergine>ub-lb){
			minMergine=ub-lb;
			st=lb;
			ft=ub;
		}
		else if(minMergine==ub-lb){
			if(st>lb){
				st=lb;
				ft=ub;
			}
		}
	}
	else{
		// ÅÍSðÂ\«ÆµÄÛµÄ¨­
		if(idx==0){
			for(int i = 0; i < times[idx].size(); i++){
				int nxt=times[idx][i];
				dfs(idx+1,nxt,nxt);
			}
		}
		else{
			// lb<=x<=ubÆÈéxª¶Ý·êÎA»êðIð
			int x=*lower_bound(times[idx].begin(),times[idx].end(),lb);
			if(x>=lb&&x<=ub)
				dfs(idx+1,lb,ub);
			// »ñ´¢µÈ¯êÎAubÉàÁÆàß¢ÍÍOÌvf©,lbÉàÁÆàß¢ÍÍOÌvfÌÇ¿ç©ðIð
			else{
				// lb closed elem
				int nid=lower_bound(times[idx].begin(),times[idx].end(),lb)-times[idx].begin();
				if(nid!=0)
					dfs(idx+1,times[idx][nid-1],ub);
				nid=upper_bound(times[idx].begin(),times[idx].end(),ub)-times[idx].begin();
				if(nid!=times[idx].size())
					dfs(idx+1,lb,times[idx][nid]);
			}
		}
	}
}

int main(){
//	fp=fopen("output.txt","w");
	while(cin>>n&&n!=0){
		minMergine=1000000000;
		for(int i = 0; i < 11; i++)times[i].clear();
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 3; j++)
				cin>>d[i][j];
		}
		//»ê¼êÌvÉÂ¢ÄAÃÈÔÌÆèûðñµÄ¨­
		for(int i = 0; i < n; i++){
			int a[3];
			for(int j = 0; j < 3; j++)
				a[j]=d[i][j];
			sort(a,a+3);
			do{
				// ÃÈÔð²×é
				for(int j = 0; j < 60; j++){
					int b;
					int sum=0;
					bool bad=false;
					for(int k = 0; k < 3; k++){
						int num=(a[k]+j+60)%60;
						if(k==0){
							sum+=num;
						}
						else if(k==1){
							sum+=num*60;
							b=num/12;
						}
						else{
							if(b!=num%5){
								bad=true;
								break;
							}
							sum+=(num/5)*3600;
						}
					}
					if(!bad)
						times[i].push_back(sum);
				}
			}while(next_permutation(a,a+3));
			sort(times[i].begin(),times[i].end());
		}
		dfs(0,0,0);
		PrintTime(st);
		fprintf(fp," ");
		PrintTime(ft);
		fprintf(fp,"\n");
//		for(int i = 0; i < n; i++)
//			cout<<times[i].size()<<endl;
//		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from math import gcd
A, B, C, D = map(int, input().split())
E = C*D//gcd(C, D)

c1 = (B//C)-((A+C-1)//C)+1
c2 = (B//D)-((A+D-1)//D)+1
c3 = (B//E)-((A+E-1)//E)+1
ans = B-A+1-c1-c2+c3

print(ans)


Measured memory_bytes: 9180
h, w = map(int,input().split())
a = [str(input()) for i in range(h)]

d_al = dict()

for ai in a:
    for aij in ai:
        if aij in d_al:
            d_al[aij] += 1
        else:
            d_al[aij] = 1

od = 0
a2 = 0

for i in d_al.values():
    if i%2 == 1:
        od += 1
    elif i%4 == 2:
        a2 += 1

if h%2==1 and w%2==1:
    if od == 1 and a2 <= (h+w-1)//2:
        print("Yes")
    else:
        print("No")
elif h%2==1:
    if od == 0 and a2 <= w//2:
        print("Yes")
    else:
        print("No")
elif w%2==1:
    if od == 0 and a2 <= h//2:
        print("Yes")
    else:
        print("No")
else:
    if od == 0 and a2 == 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9252
#include <cstdio>
#include <algorithm>
using ll = long long;
using namespace std;
int main(){
	ll n,k;scanf("%lld %lld",&n,&k);
	ll arr[n];
	for(ll i=0;i<n;i++){
			scanf("%lld",&arr[i]);
		}
	sort(arr,arr+n);
	ll total(0);
	for(ll i=0;i<=n-1-k;i++){
			total += arr[i];
		}
	printf("%lld",total);	
	return 0;
	}


Measured memory_bytes: 3288
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define replb(i,a,b) for(ll i=a;i>=b;i--)
#define repl(i,a,b) for(ll i=a;i<b;i++)
#define repit(arr)  for(auto it=arr.begin();it!=arr.end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set <int>
#define setl set <ll>
#define dseti set <int, greater <int> >
#define dsetl set <ll, greater <ll> >
#define mseti multiset <int>
#define msetl multiset <ll>
#define dmseti multiset <int, greater <int> >
#define dmsetl multiset <ll, greater <ll> >
#define sortA(arr)   sort(arr.begin(),arr.end())
#define ssort(arr) stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int gcd(int a,int b){
    if (a < b) swap(a, b);
    if (b == 0) return a;
    else return gcd(b, a % b);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll t,n,fl;cin>>n;int i=1;
    while(1){
        if(n<=(castl(pow(26,i)+0.5))){break;}
        n-=castl(pow(26,i)+0.5);
        i++;
    }
    if(n==(castl(pow(26,i)+0.5))){
        rep(j,0,i)cout<<'z';
    }
    else{
    repb(j,i-1,0){
        //cout<<(castl(pow(26,i)+0.5));
        fl=n%(castl(pow(26,j)+0.5))!=0;
        if(fl){cout<<char('a'+n/(castl(pow(26,j)+0.5)));n=(n%((castl(pow(26,j)+0.5))));}
        else {cout<<char('a'+n/(castl(pow(26,j)+0.5))-1);n=(castl(pow(26,j)+0.5));}
    }
    }
    return 0;
}

Measured memory_bytes: 4076
solve :: String -> String -> String -> Int
solve [] [] [] = 0
solve (a1:ax) (b1:bx) (c1:cx)
  | a1 == b1 && b1 == c1             =     solve ax bx cx
  | a1 == b1 || b1 == c1 || a1 == c1 = 1 + solve ax bx cx
  | otherwise                        = 2 + solve ax bx cx

main :: IO ()
main = do
  _ <- getLine
  a <- getLine
  b <- getLine
  c <- getLine
  print $ solve a b c

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<int> edge[100000];
int cnt[100000];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    edge[a - 1].eb(b - 1);
    cnt[b - 1]++;
  }

  queue<int> q;
  rep(i, n) if (cnt[i] == 0) q.push(i);

  vector<int> ans(n, 0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();

    rep(i, edge[u].size()) {
      int v = edge[u][i];
      if (--cnt[v] == 0) {
        q.push(v);
        ans[v] = u + 1;
      }
    }
  }

  rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 7040
/* 
Hey there stalker....
 
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ 
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
 
Like what you see?
*/
#include <bits/stdc++.h>
using namespace std;
 
#define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define ld long double
#define lli long long int
#define p_b push_back
#define m_p make_pair
#define fs first
#define sc second
#define all(x) x.begin(),x.end()
#define fr(i,a,n) for(lli i=a; i<n; i++)
#define fre(i,a,n) for(lli i=a; i<=n; i++)
const lli mod = 1e9 + 7;
/*****************************************************/
int main()
{
    fastIO
    lli n;
    cin>>n;
    lli i,a[n+1],b[n+1],c[n+1],dp[4][n+1];
    fre(i,1,n)
        cin>>a[i]>>b[i]>>c[i];
    dp[1][1]=a[1];
    dp[2][1]=b[1];
    dp[3][1]=c[1];
    for(i=2;i<=n;i++)
    {
        dp[1][i]=max(a[i]+dp[2][i-1],a[i]+dp[3][i-1]);
        dp[2][i]=max(b[i]+dp[1][i-1],b[i]+dp[3][i-1]);
        dp[3][i]=max(c[i]+dp[2][i-1],c[i]+dp[1][i-1]);
    }
    cout<<max(dp[1][n],max(dp[2][n],dp[3][n]));
    //cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
    return 0;
} 

Measured memory_bytes: 4992
#include<stack>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="AAA" || s=="BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int v[102];
int main()
{
    int n,k,i,rez,a,b,sum,kaux;
    scanf("%d%d",&n,&k);
    for(i=1; i<=n; i++)
        scanf("%d",&v[i]);
    rez=INT_MIN;
    for(a=0; a<=n; a++)
        for(b=0; b<=n && a+b<=k && n+1-b>a; b++)
        {
            vector <int> aux;
            sum=0;
            for(i=0; i<=a; i++)
            {
                sum+=v[i];
                if(i>0)
                    aux.push_back(v[i]);
            }
            for(i=0; i<=b; i++)
            {
                sum+=v[n+1-i];
                if(i>0)
                    aux.push_back(v[n+1-i]);
            }
            kaux=k-a-b;
            sort(aux.begin(),aux.end());
            for(auto it : aux)
            {
                if(!kaux || it>0)
                    break;
                sum-=it;
                kaux--;
            }
            rez=max(rez,sum);
        }
    printf("%d",rez);


    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
### ローリングハッシュ rolling hash
import random
# M = 10**9+7
# M = 1<<63 - 1
M = 92709568269121

b = random.choice(range(1,M))
def rhash_list(s):
    l = [chr(v) for v in range(ord("a"), ord("z")+1)]
    d = {c:i+2 for i,c in enumerate(l)}
    ans = 0
    v = 1
    l = [0]
    for item in s:
        ans += d[item]*v
        v *= b
        ans %= M
        v %= M
        l.append(ans)
    return l
l = rhash_list(s)
if len(set(s))==n:
    ans = 0
else:
    binv = pow(b,M-2,M)
    pows = [None]*(n+1)
    v = 1
    for j in range(n+1):
        pows[j] = v
        v *= binv
        v %= M
#         pow(binv,j,M)
    ans = 0
    from collections import defaultdict
    for i in range(n//2, 0, -1):
        d = defaultdict(list)
        for j in range(n-i+1):
            d[((l[j+i]-l[j])*pows[j])%M].append(j)
        for v in d.values():
            if v[0]+i<=v[-1]:
                ans = i
        if ans>0:
            break
print(ans)

Measured memory_bytes: 234436
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a;
    while(a%2==0){
      a/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> k(m,vector<int>(1,0));
  int ans=0;
  priority_queue<int, vector<int>, less<int>> q;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a>m)continue;
    k[a-1].push_back(b);
  }
  rep(i,m){
    rep(j,k[i].size()){
      int w=k[i][j];
      q.push(w);
    }
    if(q.size()>=1){
      ans+=q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 6976
#include<iostream>
#include<vector>

using namespace std;

int main(){
   int n, now, count = 0;

   cin >> n;
   vector<int> ve(n + 1);
   vector<int> memo(n + 1);

   for(int i = 1; i < n + 1; i++) cin >> ve[i];

   now = 1;
   while(now != 2){
      if(memo[now] == 1){
         count = -1;
         break;
      }else{
         memo[now]++;
         now = ve[now];
         count++;
      }
   }

   cout << count << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int h, w;
ll cost[205][205];

void warshall_floyd(int n){
    rep(k, n){
        rep(i, n){
            rep(j, n) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
    }
}

int main(){
    cin >> h >> w;

    rep(i, 205) rep(j, 205) {
        if (i == j) cost[i][j] = 0;
        else cost[i][j] = LINF;
    }

    rep(y, 10) rep(x, 10){
        int tmp;
        cin >> tmp;
        cost[y][x] = tmp;
    }
    warshall_floyd(10);
    ll ans = 0;
    rep(i, h * w){
        int a;
        cin >> a;
        if (a == -1) continue;
        ans += cost[a][1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A = sorted(li_input())

    if A == [5,5,7]:
        print("YES")
    else:
        print("NO")




main()


Measured memory_bytes: 4904
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
int N;
V L;
bool dbg = false;
void solve() {
    itn ans = 0;
    sort(all(L));
    FOR(i, 0, N) {
        FOR(j, i + 1, N) {
            int a = L[i];
            int b = L[j];
            auto s = ub(all(L), abs(a - b));
            auto e = lb(all(L), (a + b));
            int t = e - s;
            if (abs(a - b) < a)
                t--;
            if (abs(a - b) < b)
                t--;
            if (t > 0) {
                ans += t;
            }
        }
    }
    ans /= 3;
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N) {
        int l;
        cin >> l;
        L.pb(l);
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2];
  
	

	return 0;
}

Measured memory_bytes: 3568
N = int(input())
ans = "Yes"
x = 0
y = 0
t = 0
for i in range(N):
    t_i,x_i,y_i = map(int,input().split())
    x_i = abs(x_i-x)
    y_i = abs(y_i-x)
    t_i = abs(t_i-t)
    
    if x_i+y_i <= t_i and (x_i+y_i-t_i)%2 == 0:
        continue
    else:
        ans = "No"
    x = x_i
    y = y_i
    t = t_i

print(ans)

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

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

	if(a%2 != b%2)
    {
		cout<<"IMPOSSIBLE"<<endl;
	}

	else
	cout<<(a+b)/2<<endl;

    return 0;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i < N - 1; ++i) {
    for (ll j = 0; j < N; ++j) {
      ans = max(ans, abs(A.at(i) - A.at(j)));
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#define N 10005

int n;
int val[N];

signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&val[i]);
	int ans=0;
	for(int i=1;i<=n;i++){
		while(val[i]%2==0){
			ans++;
			val[i]/=2;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int n;
  int i;
  char x[10][100];
  double y[10];
  double sum=0;

  scanf("%d",&n );

  for(i=0;i<n;i++){
    scanf("%lf",&y[i]);
    scanf("%s",x[i]);
  }
  
  for(i=0;i<n;i++){
    if(strcmp(x[i],"BTC")==0){
      y[i]=y[i]*380000.0;
    }
    sum=sum+y[i];
  }
  printf("%.4f",sum);
  return 0;
}

Measured memory_bytes: 128
n,k = map(int, input().split())
ans = []
lis = []
for i in range(n):
    ans.append(1)

for i in range(k):
    d = int(input())
    lis = list(map(int, input().split()))
    for m in lis:
        ans[m-1] = 0

print(sum(ans))
        

    

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

using namespace std;
int main(){
  long n,m;
   cin >> n >> m;
  
  long res;
  
  if(m-2*n<0) res=m/2;
  else res=(n+(m-2*n)/4);  
  
 
cout << res << endl;

  
    
  
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int X=sc.nextInt();
        int T=sc.nextInt();
        
        int num1=N/X;
        if(N%X>=1){
            num1+=1;
        }
        
        int ans =num1*T;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35832
var
  N: string;
  K: Integer;
  A: Integer;
  B: array[0..3] of Integer;
  T: Integer;
  I: Integer;
  J: Integer;
begin
  readln(N);
  read(K);

  A := 1;
  B[0] := 1;
  B[1] := Ord(N[1]) - 48 - 1;

  for I := 2 to Length(N) do
  begin
    T := Ord(N[I]) - 48;
    for J :=  K - 1 downto 0 do
    begin
      B[j + 1] := B[j + 1] + b[j] * 9;
    end;
    if T <> 0 then
    begin
      if A + 1 <= K then B[A + 1] := B[A + 1] + T - 1;
      if A <= K then Inc(B[A]);
      Inc(A);
    end;
  end;

  if A = K then writeln(B[K] + 1)
  else writeln(B[K]);
end.


Measured memory_bytes: 128
import sys
from collections import defaultdict
input = sys.stdin.readline


def main():
    N = int(input())
    d = defaultdict(lambda: 0)
    for _ in range(N):
        s = ''.join(sorted(input().strip()))
        d[s] += 1

    ans = 0
    for v in filter(lambda x: x > 1, d.values()):
        ans += (v - 1) * v // 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18228
from collections import deque

def main():
    N, *AB = map(int, open(0).read().split())

    E = [set() for _ in range(N + 1)]

    memo = {}
    for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
        E[a].add(b)
        E[b].add(a)
        memo[(a, b)] = i
        memo[(b, a)] = i

    K = max(len(e) for e in E)

    A = [""] * (N - 1)

    visited = [False] * (N + 1)

    Q = deque([(-1, 1)])
    visited[1] = True
    while Q:
        a, v = Q.popleft()
        c = 0
        for u in E[v]:
            E[u].remove(v)
            c += 1
            if c == a:
                c += 1
            Q.append((c, u))
            A[memo[(v, u)]] = str(c)
        E[v] = set()
    print(K)
    print("\n".join(A))

main()


Measured memory_bytes: 72344
// Ver19.02
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char a[11];
  scanf("%s", a);

  a[3] = '8';
  printf("%s\n", a);
  return 0;
}

Measured memory_bytes: 128
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

   
int main(){
	int N,K;
	string S;
	cin >> N >> K;
	cin >> S;
	if(S[K-1]=='A')S[K-1]='a';
	else if(S[K-1]=='B')S[K-1]='b';
	else if(S[K-1]=='C')S[K-1]='c';
	cout << S << endl;

}

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

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 llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    string T,S;
    cin >> S;
    cin >> T;

    int ls = S.length();
    int lt = T.length();

    int ans = iINF;

    rep(si,ls-lt+1){
        string subS = S.substr(si,lt);
        int tans=0;
        rep(i,lt) if(subS[i]!=T[i]) tans++;
        //cout << si << " : " << tans << endl;
        //cout << subS << " "  << T << endl;
        chmin(ans,tans);
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i){
        if (i % 2 == 0){
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int n; cin>>n;

	string s; cin>>s;

	
	int ans = 1;

	int i = 1;
	while(i <n) {
		if(s[i] != s[i-1]) {
			ans++;
		}
		i += 1;
	}

	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int mod = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n), y(n), a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		a[i] = x[i] - y[i];
		b[i] = x[i] + y[i]; 
	}

	int mx[2] = { -2010101010, -2010101010 }, mn[2] = { 2010101010, 2010101010 };
	for (int i = 0; i < n; i++) {
		mx[0] = max(mx[0], a[i]);
		mx[1] = max(mx[1], b[i]);
		mn[0] = min(mn[0], a[i]);
		mn[1] = min(mn[1], b[i]);
	}
	cout << max(mx[0] - mn[0], mx[1] - mn[1]) << endl;

	return 0;
}

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

using namespace std;

int main()
{
    long long n, i, j;

    cin >> n;

    for(i=1; i<=9; i++)
    {
        for(j=1; j<=9; j++)
        {
            if(i*j == n)
            {
                cout << "Yes\n";
                return 0;
            }
        }
    }

    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
A = gets.split.map(&:to_i)

def calc_conbination(n, m)
  m.times.inject(1){ |ele| ele * n % 1000000007 }
end

def pattern1
    A.sort.each_with_index do |v, i|
    if unmatch?(v, i, 1)
      puts 0
      exit
    end
  end
end

def pattern2
    A.sort.each.with_index(1) do |v, i|
    if unmatch?(v, i)
      puts 0
      exit
    end
  end
end

def unmatch?(v, i, n = 0)
  v != (i / 2) * 2 + n
end

(n % 2).zero? ? pattern1 : pattern2
p calc_conbination(2, n / 2)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int h, a;

int main() {
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long current = A[0];
  long ret = 1;
  long diff = 0;
  rep (i, N) {
    long tmpdiff = A[i] - current;
    if (tmpdiff * diff < 0) {
      ret++;
      diff = 0;
      current = A[i];
    } else {
      if (tmpdiff) diff = tmpdiff;
      current = A[i];
    }
  }
  cout << ret << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  ll S, x1, y1, x2, y2;
  cin >> S;
  if (S == 1'000'000'000'000'000'000ll) {
    x1 = 1e9; y1 = 0; 
    x2 = 0; y2 = 1e9;
  }
  else {
    x1 = 1e9;
    x2 = 1;
    y2 = 1+S/x1;
    y1 = 1e9 -S%x1;
  }
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << 0 << " " << 0 << endl; 
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, m, i, j, x;
    scanf("%d %d\n", &n, &m);
    int A[100][100]={}, B[100]={}, C[100]={};
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &x);
            A[i][j]=x;
        }
    }
    
    for(j=0; j<m; j++){
        scanf("%d", &x);
        B[j]=x;
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            C[i]=C[i]+A[i][j]*B[j];
        }
        printf("%d\n", C[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<pair<int64_t, int64_t>> a(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }

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

    const auto* delim = "";
    for (auto aa : a) {
        cout << delim << aa.second;
        delim = " ";
    }

    cout << endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,k;
	cin>>n>>k;
	vector<double> a(n);
	forn(i,n){
		double x;
		cin>>x;
		a[i]=(x+1)/2;
	}
	vector<double> ps={0};
	for(int i=0;i<n;i++) ps.emplace_back(ps.back()+a[i]);
	double ans=0;
	for(int i=0;i+k<=n;i++) ans=max(ans,ps[i+k]-ps[i]);
	cout<<fixed<<setprecision(7)<<ans;
    return 0;
}



Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a<=2){
		cout<<2<<endl;
		return 0;
	}
	for(int i=a&1?a:a+1;;i+=2){
		int qi=sqrt(i);
		bool flag=0;
		for(int j=3;j<=qi;j+=2)
			if(i%j==0){flag=1;break;}
		if(flag)continue;
		cout<<i<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N,X;
    N = sc.nextInt();
    X = sc.nextInt();
    Integer x[] = new Integer[N];
    for(int i=0; i<N; i++) x[i] = sc.nextInt();
    int ans = Math.abs(X - x[0]);
    int tmp;
    for(int i=1; i<N; i++){
      tmp = Math.abs(X - x[i]);
      ans = gcd(ans, tmp);
    }
    System.out.println(ans);
  }
  
  public static int gcd(int a, int b){
    if(a < b){
      int c = a;
      a = b;
      b = c;
    }
    if(a%b == 0) return b;
    return gcd(b, a%b);
  }
}



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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}

int cnt[200005];

int main()
{
    int n;
    scn(n);
    int a[n];

    for(int i=0; i<n; i++){
        scn(a[i]);
        cnt[a[i]]++;
    }

    int ans = 0;

    cnt[-1] = 0;

    for(int i=0; i<=100005; i++){

        ans = max(ans , cnt[i-1] + cnt[i+1] + cnt[i]);
    }
    cout<<ans;

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,x,ans=INT_MAX,v[20];
struct book{
	int c,a[20];
	inline bool operator<(const book&r)const{return c<r.c;}
}b[20];
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i].c);
		for(int j=1;j<=m;j++)scanf("%d",&b[i].a[j]);
	}
	sort(b+1,b+1+n);
	for(int i=0,cst=0;i<(1<<n);cst=0,i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++)
			if(i&(1<<j-1)){
				for(int k=1;k<=m;k++)v[k]+=b[j].a[k];
				cst+=b[j].c;
			}
		int flg=0;
		for(int j=1;j<=m;j++)
			if(v[j]<x){flg=1;break;}
		if(flg==0)ans=min(ans,cst);
	}
	printf("%d\n",ans==INT_MAX?-1:ans);
}

Measured memory_bytes: 3816
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> A,B,C,D;
    vector<ll> X,Y;//x,y index
    vector<pair<int,int>> RX,RY;//reverse x,y index
    vector<pair<int,int>>  I;// (x,y)
    vector<pair<int,int>>  F;// (x,y)
    
    rep(i,n){
        ll x,y;
        cin >> x>> y;
        X.push_back(x+y);
        Y.push_back(x-y);
    }
    sort(ALL(X));
    sort(ALL(Y));
    ll temp1=abs(X[0]-X[X.size()-1]);
    ll temp2=abs(Y[0]-Y[Y.size()-1]);
    ll ans=0;
    if(temp1>temp2){
        ans=temp1;
    }else{
        ans=temp2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6648
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}



signed main(){
    string N;
    cin >> N;
    cout << (N[0] == '7' || N[1] == '7' || N[2] == '7' ? YES : NO) << endl;
    return 0;
}


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

int main()
{
    int a,b,ans;
    string op;
    while(1)
    {
        cin >> a >> op >> b;
        if(op=="?")
        {
            return 0;
        }
        if(op=="+")
        {
            ans=a+b;
        }
        if(op=="-")
        {
            ans=a-b;
        }
        if(op=="/")
        {
            ans=a/b;
        }
        if(op=="*")
        {
            ans=a*b;
        }
        cout << ans <<endl;
    }
}


Measured memory_bytes: 3164
// https://atcoder.jp/contests/dp/tasks/dp_p
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;
ll dp[100010][2];
ll solve(vector<ll> v[], ll node, ll type, ll par)
{
    if (dp[node][type] != -1)
        return dp[node][type];
    dp[node][type] = 1;
    if (type == 1)
    {
        for (ll i = 0; i < (ll)v[node].size(); i++)
            if (v[node][i] != par)
                dp[node][type] = (dp[node][type] * solve(v, v[node][i], 0, node)) % mod;
    }
    else
    {
        for (ll i = 0; i < (ll)v[node].size(); i++)
            if (v[node][i] != par)
                dp[node][type] = (dp[node][type] * ((solve(v, v[node][i], 1, node) + solve(v, v[node][i], 0, node)) % mod)) % mod;
    }
    return dp[node][type];
}

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

    ll n, a, b;
    cin >> n;
    vector<ll> v[n + 1];
    for (ll i = 0; i < n - 1; i++)
    {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    memset(dp, -1, sizeof(dp));
    cout << (solve(v, 1, 0, -1) + solve(v, 1, 1, -1)) % mod << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

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 sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main(void){

  ll h, w;
  cin>>h>>w;
  char M[h][w];
  queue<pair<ll, ll>> q;
  ll V[h][w];

  REP(i, h){
    REP(j, w){
      char x;
      cin>>x;
      M[i][j] = x;
      V[i][j] = -1;
      if(x=='#'){
        V[i][j]++;
        q.push(make_pair(i, j));
      }
    }
  }

  ll d[4][2] = {{1,0}, {-1,0}, {0, 1}, {0, -1}};

  while(q.size()!=0){
    pair<ll, ll> now = q.front();
    q.pop();
    ll sx = now.first;
    ll sy = now.second;
  //.cout<<sx<<","<<sy<<endl;

    REP(i, 4){
      ll nx = sx + d[i][0];
      ll ny = sy + d[i][1];
      if(nx>=0 && ny>=0 && nx<h && ny<w && M[nx][ny]=='.' && V[nx][ny]==-1){
        q.push(make_pair(nx, ny));
        V[nx][ny] = V[sx][sy]+1;
        M[nx][ny] = '#';
      }
    }
  }
  ll ans = 0;
  REP(i, h){
    REP(j, w){
      //cout<<V[i][j];
      ans = max(V[i][j], ans);
    }
   // cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
  
}

Measured memory_bytes: 25396
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int r;
    cin >> r;
    ctn(3 * (r * r));
    return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <vector>

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        while(1){
            if(a[i]%2 != 0) break;
            a[i] /= 2;
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/dp/tasks/dp_d

ll dp[105][100005];

int main() {
  int N, W; cin >> N >> W;
  int w[N+1], v[N+1];
  REP(i, N) {
    int a, b; cin >> a >> b;
    w[i+1] = a;
    v[i+1] = b;
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= W; j++) {
      if (w[i] > j) {
        dp[i][j] = dp[i-1][j];
      }
      else {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
      }
    }
  }
  cout << dp[N][W] << "\n";

  return 0;
}


Measured memory_bytes: 81276
N = gets.to_i

foods = N.times.map { gets.split.map(&:to_i) }

foods.sort_by! { |a, b| -(a + b) }

sumA = 0
sumB = 0

N.times do |i|
  a, b = foods[i]

  if i.even?
    sumA += a
  else
    sumB += b
  end
end

puts sumA - sumB


Measured memory_bytes: 12664
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n;
double Heads[3002], Tails[3002];
double dp[3002][3002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> Heads[i], Tails[i] = 1.000000 - Heads[i];
    dp[0][0] = 1.0000000; // base case
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= n; ++j)
        {
            if(i + j >= n)
                continue;
            dp[i+1][j] += dp[i][j] * Heads[i+j+1];
            dp[i][j+1] += dp[i][j] * Tails[i+j+1];
        }
    double ans = 0.0000;
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j < i; ++j)
            if(i + j == n)
                ans += dp[i][j];
    cout << fixed << setprecision(15) << ans << '\n';
    return 0;
}


Measured memory_bytes: 70016
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

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

int main(void) {
    int m; cin >> m;
    cout << 24 - m + 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ll long long

const ll mod = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; ++i){
        ans *= i;
        if(ans>=(mod-9)){
            ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256