akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
vector<int> a[N], b[N];
int da[N], db[N];
int id[N], q[N << 1], dph[N << 1], dfn = 0;
int dp[N << 1][20], lg2[N << 1];
int n, x, y;
void dfsb(int x, int fx) {
    id[x] = ++dfn;
    q[dfn] = x;
    db[x] = db[fx] + 1;
    dph[dfn] = db[x];
    for (int y : b[x]) {
    	if (y == fx) continue; 
        dfsb(y, x);
        q[++dfn] = x;
        dph[dfn] = db[x];
    }
}
void RMQ_init(int n) {
    for (int i = 2; i <= n; i++) lg2[i] = lg2[i / 2] + 1;
    for (int i = 1; i <= n; i++) dp[i][0] = i;
    for (int j = 1; (1 << j) <= n; j++) {
        for (int i = 1; i + (1 << j) - 1 <= n; i++) {
            int a = dp[i][j - 1], b = dp[i + (1 << (j - 1))][j - 1];
            dp[i][j] = dph[a] <= dph[b] ? a : b;
        }
    }
}
int RMQ_min(int L, int R) {
    if (L > R) swap(L, R);
    int k = lg2[R - L + 1];
    int a = dp[L][k], b = dp[R - (1 << k) + 1][k];
    return dph[a] <= dph[b] ? a : b;
}
int LCA(int u, int v) {
    int x = id[u], y = id[v];
    return q[RMQ_min(x, y)];
}
int ans = 0;
void dfsa(int x, int fx) {
    da[x] = da[fx] + 1;
    if (da[x] >= db[x]) return;
    if (~ans) ans = max((db[x] - 1) << 1, ans);
    for (int y : a[x]) {
        if (y == fx) continue;
        if (db[x] + db[y] - 2 * db[LCA(x, y)] > 2) ans = -1;
        dfsa(y, x);
    }
}
int main() {
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        b[u].push_back(v);
        b[v].push_back(u);
    }
    dfsb(y, 0);
    RMQ_init(dfn);
    dfsa(x, 0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 68988
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		char[][] table={{'a', 'f', 'k', 'p', 'u', 'z'},
				{'b', 'g', 'l', 'q', 'v', '.'}, {'c', 'h', 'm', 'r', 'w', '?'},
				{'d', 'i', 'n', 's', 'x', '!'}, {'e', 'j', 'o', 't', 'y', ' '},};

		for(; sc.hasNext();){
			String s=sc.next();
			if(s.length()%2==1){
				println("NA");
				continue;
			}
			String ans="";
			for(int i=0; i<s.length()/2; i++){
				int m=s.charAt(i*2)-'0';
				int n=s.charAt(i*2+1)-'0';
				m--;
				n--;
				// println(m+":"+n);
				if(m<0||m>=6||m<0||n>=5||!Character.isDigit(s.charAt(i*2))
						||!Character.isDigit(s.charAt(i*2+1))){
					ans="NA";
					break;
				}
				ans+=table[n][m];
			}
			println(ans);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
s = input()
t = input()
ans = len(t)
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] == t[i]:
            ans -= 1
else:
    for i in range(len(s)-len(t)):
        min_ans = 0
        s1 = s[i:len(t)+i]
        for j in range(len(t)):
            if s1[j] != t[j]:
                min_ans += 1
        ans = min(ans,min_ans)
print(ans)

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


int main(){
  int n; cin>>n;
  vector<ll>l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  int ans=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]<l[k]+l[j] && l[j]<l[i]+l[k] && l[k]<l[i]+l[j]){
          if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
            ans++;
          }
        }
      }
    }
  }

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



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
 	int k , n ;
  	cin >> k  >> n ; 
  	vector<int> v(n);
  	for ( int i =  0 ;i < n  ; i++ ) cin >> v[i] ; 
  	sort( v.begin() , v.end() );
  	int d = v[v.size() -1 ] - v[0];
  	for ( int i = n-1 ; i >= 1 ; i -- )
      	d = min( d , k - v[i] + v[i-1] ) ;
  	cout << d;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 10007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int m = s.size();
  rep(i, m) {
    s[i] = 'A' + (s[i]-'A'+n)%26;
  }
  cout << s << endl;
}

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

int main(void)
{
  long X;
  scanf("%ld", &X);
  long t = (long)(-1+sqrt(8*X+1))/2;
  while(t*(t+1) < X*2)
    t++;
  printf("%ld\n", t);
}

Measured memory_bytes: 128
N = int(input())

B = list(map(int,input().split()))

A = []
A.append(B[0])

for i in range(1, N-1):
    if B[i-1]<B[i]:
        A.append(B[i-1])
    else:A.append(B[i])
A.append(B[N-2])

print(sum(A))

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 26
ll a[N], b[N];

int main(){
	int n;
	cin>>n;
	fill(a, a+N, INF);
	rep(i, n){
		string s;
		cin>>s;
		mset(b, 0);
		rep(j, s.size()) b[s[j]-'a']++;
		rep(j, N) chmin(a[j], b[j]);
	}
	rep(i, N) cout<<string(a[i], 'a'+i);
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
def check(p):
    i = 0
    for j in range(track):
        s = 0
        while s + A[i] <= p:
            s += A[i]
            i += 1
            if i == budget:
                return True
    return False
    
def solve():
    left = max(A)
    right = sum(A)
    while (right - left > 1):
        mid = int((left + right) / 2)
        if check(mid):
            right = mid
        else :
            left = mid
    if check(left):
        return left
    else :
        return right

if __name__ == '__main__':
    budget, track = list(map(int, input().split()))
    A = []
    for n in range(budget):
        A.append(int(input()))     
    ans = solve()
    print(ans)


Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =2e5+100;
ll vis[N],x[N];

int main(){
    int n;
    ll res =0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&x[i]);
        vis[x[i]]++;
    }
    for(int i=1;i<=200000;i++){
        res +=(vis[i]*(vis[i]-1)/2);
    }
    for(int i=0;i<n;i++){
        printf("%lld\n",res-vis[x[i]]+1);
    }
    return 0;
}


Measured memory_bytes: 4736
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    MAX = max(A)
    MIN = min(A)
    if MAX == MIN:
        print("Yes" if MAX + 1 == n or 2 * MAX <= n else "No")
    elif MAX - MIN == 1:
        cnt = A.count(MIN)
        print("Yes" if cnt < MAX and cnt + 2 * (MAX - cnt) <= n else "No")
    else:
        print("No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 20656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> tri;

ll solve(void){
  ll n,m,x;
  scanf("%lld%lld%lld",&n,&m,&x);
  vector<ll> h(n);
  for(int i=0;i<n;i++)scanf("%lld",&h[i]);

  vector< vector<pll> > g(n);
  for(int i=0;i<m;i++){
    ll a,b,t;
    scanf("%lld%lld%lld",&a,&b,&t);
    a--; b--;
    g[a].push_back(pll(t,b));
    g[b].push_back(pll(t,a));
  }

  priority_queue<tri> q;
  q.push(tri(pll(x,0),0));
  vector<bool> vis(n,0);

  while(q.size()){
    tri p = q.top(); q.pop();
    ll hight = p.first.first, cost = -p.first.second, tree = p.second;

    if(vis[tree])continue;
    vis[tree] = 1;

    if(tree == n-1){
      return cost + h[n-1]-hight;
    }

    for(pll e : g[tree]){
      ll nxt = e.second, t = e.first, nxtc = cost, nxth = hight;
      if(h[tree]<t)continue;

      if(hight<t){
	nxtc += 2*t-hight;
	nxth = 0;
      }else if(h[nxt]<hight-t){
	nxtc += hight-h[nxt];
	nxth = h[nxt];
      }else{
	nxtc += t;
	nxth -= t;
      }
      q.push(tri(pll(nxth,-nxtc),nxt));
    }
  }
  return -1;
}

int main(){
  printf("%lld\n",solve());
}

Measured memory_bytes: 32288
#include <iostream>
using namespace std;
#define Max 200000
#define Top 1000000005
typedef long long ll;
int L[Max/2+5],R[Max/2+5];
ll cnt = 0;
void merge(int A[],int n,int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int i,j;
	for(i=0;i<n1;i++) L[i] = A[left+i];
	for(i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = Top;
	i = j = 0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]) A[k] = L[i++];
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	
}
void mergeSort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid = (left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}
int main(){
	int i,n,A[Max];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	mergeSort(A,n,0,n);
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 4724
import java.util.*;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    if((N%500) <= A){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23252
#商品数を取り込む
line_num = input()
line = line_num.split(" ")
  
    #全得票数を計算する
line2 = input().split(" ")
sum_vote = 0
for i in line2:
   # print(i)
    sum_vote += int(i)
  
#規定得票数を算出する。
numa = sum_vote/int(line[1])
num= numa/4

list =[]
for i in line2:
    if int(i) >=num:
        list.append(i)
    else:
        pass

if len(list)>=int(line[1]):
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    ans += min(k, a);
    k -= min(k, a);
    k -= min(k, b);
    ans -= min(k, c);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=18,p=998244353;
int read(){
    int f=1,g=0;char ch=getchar();
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
    for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
    return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,L,s,a[1<<N],b[1<<N];
inline int pl(int x,int y){return (x+y<p) ? (x+y) : (x+y-p);}
void FWT(int *a,int L,int typ){
	for (int k=1;k<L;k<<=1)
	for (int i=0;i<L;i+=k*2)
	for (int j=0;j<k;j++){
		int x=a[i+j],y=a[i+j+k];
		a[i+j]=pl(x,y);a[i+j+k]=pl(x,p-y);
	}
	if (typ==1){
		int R=qpow(L,p-2);
		for (int i=0;i<L;i++) a[i]=(ll)a[i]*R%p;
	}
}
int main(){
	n=read();L=1<<n;
	for (int i=0;i<L;i++)
		a[i]=read(),s+=a[i];
	s=qpow(s,p-2);
	for (int i=0;i<L;i++) a[i]=(ll)a[i]*s%p,b[i]=(i==0) ? (L-1) : (p-1);
	a[0]-=1;
	FWT(a,L,0);FWT(b,L,0);
	int pos=0;
	for (int i=0;i<L;i++)
	if (!a[i]) pos=i;
	else a[i]=(ll)b[i]*qpow(a[i],p-2)%p;
	FWT(a,L,1);
	int val=(ll)(p-a[0])*L%p;
	FWT(a,L,0);
	a[pos]=val;
	FWT(a,L,1);
	for (int i=0;i<L;i++) printf("%d\n",a[i]);
	return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var dp = new double[n + 1, n + 1];
            dp[0, 0] = 1;

            for (var i = 1; i <= n; i++)
            {
                for (var j = 0; j <= i; j++)
                {
                    if (j - 1 >= 0)
                        dp[i, j] = dp[i - 1, j - 1] * p[i - 1] + dp[i - 1, j] * (1.0 - p[i - 1]);
                    else
                        dp[i, j] = dp[i - 1, j] * (1.0 - p[i - 1]);
                }
            }

            var ans = 0D;
            for (var i = n / 2 + 1; i <= n; i++) ans += dp[n, i];
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 80992
#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>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int K, X;
  cin >> K >> X;
  ll max, min;
  max = X + K - 1;
  min = X - K + 1;
  for(int i = min; i <= max; i++) cout << i << endl;  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
        int stack_data[10];
        int stack_num=0;
        int tmp = 0;
        int i;
        while(scanf("%d", &tmp) != EOF) {
                if(tmp!=0) {
                        stack_data[stack_num] = tmp;
                        stack_num++;
                } else {
                        stack_num--;
                        printf("%d\n", stack_data[stack_num]);
                        stack_data[stack_num] = 0;
                }
        }

        return 0;
}

Measured memory_bytes: 600
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=set(a)
d=len(s)
cc=Counter(a)
ans=0
for i in s:
    ans+=(cc[i]*(cc[i]-1))//2
for i in a:
    if cc[i]==1:
        print(ans)
    else:
        print(ans-(cc[i]-1))


Measured memory_bytes: 28736
def main():
  INIT = 100
  
  query = []
  ans = []
  while True:
    q = int(input())
    if q == 0:
      break
    query.append(q)
  MAX = max(query)
  
  table = [INIT] * (MAX + 1)
  table[0] = 0
  all_item = [i * (i + 1) * (i + 2) // 6 for i in range(1, 181)]
  odd_item = [i for i in all_item if i % 2]
  eve_item = [i for i in all_item if not i % 2]
  
  for v in odd_item:
    for j in range(v, MAX + 1):
      tjv = table[j - v]
      if table[j] > tjv + 1:
        table[j] = tjv + 1
  
  for q in query:
    ans.append(table[q])
  
  for v in eve_item:
    for j in range(v, MAX + 1):
      tjv = table[j - v]
      if table[j] > tjv + 1:
        table[j] = tjv + 1
  
  for i, q in enumerate(query):
    print(table[q], ans[i])

main()



Measured memory_bytes: 13152
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int r;

int main() {
    cin >> r;

    cout << r * r << endl;
    return 0;
}


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


int main() {
    int p,q,r;
    cin >> p >> q >> r;
    cout << min({p+q,q+r,p+r}) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long sum = 0;
    for(int i=0;i<s.size();++i)sum+=s[i]-'0';
    if(sum%9==0)cout<<"Yes";
    else cout<<"No";
    return 0;	
}

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

int main() {
    
    int a,b,c,d;
    int x=-1;
    
    cin>>a>>b;
    
    for(int i=0;i<1001;i++){
      c=0.08*i;
      d=0.1*i;
        if(c == a && d == b){
            cout<<i<<endl;
            x=1;
            break;
        }
    }
    if(x==-1)cout<<x<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    int H, W;
    int h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,k,l,m,n,o,p,q,r,t,a[100001];
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    r=0;
    for(i=0;i<k;i++)
    {
        r+=a[i];
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 3652
N = int(input())

res = N
S = ''
divisor = 1
i = 0
while res != 0:
    divisor *= 2
    remainder = abs(res) % divisor
    bit = 0 if remainder == 0 else 1
    S = str(bit) + S
    if i % 2 == 0:
        res -= divisor * bit // 2
    else:
        res += divisor * bit // 2
    i += 1
print(S or '0')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

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

    int A[2][N];
    std::fill( (int*)A, (int*)(A + 2), 0);
    for(int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];             
//            cout << A[i][j] << endl;
        }
    }

    int max_candis[2][N];
    std::fill((int*)max_candis, (int*)(max_candis + 2), 0);
    max_candis[0][0] = A[0][0];
    for(int i = 1; i < N; i++)
    {
        max_candis[0][i] = A[0][i] + max_candis[0][i-1];
//            cout << max_candis[0][i] << endl;

    }

    max_candis[1][0] = max_candis[0][0] + A[1][0];
    for(int i = 1; i < N; i++)
    {
        max_candis[1][i] = A[1][i] + max(max_candis[0][i], max_candis[1][i - 1]);
//            cout << max_candis[1][i] << endl;

    }
    cout << max_candis[1][N - 1] << endl;
}

Measured memory_bytes: 256
# 二回訪れたら終了、それまでに2に行ったらOK
# インデックスと値を入れ替えながらやってみる
n = int(input())
dic = []
for i in range(n):
    dic.append(int(input()))

used = [False for _ in range(10 ** 5 + 1)]
tmp = 1
ans = 0
while True:
    target = dic[tmp - 1]
    if target == 2:
        print(ans + 1)  # 次の一手で決まるので
        exit()
    if used[target]:
        print(-1)
        exit()
    tmp = target
    used[tmp] = True
    ans += 1


Measured memory_bytes: 7852
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int ans=1;
  while(ans*2<=N)ans*=2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

int n, s;

bool check(int b) {
    int tn = n, res = 0;
    while (tn) {
        res += tn % b;
        tn /= b;
    }
    return (res == s);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int sqr;
    cin >> n >> s;
    if (n == s) {
        cout << n + 1 << "\n";
        return 0;
    }
    if (s > n) {
        cout << -1 << "\n";
        return 0;
    }
    sqr = ceil(sqrt(n));
    FOR(b, 2, sqr + 1) {
        if (check(b)) {
            cout << b << "\n";
            return 0;
        }
    }
    ROF(x1, sqr, 0) {
        if ((s - x1 >= 0) && (s - x1 < ((n - s) / x1 + 1)) && (x1 < ((n - s) / x1 + 1)) && ((n - s) % x1 == 0)) {
            cout << ((n - s) / x1 + 1) << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";

    return 0;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D){
    cout << "Balanced" <<endl;
  }
  else if (A + B > C + D){
    cout << "Left" <<endl;
  }
  else if (A + B < C + D){
    cout << "Right" <<endl;
  }
}

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

int a, b;
string S_a, S_b;

int main(){
  cin >> a >> b;
  for (int i = 0; i < a; ++i) S_a += to_string(b);
  for (int i = 0; i < b; ++i) S_b += to_string(a);
  string res = (S_b < S_a? S_b : S_a);
  cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;map<string,ll> m;
    for (int i = 0; i < n; ++i)
    {
        string s;cin >> s;m[s]++;
    }
    ll d=-1;
    for(auto i : m)d=max(d,i.second);
        vector<string > v;
    for(auto i : m)
    {
        if(i.second==d)v.push_back(i.first);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); ++i)
    {
        cout << v[i] << "\n";
    }
    }

Measured memory_bytes: 25584
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a), i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll H, A;
	cin >> H >> A;
	if(H%A==0){
		cout << (ll)(H/A);
	}else{
		cout << (ll)(H/A)+1;
	}
	cout << endl;
}


Measured memory_bytes: 256
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

#sの数
n = int(arr_data[0][0])
#cの数
m = int(arr_data[0][1])

num=min(n//1,m//2)

cnt=num

n-=num*1
m-=num*2

#cnt+=n//3
cnt+=m//4

print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;




int main() {
  ll a,b;
  string s;
  cin >> a >> s;
  b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
  cout << a*b/100 << endl;
}










Measured memory_bytes: 3200
import Control.Monad 
import Data.List
import qualified Data.ByteString.Char8 as B

main = do
    n <- read <$> getLine :: IO Int
    names <- replicateM n B.getLine
    let m = cnt 'M' names
    let a = cnt 'A' names
    let r = cnt 'R' names
    let c = cnt 'C' names
    let h = cnt 'H' names
    let l = zip [1..] [m,a,r,c,h] 
    print . sum $ [i*j*k|(p,i)<-l,(p',k)<-l,(p'',j)<-l,p<p',p'<p'']
    
cnt k names = length . filter (\s-> B.head s == k) $ names


Measured memory_bytes: 21372
<?php
fscanf(STDIN, '%d', $N);
$S = [];
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, '%s', $S[$i]);
}
$X = array_count_values($S);
array_multisort(array_values($X), SORT_DESC, array_keys($X), SORT_ASC, $X);
$ans = [];
$maxx = null;
foreach ($X as $k => $v) {
    if (is_null($maxx)) {
        $maxx = $v;
        $ans[] = $k;
    } else {
        if ($v === $maxx) {
            $ans[] = $k;
        } else {
            break;
        }
    }
}
echo implode(PHP_EOL, $ans);


Measured memory_bytes: 76272
#b
a=[None]*5
for i in range(5):
    a[i] =int(input())

import math

suma = sum(math.ceil(aa/10)*10 for aa in a)
ans=10**10
for i in range(5):
    ans = min(ans,a[i] + suma - math.ceil(a[i]/10)*10 )
print(ans)

Measured memory_bytes: 62012
package main

import "fmt"

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)

	ans := r * 100 + g * 10 + b
	if ans % 4 == 0 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


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

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

    int idx = -1;

    int a[100010];

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


    int ans = 0;
    for(int i = 0;i < n-1;i++){
        if(a[i] + a[i+1] >= l){
            idx = i;
            break;
        }
    }

    if(idx == -1){
        cout << "Impossible" << endl;
        return 0;
    }else{
        cout << "Possible" << endl;
    }

    for(int i = 0;i < idx;i++){
        cout << i+1 << endl;
    }

    for(int i = n-2;i > idx;i--){
        cout << i+1 << endl;
    }

    cout << idx+1 << endl;
    return 0;
}






Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define MOD 1000000007
typedef long long ll;
using namespace std;

struct UnionFind{
  vector<int> par;
  UnionFind(int N) : par(N){
    for(int i=0;i<N;i++) par[i] = i;
  }

  void init(int N){
    for(int i=0;i<N;i++) par[i] = i;
  }

  int root(int x){
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
  }

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

int main(){
  int N,M; cin >> N >> M;
  UnionFind tree(N);
  vector<pair<int,int>> v(M);
  for(int i=0;i<M;i++){
    int a,b; cin >> a >> b;
    a--; b--;
    v[i] = {a,b};
  }

  int ans = 0;
  for(int i=0;i<M;i++){
    tree.init(N);
    for(int j=0;j<M;j++){
      if(i == j) continue;
      else tree.unite(v[j].first, v[j].second);
    }
    set<int> st;
    for(int i=0;i<N;i++){
      st.insert(tree.root(i));
    }
    if(st.size() > 1) ans++;
  }

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

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin() , v.end());
    int m;
    cin >> m;
    for(int i = 0; i< m; i++){
        int p;
        cin >> p;
        if(std::binary_search(v.begin(), v.end(), p)){
            cout << binary_search(v.begin(), v.end(), p) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
}


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

int main() {
  string N;
  cin>>N;
  int long1=N.size()-1;
  if(N.at(long1)=='2'||N.at(long1)=='4'||N.at(long1)=='5'||N.at(long1)=='7'||N.at(long1)=='9'){
    cout<<"hon"<<endl;
  }
  else if(N.at(long1)=='0'||N.at(long1)=='1'||N.at(long1)=='6'||N.at(long1)=='8'){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"bon"<<endl;
  }
}


Measured memory_bytes: 3620
N,A,B = map(int,input().split())
S = input()

passed = 0 
fo = 1 
for i in range(N):
  if(S[i] == 'a'):
    if(passed < A+B):
      print('Yes')
      passed += 1
    else:
      print('No')
  elif(S[i] == 'b'):
    if((passed < A+B)and(fo <= B)):
      print('Yes')
      fo += 1
      passed += 1
    else:
      print('No')
  elif(S[i] == 'c'):
     print('No')
    


Measured memory_bytes: 4016
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****

public class Main {
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        String s=scan.next();
        Map<String,Integer> m=new HashMap<>();
        m.put("MON",6);
        m.put("TUE",5);
        m.put("WED",4);
        m.put("THU",3);
        m.put("FRI",2);
        m.put("SAT",1);
        m.put("SUN",7);
        System.out.println(m.get(s));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


Measured memory_bytes: 20948
n = int(input())
a = list(map(int, input().split()))

def bubbleSort(a:list, n:int):
    count = 0
    flag = 1
    while flag:#要素の交換が起こらなくなるまで続ける
        flag = 0
        for j in range(n-1, 0, -1):#配列の右端から見ていく
            if a[j] < a[j-1]:#右側の要素が一つ左の要素より小さければ要素を交換
                a[j], a[j-1] = a[j-1], a[j]
                flag = 1 #交換が一度でも発生したらflag立てる
                count += 1
    return count, a

count, a = bubbleSort(a, n)
print(" ".join(map(str, a)))
print(count)



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

int main(){

   int maxi=-10000000,mini=10000000,no,i,currentNo;
   long long sum=0;
   cin >> no;
   for(i=0;i<no;i++){
   	cin >> currentNo;
	if(currentNo<mini) mini=currentNo;
	if(currentNo>maxi) maxi=currentNo;
	sum=sum+currentNo;
	
   }
   
    cout << mini << " " << maxi << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3116
// ALDS1_4_A.cpp
// Linear Search
// ???????????§?°?

#include <iostream>
#include <set>
using namespace std;

int intersectionCnt(set<int>& S, set<int>& T)
{
    int C = 0;
    set<int>::iterator it1 = S.begin();
    set<int>::iterator it2 = T.begin();
    while (it1 != S.end() && it2 != T.end()) {
        if (*it2 == *it1) {
            C++;
            ++it1;
            ++it2;
        }
        else if (*it2 < *it1) {
            ++it2;
        }
        else {
            ++it1;
        }
    }
    return C;
}

int main()
{
    int n;
    cin >> n;
    set<int> S;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        S.insert(tmp);
    }

    int q;
    cin >> q;
    set<int> T;
    for (int i = 0; i < q; i++) {
        cin >> tmp;
        T.insert(tmp);
    }

    int C = intersectionCnt(S, T);
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 10000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

bool dp[2][4010][20010];
const int B = 10000;

int main() {
	string str;
	cin >> str;
	int x, y;
	cin >> x >> y;

	int d = 0; int cnt = 0;
	vector<int> v;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'F') {
			++cnt;
		}
		else {
			v.pb(cnt);
			cnt = 0;
			d ^= 1;
		}
	}
	if (cnt)v.pb(cnt);
	
	int c[2] = {};
	for (int i = 0; i < 2; i++) {
		dp[i][0][B] = true;

		for (int j = i; j < v.size(); j += 2) {
			for (int k = 0; k < 20010; k++)if (dp[i][c[i]][k]) {
				if (j != 0) {
					dp[i][c[i] + 1][k - v[j]] = true;
				}
				dp[i][c[i] + 1][k + v[j]] = true;
			}
			++c[i];
		}
	}
	cout << ((dp[0][c[0]][x + B] && dp[1][c[1]][y + B]) ? "Yes" : "No" )<< endl;

	return 0;
}

Measured memory_bytes: 154496
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;

typedef long long ll;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

clock_t time_p=clock();
void printTime(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}


ll mod=1e9+7;
const int N = 1e5 + 5;
bool collinear(int x1, int y1, int x2, int y2, int x3, int y3) {
  return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}

int32_t main(){
    io();
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k -1];


}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s=sc.next();
String t=s;
boolean f=false;
int count=0;
for(int i=0;i<s.length()-3;i++){if(s.charAt(i+2)=='C')count++;}
for(char i='A';i<='Z';i++){t=t.replaceAll(String.valueOf(i), "");}
if(s.charAt(0)=='A'){
    if(count==1){
        if(t.length()==s.length()-2){
        f=true;
        }
    }
}
if(f){System.out.println("AC");}else{System.out.println("WA");}
}}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> A(M,INF), A_odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  A_odd[0] = 0;
  for(int i = 0; i < M; ++i){
    A[i] = i;
    A_odd[i] = i;
  }
  while(t < 1000000){
    for(int k = 0; k+t < M; ++k){
      A[k+t] = min(A[k]+1,A[k+t]);
      if(t%2) A_odd[k+t] = min(A_odd[k]+1,A_odd[k+t]);
    }
    ++k;
    t *= k;
    t /= (k-3);
  }
  while(cin >> n, n){
    cout << A[n] << " " << A_odd[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 10484
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set> 
#include <vector>
#include <limits.h>
#include <math.h>
#define ll long long 

using namespace std; 
ll k, n;
int main(void)
{
	while (scanf("%lld", &k) == 1)
	{
		n = 50;
		printf("%lld\n", n);
		ll a = k / n, b = k%n;
		int cot = 0;
		for (ll i = 1; i <= b; i++)
		{
			cot++; 
			cout << 49 + a + 50 - (b - 1) << (cot == n ? '\n' : ' ');
		}
		for (ll i = 1; i <= (n - b); i++)
		{
			cot++;
			cout << 49 + a - b << (cot == n ? '\n' : ' ');
		}
	}
	return false;

	return false;
}

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

int main(){
  int x; cin >>x;
  int ans = 0;
  int i = 1;
  while(x>0){
    ans++;
    x -= i;
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d)
    cout<<"Left";
  else if(a+b==c+d)
    cout<<"Balanced";
  else
    cout<<"Right";
  return 0;
}

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

int main() {
	string s; cin >> s;
	auto z = count(s.begin(), s.end(), '0');
	auto o = count(s.begin(), s.end(), '1');
	cout << 2 * min(z,o) << endl;
	return 0;
}

Measured memory_bytes: 512
K = int(input())

if K%7 == 0:
    L = 9*K/7
else:
    L = 9*K

mod = [1]
i = 1


while True:
    mod.append((mod[i-1]*10)%L)
    if mod[i] == 1:
        print(i)
        break
    if i > K:
        print(-1)
        break
    i += 1
   

Measured memory_bytes: 48688
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a, b, c;
    cin >> a >> b;
    
    c = a + b;
    
    if(c%2==1)
      cout << (c+1)/2 << endl;
    else
      cout << c/2 << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, m = list(map(int, input().split(" ")))
a_list = list(map(int, input().split(" ")))
b_list = list(map(int, input().split(" ")))

a_min = min(a_list)
b_min = min(b_list)

sum_min = a_min + b_min

for _ in range(m):
  m_0, m_1, m_2 = list(map(int, input().split(" ")))
  a_m = a_list[m_0 - 1]
  b_m = b_list[m_1 - 1]
  if sum_min > (a_m + b_m - m_2):
    sum_min = a_m + b_m - m_2
print(sum_min)


Measured memory_bytes: 18736
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());
		for(int i=1;i<=X; i++) {
			int t = i*2;
			int k = (X-i)*4;
			int t2= i*4;
			int k2= (X-i)*2;
			if(t+k == Y || t2+k2==Y) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 35644
fn main() {
    use std::io;
    let mut input = String::new();
    let _ = io::stdin().read_line(&mut input);
    let input_nums =
        input.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>();
    let n = input_nums[0];
    let m = input_nums[1];
    if n * 2 >= m {
        println!("{}", m / 2);
    } else {
        println!("{}", (m + n * 2) / 4);
    }
}

Measured memory_bytes: 4352
#include<cstdio>
#define RI int
#define CI const int&
using namespace std;
const int N=405,mod=998244353;
int n,s1,s2,a[N],b[N],fact[N],inv[N],pw[N],f[N][N][N],ans;
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline void dec(int& x,CI y)
{
	if ((x-=y)<0) x+=mod;
}
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline void init(CI n=400)
{
	RI i; for (fact[0]=i=1;i<=n;++i) fact[i]=1LL*fact[i-1]*i%mod;
	for (inv[n]=quick_pow(fact[n]),i=n-1;~i;--i) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
int main()
{
	RI i,j,k,p; for (scanf("%d",&n),i=1;i<=n;++i) scanf("%d%d",&a[i],&b[i]);
	for (init(),f[0][0][0]=mod-1,i=1;i<=n;++i)
	{
		for (j=0;j<=s1;++j) for (k=0;k<=s2;++k) f[i][j][k]=f[i-1][j][k];
		for (pw[0]=j=1;j<b[i];++j) pw[j]=1LL*pw[j-1]*a[i]%mod;
		for (j=0;j<b[i];++j) pw[j]=1LL*pw[j]*inv[j]%mod;
		for (j=0;j<=s1;++j) for (k=0;k<=s2;++k) for (p=0;p<b[i];++p)
		dec(f[i][j+p][k+a[i]],1LL*f[i-1][j][k]*pw[p]%mod); s1+=b[i]-1; s2+=a[i];		
	}
	for (i=0;i<=s1;++i) for (j=1;j<=s2;++j)
	inc(ans,1LL*f[n][i][j]*fact[i]%mod*quick_pow(j,mod-1-i)%mod*s2%mod*quick_pow(j)%mod);
	return printf("%d",ans),0;
}

Measured memory_bytes: 256128
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int x,y;
	cin>>x>>y;
	if(y>=2*x and y<=4*x and y%2==0)cout<<"Yes\n";
	else cout<<"No\n";
	
	
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin >>n;
    ll i;
    for(i=1;i*i<=n;i++);
    ans=(i-1)*(i-1);

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc141/tasks/abc141_d

#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {
    
}

const int maxn = 100500;

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

    int N, M;
    cin >> N >> M;

    priority_queue<int> pq;

    for(int i = 1; i <= N; i++) {
        int x;
        cin >> x;

        pq.push(x);
    }

    for(int i = 1; i <= M; i++) {
        int val = pq.top(); pq.pop();

        pq.emplace(val/2);
    }

    int sum = 0;
    while(pq.size()) {
        sum += pq.top();
        pq.pop();
    }

    cout << sum << endl;
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


Measured memory_bytes: 4268
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		String S = reader.next();
		solver(S);
	}

	public static void solver(String S) {
		int k = S.length();
		long sum = 0;
		for (int i=0; i<k; i++) {
			for (int d=0; d<k-i; d++) {
				double p = (d == k-i-1) ? Math.pow(2, k-d-1) : Math.pow(2, k-d-2);
				long add = (long)(Math.pow(10, d) * p);
				sum += add * Integer.parseInt("" + S.charAt(i));
			}
		}
		System.out.println(sum);
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 7636