akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class segTree{
    public:
    vector<ll>data;
    vector<ll>sub;
    vector<ll>left;
    vector<ll>right;
    ll offset;
    segTree(ll n, ll initValue = 0){
        offset = 1;
        while(offset < n + 1)offset <<= 1;
        data = vector<ll>(offset * 2, initValue);
        sub = vector<ll>(offset * 2, 0);
        left = vector<ll>(offset * 2, 0);
        right = vector<ll>(offset * 2, 0);
        for(ll i = 0; i < offset; i++){
            left[offset + i] = i;
            right[offset + i] = i;
        }
        for(ll i = offset - 1; i > 0; i--){
            left[i] = left[2 * i];
            right[i] = right[2 * i + 1];
        }
        // cout << offset << endl;
    }
    void add(ll l, ll r, ll x, ll p = 1){
        if(l <= left[p] && right[p] <= r){
            sub[p] += x;
        }
        else if(right[p] < l)return;
        else if(r < left[p])return;
        else if(p < offset){
            add(l, r, x, p * 2);
            add(l, r, x, p * 2 + 1);
        }
    }
    ll get(ll p, ll offsetFlg = 1){
        if(offsetFlg)p += offset;
        // cout << "*" << p << endl;
        if(p > 1)get(p / 2, 0);
        if(left[p] < right[p]){
            add(left[p], right[p], sub[p], p * 2);
            add(left[p], right[p], sub[p], p * 2 + 1);
        }
        else data[p] += sub[p];
        sub[p] = 0;
        return data[p];
    }
    void show(){
        cout << "-----" << endl;
        for(ll i = 1; i < offset * 2; i++){
            if(i >= offset)cout << "[" << i << ", " << i - offset << "](" << data[i] << ", " << sub[i] << ") ";
            else cout << "[" << i << "](" << data[i] << ", " << sub[i] << ") ";
            int flg = 1;
            for(ll tmp = i + 1;tmp;tmp /= 2){
                if((tmp & 1) && (tmp > 1))flg = 0;
            }
            if(flg)cout << endl;
        }
        cout << "+++++" << endl;
    }
};

int main(){

    ll N, Q;
    cin >> N >> Q;
    segTree tree(N);
    for(ll i = 0; i < Q; i++){
        // cout << "case :" << i << endl;
        ll q;
        cin >> q;
        if(q == 0){
            ll s, t, x;
            cin >> s >> t >> x;
            tree.add(s, t, x);
        }
        else{
            ll x;
            cin >> x;
            cout << tree.get(x) << endl;
        }
        // tree.show();
    }

    return 0;
}


Measured memory_bytes: 10944
r = a = o = 0
while gets
	x, y, z = $_.split.map &:to_i
	break if x+y<=z || y+z<=x || z+x<=y
	cos = (1..3).map{
		tmp = (x*x + y*y - z*z).to_f/(2*x*y) 
		x, y, z = y, z, x
		tmp
	}
	if cos.any?{|x| x < 0}
		o += 1
	elsif cos.all?{|x| x > 0}
		a += 1
	else
		r += 1
	end
end
puts [r+a+o, r, a, o].join(" ")

Measured memory_bytes: 6124
#include<bits/stdc++.h>
using namespace std;
map<int,int> s[2];
int n,a[200001];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),s[i&1][a[i]]++;
	multimap<int,int> m[2];
	m[0].insert({0,-1});
	m[1].insert({0,-1});
	for(int i=0;i<2;i++)
		for(auto x:s[i])m[i].insert({x.second,x.first});
	auto i=m[0].rbegin(),j=m[1].rbegin(),k=i,l=j;k++;l++;
	if(i->second!=j->second)return printf("%d\n",n-i->first-j->first),0;
	printf("%d\n",n-max(i->first+l->first,j->first+k->first));
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	if(n>29){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

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

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const long long MOD = 998244353;
const int K = 1001000;

long long d[K];
vector<int> divs[K];
long long cnt[K];
long long ans, s;

long long inq(long long x, long long y)
{
    if (y == 0) return 1;
    long long l = inq(x, y / 2);
    if (y % 2) return l * l % MOD * x % MOD;
    return l * l % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for (int i = 1; i < K; i++)
    {
        for (int j = 2; j * i < K; j++)
        {
            divs[i * j].push_back(i);
        }
    }
    d[1] = 1;
    for (int i = 2; i < K; i++)
    {
        d[i] = inq(i, MOD - 2);
        for (auto kek : divs[i])
        {
            d[i] = (d[i] + MOD - d[kek]) % MOD;
        }
    }
    int n, a;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a, cnt[a]++, s += a;
    for (int lc = 1; lc < K; lc++)
    {
        long long a = 0;
        for (int i = lc; i < K; i += lc)
        {
            a += cnt[i] * i;
            a %= MOD;
        }
        ans = (ans + a * a % MOD * d[lc]) % MOD;
    }
    ans = (ans - s + MOD * MOD) % MOD;
    cout << ans * inq(2, MOD - 2) % MOD << endl;
}


Measured memory_bytes: 130560
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return "".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a = l()

dp = [[0 for i in range(a[1])] for j in range(a[0])]

for i in range(a[0]):
    po = 0
    if i > a[3]-1:
        po = 1

    for j in range(a[1]):
        ppo = po
        if j > a[2] - 1:
            ppo ^= 1
        dp[i][j] = ppo
for i in range(a[0]):
    print(jo(dp[i]))






Measured memory_bytes: 13296
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class BIT {
	int n;
	vector<ll> node;
public:
	BIT(int N) {
		n = N;
		node.resize(n + 1);
	}

	void add(int i, ll x) {
		for (++i;i <= n;i += (i&-i)) {
			node[i] += x;
		}
	}

	ll sum(int i) {
		ll s = 0;
		for (++i;i > 0;i -= (i&-i)) {
			s += node[i];
		}
		return s;
	}
};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, D, A;
	cin >> N >> D >> A;
	vector<pair<ll, ll>> XH(N);
	REP(i, N) cin >> XH[i].first >> XH[i].second;
	SORT(XH);
	vector<ll> X(N), H(N);
	REP(i, N) tie(X[i], H[i]) = XH[i];
	BIT bit(N);
	int r = 1;
	ll res = 0;
	REP(l, N) {
		H[l] -= bit.sum(l);
		if (H[l] <= 0) continue;
		ll iter = (H[l] + A - 1) / A;
		res += iter;
		ll d = iter * A;
		bit.add(l, d);
		if (r <= l) r = l + 1;
		while (r < N && X[r] - X[l] <= 2 * D) ++r;
		if (r < N) bit.add(r, -d);
	}
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int x = kb.nextInt();
		int y = kb.nextInt();
		boolean e = false;
		int a = x * 2 - 2;
		for (int i = 0; i < x+1; i++) {
			a += 2;
			if (a == y) {
				e = true;
				break;
			}
		}
		if (e == false)
			System.out.println("No");
		else
			System.out.println("Yes");
		kb.close();
	}

}


Measured memory_bytes: 27040
package main

import "fmt"

func main() {
	var n, a, b, count int
	fmt.Scan(&n, &a, &b)

	if a == 0{
		count = 0
	}else if a >= n{
		count = n
	}else if a < n{
		if (n % (a+b)) > a{
			count = a * (n / (a+b)) + a
		}else{
			count = a * (n / (a+b)) + (n % (a+b))
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
#include <stdio.h>
using namespace std;
int a, b;
char s[105][105];
int main() {
	scanf("%d %d", &a, &b);
	a --, b --;
	for (int i = 1; i <= 50; i ++)
		for (int j = 1; j <= 100; j ++)
			s[i][j] = '.';
	for (int i = 51; i <= 100; i ++)
		for (int j = 1; j <= 100; j ++)
			s[i][j] = '#';
	for (int i = 1; b; i += 2)
		for (int j = 1; j <= 100 && b; j += 2)
			s[i][j] = '#', b --;
	for (int i = 100; a; i -= 2)
		for (int j = 100; j >= 1 && a; j -= 2)
			s[i][j] = '.', a --;
	printf("100 100\n");
	for (int i = 1; i <= 100; i ++)
		printf("%s\n", s[i] + 1);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	char ch[3];
	rep(i, 3)cin >> ch[i];
	string s(ch, 3);
	cout << (stoi(s) % 4 == 0 ? "YES" : "NO") << "\n";

	return 0;
}

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

int main()
{
   int n;
   cin>>n;
   ll a[n];ll b[n];
   for(int i=0;i<n;i++)cin>>a[i];
   int k=-1;
   for(int i=0;i<n;i++)
   {
       k++;
       b[k]=a[i];
       while((k>=2)&&(b[k-1]>=b[k-2])&&(b[k-1]>=b[k]))
       {
               b[k-2]=b[k-2]+b[k]-b[k-1];
               k-=2;
       }
   }
   int i=0, j=k, turn=0;
   ll ans=0;
   while(i<=j)
   {
       if(b[i]>=b[j])
       {
         if(!turn)
         {
             ans+=b[i];
             turn=1;
         }
         else
         {
             ans-=b[i];
             turn=0;
         }
         i++;
       }
       else
       {
         if(!turn)
         {
             ans+=b[j];turn=1;
         }
         else
         {
             ans-=b[j];turn=0;
         }
         j--;
       }
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3656
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] aS = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int count = 0;
            for(int i = 0; i < aS.Length; i += 2)
            {
                if(aS[i] % 2 ==1)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()

int main() {
    int N;
    cin >> N;
    if (N % 1000 == 0) {
        cout << 0 << endl;
    }else {
        cout << 1000 - N % 1000 << endl;
    }
    return 0;
}

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

ll INF = 1001001001;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{

    int h, w;
    cin >> h;
    cin >> w;
    vector<string> s(h);
    REP(i, h)
    cin >> s[i];
    int ans = 0;

    REP(si, h)
    REP(sj, w)
    {
        if (s[si][sj] == '#')
            continue;
        queue<P> q;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF)
                return;
            dist[i][j] = x;
            q.push(P(i, j));
        };

        update(si, sj, 0);

        while (!q.empty())
        {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            REP(dir, 4)
            {
                int ni = i + di[dir], nj = j + dj[dir];
                if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                    continue;
                if (s[ni][nj] == '#')
                    continue;
                update(ni, nj, dist[i][j] + 1);
            }
        }
        REP(i, h)
        REP(j, w)
        {
            if (dist[i][j] == INF)
                continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
static inline int Root(int x,UnionFind *uf)
{
  if(uf[x].Parent==x)return x;
  else return uf[x].Parent=Root(uf[x].Parent,uf);
}
static inline int Unite(int x,int y,UnionFind *uf)
{
  x=Root(x,uf),y=Root(y,uf);
  if(x==y)return 0;
  uf[x].Parent=y;uf[y].Rank+=uf[x].Rank;return 1;
}
static inline int Size(int x,UnionFind *uf){return uf[Root(x,uf)].Rank;}
static inline int Belong(int x,int y,UnionFind *uf){return Root(x,uf)==Root(y,uf);}
int main(void)
{
  int A,B,C,D,N,M,K;
  if(scanf("%d %d %d",&N,&M,&K)==1)scanf("%d %d %d",&N,&M,&K);
  int known[N];
  UnionFind uft[N];
  for(int i=0;i<N;i++){known[i]=0;uft[i].Parent=i;uft[i].Rank=1;}
  while(M--)
  {
    if(scanf("%d %d",&A,&B)==1)scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B,uft);
  }
  while(K--)
  {
    if(scanf("%d %d",&C,&D)==1)scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D,uft))known[C]++,known[D]++;
  }
  for(int i=0;i<N;i++){printf("%d ",Size(i,uft)-known[i]-1);}
  return printf("\n"),0;
}

Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int N=1e5+11;
using ii=pair<int,int>;
vector<ii> g[N];
int color[N],n;
void dfs(int curr,int par,int c){
   color[curr]=c;
   for(auto it:g[curr]){
	    if(it.f!=par)
		   dfs(it.f,curr,c^(it.s%2));
	   }	
}
void solve(){
  	cin>>n;
  	for(int i=0;i<n-1;i++){
	  int a,b,c;
	  cin>>a>>b>>c;
	  --a,--b;
	  g[a].push_back({b,c});
	  g[b].push_back({a,c});	
	}
	dfs(0,-1,0);
	for(int i=0;i<n;i++)cout<<color[i]<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


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

using namespace std;

const double EPS = 1e-9;

inline bool is_in(double a, double b, double x) {
	if (a > b) {
		swap(a, b);
	}
	return (a - EPS <= x && x <= b + EPS);
}

struct point {
	double x, y;
	point() {}
	point(double _x, double _y) : x(_x), y(_y) {}
};

inline bool is_in(point A, point B, point P) {
	return (is_in(A.x, B.x, P.x) && is_in(A.y, B.y, P.y));
}

void read(point &P) {
	cin >> P.x >> P.y;
}

point operator + (const point &P, const point &Q) {
	return point(P.x + Q.x, P.y + Q.y);
}

point operator - (const point &P, const point &Q) {
	return point(P.x - Q.x, P.y - Q.y);
}

point operator * (const point &P, const double k) {
	return point(P.x * k, P.y * k);
}

point operator / (const point &P, const double k) {
	assert(fabs(k) > EPS);
	return point(P.x / k, P.y / k);
}

inline double dot(const point &P, const point &Q) {
	return P.x * Q.x + P.y * Q.y;
}

inline double cross(const point &P, const point &Q) {
	return P.x * Q.y - P.y * Q.x;
}

inline double norm2(const point &P) {
	return dot(P, P);
}

inline double norm(const point &P) {
	return sqrt(dot(P, P));
}

inline double dist2(const point &P, const point &Q) {
	return norm2(P - Q);
}

inline double dist(const point &P, const point &Q) {
	return norm(P - Q);
}

inline point project(const point &P, const point &P1, const point &P2) {
	return P1 + (P2 - P1) * (dot(P2 - P1, P - P1) / norm2(P2 - P1));
}

inline point reflect(const point &P, const point &P1, const point &P2) {
	return project(P, P1, P2) * 2.0 - P;
}

inline point intersect(const point &A, const point &B, const point &C, const point &D) {
	return A + (B - A) * (cross(C - A, C - D) / cross(B - A, C - D));
}

inline point rotate_point(const point &P, double angle) {
	return point(P.x * cos(angle) - P.y * sin(angle), P.y * cos(angle) + P.x * sin(angle));
}

inline pair <point, point> point_circle_tangent(const point &P, const point &C, const double r) {
	double d = dist(P, C);
	double l = sqrt(d * d - r * r);
	double a = asin(r / d);
	return make_pair(P + rotate_point((C - P) * (l / d), a), P + rotate_point((C - P) * (l / d), -a));
}

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

	point P, C;
	double r;

	cin >> P.x >> P.y >> C.x >> C.y >> r;

	pair <point, point> answer = point_circle_tangent(P, C, r);
	if (answer.first.x > answer.second.x || (answer.first.x == answer.second.x && answer.first.y > answer.second.y)) {
		swap(answer.first, answer.second);
	}
	cout << fixed << answer.first.x << " " << fixed << answer.first.y << "\n";
	cout << fixed << answer.second.x << " " << fixed << answer.second.y << "\n";
}

Measured memory_bytes: 3512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

counter = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x
visited = [0]*n


def dfs(parent):
    visited[parent] = 1
    for c in edges[parent]:
        if visited[c] == 1:
            continue
        else:
            counter[c] += counter[parent]
            dfs(c)


dfs(0)
print(*counter)

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

using namespace std;

int main(){

  vector<int> card(5);
  
  while(scanf("%d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4]) != EOF){
	bool judge_1p = false;
	bool judge_2p = false;
	bool judge_3 = false;
	bool judge_4 = false;
	bool judge_s = false;

	sort(card.begin(),card.end());
	
	for(int i=0;i<4;++i){
	  int count = 1;
	  for(int j=i+1;j<5;++j){
		if(card[i] == card[j]){
		  count++;
		  if(j == 4)
			i = j - 1;
		}
		else{
		  i = j - 1;
		  break;
		}
	  }
	  
	  if(count == 2){
		if(judge_1p == false)
		  judge_1p = true;
		else if(judge_1p == true)
		  judge_2p = true;
	  }
	  else if(count == 3)
		judge_3 = true;
	  else if(count == 4)
		judge_4 = true;
	  
	}

	if(card[0] == 1 && card[1] == 10 &&
	   card[2] == 11 && card[3] == 12 &&
	   card[4] == 13){
	  cout<<"straight"<<endl;
	  continue;
	} 
	
	for(int i=0;i<4;++i){
	  if(card[i] == card[i+1] - 1 && i == 3)
		judge_s = true;
		
	  else if(card[i] != card[i+1] - 1)
		break;
	}

	if(judge_4 == true)
	  cout<<"four card"<<endl;
	else if(judge_3 == true && judge_1p == true)
	  cout<<"full house"<<endl;
	else if(judge_3 == true)
	  cout<<"three card"<<endl;
	else if(judge_2p == true)
	  cout<<"two pair"<<endl;
	else if(judge_1p == true)
	  cout<<"one pair"<<endl;
	else if(judge_s == true)
	  cout<<"straight"<<endl;
	else
	  cout<<"null"<<endl;
  }
  
}



Measured memory_bytes: 3136
/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int dp[105][105];

int DP(int x,int y){

    if(x < 2 && y < 2) return 0;
    if(dp[x][y] != -1) return dp[x][y];

    int &ret = dp[x][y] = 0;

    for(int i=1;2*i<=x;i++)
    {
        if(DP(x-2*i,y+i) == 0)
            ret = 1;
    }

    for(int i=1;2*i<=y;i++)
    {
        if(DP(x+i,y-2*i) == 0)
            ret = 1;
    }

    return ret;

}

int main(){

    long long x,y;
    cin >> x >> y;

    if(x > y) swap(x,y);

    if(y >= x-1 && y <= x+1) P("Brown\n");

    else P("Alice\n");


/*
    memset(dp,-1,sizeof(dp));

    FOR(i,0,x)
        FOR(j,0,y)
            dp[i][j] = DP(i,j);

    FOR(i,0,x)
        FOR(j,0,y)
            P("%d %d %d\n",i,j,dp[i][j]);
*/
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(abc058_a(sc.nextInt(),sc.nextInt(),sc.nextInt()));
    }

    static String abc058_a(int a, int b, int c) {
        if (b - a == c - b) {
            return "YES";
        }
        return "NO";
    }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto solve = [&]() -> ll {
    ll A, B, C; cin >> A >> B >> C;
    if (A > B) swap(A, B);
    if (B > C) swap(B, C);
    ll x = (C - A) / 2;
    ll y = (C - B) / 2;
    A += 2 * x;
    B += 2 * y;
    ll c = 0;
    if (A < C) c++;
    if (B < C) c++;
    if (c == 0) return x + y;
    if (c == 2) return x + y + 1;
    return x + y + 2;
  };
  cout << solve() << endl;
  

  return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define llu unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int ele1,ele2,ele3;
    data() {}
    data(int a,int b,int c)
    {
        ele1=a,ele2=b,ele3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.ele1> b.ele1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;


int main()
{
    int t,tc=1;
	string a,b;
	cin>>a>>b;
	int l=a.length();
	int l2=b.length();
	int i,j;
	for(i=0;i<l2;i++){
		cout<<a[i];
		cout<<b[i];
	}
	for(j=i;j<l;j++){
		cout<<a[i];
	}
	NL;
	

    return 0;
}

/*




*/


Measured memory_bytes: 256
def insert(tree,node):
    parent=None
    child=root
    while child is not None:
        parent=child
        if node<child:child=tree[parent][0]
        else:child=tree[parent][1]
    if node<parent:tree[parent][0]=node
    else:tree[parent][1]=node


def In_order(node):
    if node is None:return
    In_order(tree[node][0])
    print(" {}".format(node), end="")
    In_order(tree[node][1])


def Pre_order(node):
    if node is None:return
    print(" {}".format(node), end="")
    Pre_order(tree[node][0])
    Pre_order(tree[node][1])


def find(x,key):
    while x is not None and key!=x:
        if key<x:x=tree[x][0]
        else:x=tree[x][1]
    return x


def parent_search(tree,node):
    parent=None
    child=root
    while child is not None and child!=node:
        parent=child
        if node<child:child=tree[parent][0]
        else:child=tree[parent][1]
    return parent


def getMinimum(node):
    while tree[node][0] is not None:
        node=tree[node][0]
    return node


def getSuccessor(node):
    if tree[node][1] is not None:
        return getMinimum(tree[node][1])
    target=parent_search(tree,node)
    while target is not None and node==tree[target][1]:
        node=target
        target=parent_search(tree,target)
    return target


def delete(tree,node):
    if tree[node][0] is None or tree[node][1] is None:target=node
    else:target=getSuccessor(node)

    if tree[target][0] is not None:child=tree[target][0]
    else:child=tree[target][1]

    child_parent=parent_search(tree,target)
    if target==tree[child_parent][0]:tree[child_parent][0]=child
    else:tree[child_parent][1]=child
    if target==node:
        del tree[node]
        return

    node_parent=parent_search(tree,node)
    if node==tree[node_parent][0]:tree[node_parent][0]=target
    else:tree[node_parent][1]=target
    tree[target]=tree[node]
    del tree[node]


n=int(input())
tree,root={},None
for i in range(n):
    order=input().split()
    if order[0]=="print":
        In_order(root);print()
        Pre_order(root);print()
    elif order[0]=="find":
        if find(root,int(order[1])) is not None:print("yes")
        else:print("no")
    elif order[0]=="delete":
        delete(tree,int(order[1]))
    elif order[0]=="insert":
        num=int(order[1])
        if root is None:
            root=num
            tree[root]=[None,None]
        else:
            tree[num]=[None,None]
            insert(tree,num)


Measured memory_bytes: 75144
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


A,B = MI()

print((B+A-3)//(A-1))


Measured memory_bytes: 62020
#include <iostream>
#include <functional>
#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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<char, int> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

// Returns nCr % p
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    double T, X;
    cin >> T >> X;
    ll count = 0;
    vector<ll> vec1();
    cout << T / X << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
if(x=='N')
	{m1=d2;m2=d6;m6=d5;m5=d1;
	}
if(x=='S')
	{m1=d5;m5=d6;m6=d2;m2=d1;
	}
if(x=='W')
	{m3=d6;m6=d4;m4=d1;m1=d3;
	}
if(x=='E')
	{m6=d3;m3=d1;m1=d4;m4=d6;
	}
*/
int main(){
//DICE input
int d1,d2,d3,d4,d5,d6;
int x1,x2,x3,x4,x5,x6;
int z1,z2,z3,z4,z5,z6;
cin>>x1>>x2>>x3>>x4>>x5>>x6>>z1>>z2>>z3>>z4>>z5>>z6;
d1=x1,d2=x2,d3=x3,d4=x4,d5=x5,d6=x6;
int m1,m2,m3,m4,m5,m6;
//END DICE input
int a,x,y;
//DICE replace original
d1=x1;d2=x2;d3=x3;d4=x4;d5=x5;d6=x6;
//END DICE replace
//memory replace
m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
//
for(int i3=0; i3<6 ; i3++)
	{
	for(int i2=0;i2<4;i2++)
		{
		m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
		m1=d2;m2=d6;m6=d5;m5=d1;
		d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
		if(z1==d1 && z2==d2 && z3==d3 && z4==d4 &&z5==d5 &&z6==d6) {cout<<"Yes"<<endl; break;}
		}
	if(z1==d1 && z2==d2 && z3==d3 && z4==d4 &&z5==d5 &&z6==d6) break;
	if(i3<3)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	if(i3==3)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m1=d2;m2=d6;m6=d5;m5=d1;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
	m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	if(i3==4)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
	m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	if(i3==5)
	cout<<"No"<<endl;
	}

return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int64_t k,n,c=0;
  cin>>s>>k;
  n=s.length();
  if(s.at(0)!='1') cout<<s.at(0)<<endl;
  else{
    while(c<n&&s.at(c)=='1') c++;
    if(k<=c) cout<<'1'<<endl;
    else cout<<s.at(c)<<endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair

using namespace std;

typedef pair<int, int> P;
typedef long long LL;
static const int INF = INT_MAX;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = b;

    if(a + b < c) cout << cnt + a + b + 1 << endl;
    else cout << cnt + c << endl;

    return 0;
}



Measured memory_bytes: 256
N=int(input())
W=list(map(int, input().split()))

S = sum(W)
l = 0
r = S

rrr = []
for i in range(N):
    rrr.append(r - l)
    l = sum(W[:i+1])
    r = S - l
print(min(map(abs, (rrr))))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MAX=210000;
const long long MOD=1000000007;

typedef long long ll;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

ll comb(ll n, ll k){ //nCk
    ll ans=1;
    for(ll i=n;i>n-k;i--){
        ans=ans*i%MOD;
    }
    for(ll i=1;i<=k;i++){
        ans=(ans*mod_pow(i,MOD-2))%MOD;
    }
    return ans;
}

int main(){
    int N,a,b; cin >> N >> a >> b;
    ll ans;
    ans=mod_pow(2,N)+2*MOD-(comb(N,a)+comb(N,b)+1);
    ans%=MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string a="CODEFESTIVAL2016";
	cin>>s;
	int q=16;
	for(int i=0;i<16;i++){
		q-=(a[i]==s[i])?1:0;
	}
	cout<<q<<endl;
	return 0; 
}


Measured memory_bytes: 256
# coding: utf-8

N,T = map(int,input().split())
moto=[]
mini = []
for i in range(N):
    c,t = map(int,input().split())
    if t<=T:
        mini.append(c)
if len(mini) >= 1:
    print(min(mini))
else:
    print("TLE")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define inf -100000000
#define ordered_set tree<pair<ll int,ll int>, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    ll int n,m;
    cin>>n>>m;
    ll int h[n+1];
    ll int i,x,y;
    ll int v[n+1]={0};
    ll int f[n+1]={0};
    for(i=1;i<=n;i++)
    {
    	cin>>h[i];
    }

    for(i=1;i<=m;i++)
    {
    	cin>>x>>y;
    	v[x]++;
    	v[y]++;
    	if(h[x]>h[y])
    		f[x]++;
    	else if(h[x]<h[y])
    		f[y]++;
    }
    ll int count=0;
    for(i=1;i<=n;i++)
    {
    	if(f[i]==v[i])
    	{
    		count++;
    	}
    }
    cout<<count<<endl;
}


Measured memory_bytes: 5968
import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())
E = [set() for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  E[a-1].add(b-1)
  E[b-1].add(a-1)

V = [-1 for _ in range(N)]
def dfs(u,count):
  V[u] = count
  for v in E[u]:
    if V[v] == -1:
      dfs(v,count+1)
dfs(0,0)
Path = []
v = N-1
while (v != 0):
  Path.append(v)
  for u in E[v]:
    if V[u] == V[v] -1:
      v = u
Path.append(0)
#print(Path)

def dfs2(u):
  visited[u] = True
  res = 1
  for v in E[u]:
    if not visited[v]:
      res += dfs2(v)
  return res
visited = [False for _ in range(N)]
for i in Path:
  visited[i] = True
fennec = 0
for i in range((len(Path)+1)//2):
  fennec += dfs2(Path[-i-1])
snuke = 0
for i in range(len(Path)//2):
  snuke += dfs2(Path[i])
#print(fennec,snuke)
print('Fennec' if fennec > snuke else 'Snuke')


Measured memory_bytes: 130132
#include <iostream>
#include <vector>
#include <stdlib.h>
#include<algorithm>
#include <stack>
#define INF 1000000
#define ll long long
using namespace std;

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz) : par(sz), siz(sz, 1LL) {
		for (ll i = 0; i < sz; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz) {
		par.resize(sz);
		siz.assign(sz, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool isSame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

int main()
{
	ll n,m,bl,br;
	int bnum;
	cin >> n >> m;
	stack<ll>ans;
	stack<pair<ll, ll>> b;
	pair<ll, ll> bb;
	UnionFind bri(n);

	ans.push(n * (n - 1) / 2);

	for (int i = 0; i < m; i++) {
		cin >> bl >> br;
		bb = make_pair(bl, br);
		b.push(bb);
	}

	for (int i = 0; i < m-1; i++) {
		bb = b.top();
		b.pop();
		if (bri.isSame(bb.first-1LL,bb.second-1LL)) {
			ans.push(ans.top());
		}
		else {
			if (ans.top() > bri.size(bb.first - 1LL) * bri.size(bb.second - 1LL)) {
				ans.push(ans.top() - bri.size(bb.first - 1LL) * bri.size(bb.second - 1LL));
			}
			else {
				ans.push(0);
			}
		}
		bri.merge(bb.first - 1LL, bb.second - 1LL);
	}

	for (int i = 0; i < m; i++) {
		cout << ans.top() << endl;
		ans.pop();
	}
	return 0;
}

Measured memory_bytes: 4480
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if (b > a):
    if (b + w * t > a + v * t):
        print("NO")
    else:
        print("YES")
else:
    if (b - w * t < a - v * t):
        print("NO")
    else:
        print("YES")

Measured memory_bytes: 9144
#![allow(non_snake_case)]
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        n:usize, k:i64,
        a: [i64; n]
    }
    let mut cnt = vec![0i64; 50];
    for &x in &a {
        for i in 0..50 {
            if (x >> i) & 1 > 0 {
                cnt[i] += 1;
            }
        }
    }
    let n = n as i64;
    let mut dp = vec![vec![-1, 0]; 51];
    for i in (0..50).rev() {
        if dp[i+1][0] >= 0 {
            dp[i][0] = dp[i+1][0] + (max(cnt[i], n - cnt[i]) << i);
        }
        if (k >> i) & 1 > 0 {
            dp[i][0] = max(dp[i][0], dp[i+1][1] + (cnt[i] << i));
            dp[i][1] = dp[i+1][1] + ((n - cnt[i]) << i);
        } else {
            dp[i][1] = dp[i+1][1] + (cnt[i] << i);
        }
    }
    println!("{}", dp[0].iter().max().unwrap())
}


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

int main() {
  int64_t n,a,b;
  cin>>n>>a>>b;

  int64_t sum = a+b;
  int64_t rb = n/sum;

  if(n-sum*rb >= a) cout<<a*rb+a<<endl;
  else cout<<a*rb + (n-sum*rb)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop pop_back()
#define sz size()
using namespace std;
typedef long long ll;
bool isPrime(ll n)
{
    if(n==1)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
        return false;
    return true;
}
unordered_map<ll,ll>mapp;
ll ma=-999,mi=100000000000,my=-999999999999999999,miy=100000000000;
///////////////////////////////////////////
ll cnt,n,m,x,y,i,j,k,l,r,d,in=-1,sum,in1=0;
string s,t;
ll a[1000],b[10];
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for(i=1;i<=m;i++){
        cin>>a[i];
        s+='0'+a[i];
    }
    for(i=n;;i++){
       x=i;
       t="";
       while(x!=0){
         t+=x%10+'0';
         x/=10;
       }
       reverse(t.begin(),t.end());
       for(j=0;j<s.sz;j++){
            cnt=0;
            for(ll ii=0;ii<t.sz;ii++){
                if(s[j]==t[ii]){
                    cnt=1;
                    break;
                }
            }
            if(cnt==1){
                break;
            }
       }
       if(cnt==0){
         cout<<t;
         return 0;
       }
    }
}




Measured memory_bytes: 256
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,d,a=map(int,readline().split())
    xh=[list(map(int,readline().split())) for _ in range(n)]
    xh.sort()
    x=[0]*n
    h=[0]*n
    for i in range(n):
        x[i],h[i]=xh[i][0],xh[i][1]

    dq=deque()
    now=0
    cnt=0
    for i in range(n):
        if i==0:
            cnt+=(h[i]+a-1)//a
            now+=(h[i]+a-1)//a*a
            dq.append([x[i]+2*d,now])
        else:
            while len(dq)!=0 and dq[0][0]<x[i]:
                tmp=dq.popleft()
                now-=tmp[1]
            if h[i]<=now:
                pass
            else:
                dq.append([x[i]+2*d,(h[i]-now+a-1)//a*a])
                cnt+=(h[i]-now+a-1)//a
                now+=(h[i]-now+a-1)//a*a

    print(cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 69556
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

S_f = [0]*(N+2)
S_b = [0]*(N+2)
for i in range(1,N+1):
    S_f[i]     = S_f[i-1]   + abs(A[i]-A[i-1])
    S_b[N-i+1] = S_b[N-i+2] + abs(A[N-i+1]-A[N-i+2])

for i in range(1,N+1):
    print(S_f[i-1]+S_b[i+1]+abs(A[i-1]-A[i+1]))

Measured memory_bytes: 17028
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define maxn 100005
#define maxm 100005
#define eps 1e-6
typedef long long ll;
using namespace std; 
const ll mod = 1e9 + 7;
inline int read(){
	int x = 0, f = 1;char ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
	return x * f;
}

int n ,m;
int f[200005],sum[200005],ans;
int getf(int x){return x==f[x]?x:f[x] = getf(f[x]);}
int main(){
	int i, j,u,v;
	n = read(), m =read();
	for(i = 1;i <=n;i++) f[i]=i;
	for(j = 1;j <=m;j++){
		u = read(),v=read();
		if(getf(u)==getf(v)) continue;
		f[getf(u)]=getf(v);
	}
	for(i = 1;i <= n;i++) sum[getf(i)]++,ans=max(ans,sum[getf(i)]);
	cout<<ans;
}
//

Measured memory_bytes: 10576
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception { new Main().run(); }
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a > b) System.out.println("a > b");
		else if (a < b) System.out.println("a < b");
		else System.out.println("a == b");
	}
}



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

int main(void)
{
    string S;
    int Q;
    cin >> S>> Q;
    vector<int> T(Q,0);
    vector<int> F(Q,0);
    vector<char> C(Q, 0);
    for(int i = 0; i < Q; i++){
        cin >> T[i];
        if(T[i] == 2){
            cin >> F[i] >> C[i];
        }
    }

    string head = "";
    string tail = "";
    vector<int> flip(Q, 0);
    int sum = 0;
    for(int i = 0; i < Q; i++){
        sum += T[Q - i - 1];
        sum %= 2;
        flip[Q - i - 1] = sum;
    }

    if(sum != 0){
        reverse(S.begin(), S.end());
    }

    for(int i = 0; i < Q; i++){
        if(T[i] == 2){
            if(F[i] == 1){
                if(flip[i] == 0){
                    head = C[i] + head;
                } else {
                    tail = tail + C[i];
                }
            } else {
                if(flip[i] == 0){
                    tail = tail + C[i];
                } else {
                    head = C[i] + head;
                }
            }
        }
    }

    cout << head + S + tail << endl;

    return 0;
}


Measured memory_bytes: 6900
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderB
{
    static void Main()
    {
        string s = Console.ReadLine();
        int n = s.Length;

        string s2 = s.Substring(0, (n - 1) / 2);
        string s3 = s.Substring((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);

        if(IsPalindrome(s) && IsPalindrome(s2) && IsPalindrome(s3))
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
    }

    private static bool IsPalindrome(string s)
    {
        for(int i = 0; i <= s.Length / 2; i++)
        {
            if(s.Substring(i, 1) != s.Substring(s.Length - i - 1, 1))
            {
                return false;
            }
        }
        return true;
    }
}

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


int main(void){
 int x,a,b;
 cin >> x >> a >> b;
 int count=0;
 
 for(int i=a; i<=b; i++){
     if(i%x==0) count ++;
 }
 
 if(count > 0) cout << "OK" <<endl;
 else cout << "NG" << endl;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  ll x[N];
  for (int i = 0; i < N; i++) scanf("%lld", x + i);

  ll ans = 1e18;
  for (int i = 0; i <= N - K; i++) {
    int l = i, r = i + K - 1;
    if (x[l] >= 0) {
      ans = min(ans, x[r]);
    } else if (x[r] < 0) {
      ans = min(ans, -x[l]);
    } else {
      ans = min(ans, -x[l] + (x[r] - x[l]));
      ans = min(ans, x[r] + (x[r] - x[l]));
    }
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024