akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int X[20][20];


int main(){
    int N;
    int A;
    cin >> N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            X[i][j]=-1;
        }
    }
    for(int i=1;i<=N;i++){
        cin >> A;
        for(int j=1;j<=A;j++){
            int x,y;
            cin >> x >> y;
            X[i][x] = y;
        }
    }

    map<int,int> honest;
    int ans=0;
    // 2^N通りを試す
    for(int i=0;i<pow(2,N);i++){
        int tmp=i;
        int h_cnt=0;
        bool flg=true;
        for(int j=1;j<=N;j++){
            if(tmp%2==1){
                honest[j]=1;
                h_cnt++;
            }else{
                honest[j]=0;
            }
            tmp /= 2;
        }
        for(int k=1;k<=N;k++){
            if(honest[k]==1){
                for(int l=1;l<=N;l++){
                    if(X[k][l]==1){
                        if(honest[l]!=1){
                            flg=false;
                        }
                    }else if(X[k][l]==0){
                        if(honest[l]!=0){
                            flg = false;
                        }
                    }
                }
            }
        }
        if(flg==true){
            ans=max(ans,h_cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int n;
	while(scanf("%d", &n) != EOF) {
		int count = 0;
		for(int a = 0; a < 10; a++) {
			for(int b = 0; b < 10; b++) {
				for(int c = 0; c < 10; c++) {
					for(int d = 0; d < 10; d++) {
						if(a + b + c + d == n)		count++;
					}
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main(){
long N, i, ans=0; cin >> N; long A[N], C[N]={}; 
for(i=0; i<N; i++){ cin >> A[i]; C[A[i]-1]++; }
for(i=0; i<N; i++){ if(C[i]>=2){ ans+=C[i]*(C[i]-1)/2; } }
for(i=0; i<N; i++){ long n=A[i]-1;
  if(C[n]<2){ cout << ans << "\n"; }
  else{ cout << ans-C[n]*(C[n]-1)/2+(C[n]-1)*(C[n]-2)/2 << "\n"; }
} 
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,p,q,i;
    while(cin>>n)
    {
        m=0;
        for(i=1;;i++)
        {
            m+=i;
            if(m>=n) break;
        }
        cout<<i<<endl;
    }
}


Measured memory_bytes: 256
from collections import Counter
N,K = [int(i) for i in input().split()] 
A = [int(i) for i in input().split()]
counter = Counter(A)
ans = 0
counter_list = counter.most_common()[::-1]
if K < len(counter_list):
    for a in counter_list[:len(counter_list)-K]:
        ans += a[1]
print(ans)

Measured memory_bytes: 39284
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        for(int i=0;i<10000;i++){
            if(K*i>=A && K*i<=B){
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }

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


Measured memory_bytes: 35680
n=int(input())

d=2
ans=0

while d*d <= n:
    if n%d != 0:
        d +=1
        continue

    z=d

    while n%z ==0:
        n //=z
        z *= d
        ans += 1
    
    while n % d == 0:
        n /= d

if n != 1:
    ans +=1

print(ans) 

Measured memory_bytes: 9112
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort()

tmp = 0
SUM_aa = [0]
for a in aa:
	tmp += a
	SUM_aa.append(tmp)

def solve(ind):
	size = SUM_aa[ind]
	b_ind = ind

	while True:
		ind = bisect.bisect_right(aa,size*2)

		if ind == N:		#全部吸収
			return True
		elif b_ind == ind:	#ind変更なし
			return False

		size = SUM_aa[ind]
		b_ind = ind

NG = 0
OK = N

while OK-NG > 1:
	mid = (OK+NG)//2
	if solve(mid):
		OK = mid
	else:
		NG = mid

print(N-OK+1)


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

int n, x, y;
vector <int> tree [100005];
int memo[100005];

int main () {
	
	int i=0;

	scanf("%d", &n);

	for (i=0; i<n-1; i++) {
		scanf("%d %d", &x, &y);
		x--; y--;
		tree[x].push_back(y);
		tree[y].push_back(x);
	}

	
	queue <pair<int, int> > q;
	memo[0] = 1;
	memo[n-1] = 1;
	q.push(make_pair(0, 1));
	q.push(make_pair(n-1, 2));

	int f=1, s=1;

	while (!q.empty()) {

		int u = q.front().first;
		int play = q.front().second;
		q.pop();

		for (i=0; i<tree[u].size(); i++) {
			int v = tree[u][i];
			if (memo[v] == 0) {
				q.push(make_pair(v, play));
				memo[v] = play;
				if (play == 1) f++;
				else s++;
			}
		}
	}




	if (f==s) printf("Snuke\n");
	else {
		if (f>s) printf("Fennec\n");
		else printf("Snuke\n");
	}
	
	return 0;
}

Measured memory_bytes: 6400
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int maxn = 1e5+233;
struct data{
	int a,b;
	bool operator < (const data &w) const{
		return max(a,b) > max(w.a,w.b);
	}
}p[maxn];
ll sum;
int n;
int main(){
	n = read();
	Rep(i,1,n){
		p[i].a = read(),p[i].b = read();
		sum += p[i].a;
	}sort(p+1,p+1+n);
	int k=0;ll ss=0;
	Rep(i,1,n){
		ss += max(p[i].a,p[i].b);
		if(ss >= sum){
			k = i;
			break;
		}
	}
	ll P=1,Q=1;
	Rep(i,1,n){
		ll now = sum - (ss - max(p[min(i,k)].a,p[min(i,k)].b));
		if(now <= p[i].b && now*Q<P*p[i].b)
			P = now,Q = p[i].b;
	}P=Q-P+(n-k)*Q,Q*=n;
	ll g=__gcd(P,Q);P/=g,Q/=g;
	wri(P),writeln(Q);
	return 0;
}

Measured memory_bytes: 4360
import sys
from collections import Counter

S = sys.stdin.readline().strip()
counter = Counter(S)

ls = len(S)
if ls == 1:
    print("YES")
elif ls == 2:
    if len(counter) == 2:
        print("YES")
    else:
        print("NO")
else:
    if len(counter) < 3:
        print("NO")
    else:
        counter = sorted(counter.items(), key=lambda x: x[1])
        if counter[2][1] - counter[0][1] < 2:
            print("YES")
        else:
            print("NO")

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

int main () {
	int H, W;
	char R[100];
	cin >> H >> W;
	for (int col=0; col<H; col++) {
		for (int row=0; row<W; row++) {
			cin >> R[row];
			cout << R[row];
		}
		cout << endl;
		for (int row=0; row<W; row++)
			cout << R[row];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s="";
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
if(a%2==0||b%2==0){
    s="Even";
}else{
    s="Odd";
}
System.out.println(s);
}}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

ll n,m;
vector<ll> vec[210000];
string s;
vector<P> cnt;
queue<ll> que{};
ll dead[210000];

void bfs(){
while(que.size()){
	int v=que.front();
	que.pop();
	int att;
	if(s[v-1]=='A')att=1;
	else att=2;
for(int i=0;i<vec[v].size();i++){
ll vv=vec[v][i];
if(dead[vv]==1)continue;
if(att==1 && cnt[vv].first==1){
	que.push(vv);
	dead[vv]=1;
}
if(att==2 && cnt[vv].second==1){
	que.push(vv);
	dead[vv]=1;
}
if(att==1&&cnt[vv].first>=1)cnt[vv].first-=1;
if(att==2&&cnt[vv].second>=1)cnt[vv].second-=1;
}
}
return ;
}

int main() {
cin>>n>>m;
cin>>s;
rep(i,n){
	dead[i]=0;
}

rep(i,m){
	ll a,b;
	cin>>a>>b;
vec[a].pb(b);
if(a!=b)
vec[b].pb(a);
}

cnt.pb(mp(0,0));
rep(i,n){
	ll Ac=0;
	ll Bc=0;
for(int j=0;j<vec[i].size();j++){
	if(s[vec[i][j]-1]=='A'){
Ac++;
	}
	else Bc++;
}

cnt.pb(mp(Ac,Bc));
}

rep(i,n){
	int p=cnt[i].first;
	int q=cnt[i].second;
	if(p==0 || q==0){
		que.push(i);
		dead[i]=1;
	}
}

bfs();

ll ans=0;

rep(i,n){
if(dead[i]==0)ans++;
}

if(ans>=1)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}




Measured memory_bytes: 20856
#include <cstdio>
#include <cmath>
#include <algorithm>
#define fs first
#define sc second
#define db double
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e5+5;
const db PI=acos(-1.0);
typedef pair<int,int> Pair;
Pair a[N];
db ans;
int n,bn,b[N],t[N],yy,f,k,X1,Y1,X2,Y2,i,j;
void updata(int x,int val) {
	while (x<=bn) t[x]=max(t[x],val),x+=x&(-x);
}
int query(int x) {
	int ret=0;
	while (x>0) ret=max(ret,t[x]),x-=x&(-x);
	return ret;
}
int main()
{
//	freopen("fountain.in","r",stdin);
//	freopen("fountain.out","w",stdout);
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",&a[i].fs,&a[i].sc);
	if (X1>X2)
	{
		X1*=-1; X2*=-1;
		rep(i,1,n) a[i].fs*=-1;
	}
	if (Y1>Y2)
	{
		Y1*=-1; Y2*=-1;
		rep(i,1,n) a[i].sc*=-1;		
	}
	b[1]=Y1; b[2]=Y2; bn=2;
	rep(i,1,n) b[++bn]=a[i].sc;
	sort(b+1,b+1+bn);
	bn=unique(b+1,b+1+bn)-b-1;
	sort(a+1,a+1+n);
	rep(i,1,n)
	{
		if (a[i].fs<X1 || a[i].fs>X2 || a[i].sc<Y1 || a[i].sc>Y2) continue;
		yy=lower_bound(b+1,b+1+bn,a[i].sc)-b;
		f=query(yy)+1;
		k=max(k,f);
		updata(yy,f);
	}
	ans=(ll)(X2-X1+Y2-Y1)*100;
	ans-=(20-5*PI)*k;
	if (k && k==min(X2-X1+1,Y2-Y1+1)) ans+=5*PI;
	printf("%.12lf\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x % m, n / 2, m);
	else
		return x * pow(x, n - 1, m) % m;
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x , (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ld a, b;
	cin >> a >> b;
	ld h, m;
	cin >> h >> m;
	ld tyousinn = 6 * m;
	ld tannsinn = ((h * 30) + (m / 2));
	ld kakudo = abs(tyousinn - tannsinn);
	kakudo = (kakudo / 180) * pi;
	kakudo = min(kakudo, 360 - kakudo);
	ld kotae = sqrt((a * a) + (b * b) - 2 * a * b * (cos(kakudo)));
	cout << fixed << sec(10) << kotae << endl;
}


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

const int N = 1005;

int n, k;
int a[N];

long long beauty[N*N];

int len = 0;
int ans[2][N*N];

int main() {
  scanf("%d %d", &n, &k);
  for (int i=0; i<n; i++) scanf("%d", a + i);
  
  for (int i=0; i<n; i++) {
    long long b = 0;
    for (int j=i; j<n; j++) {
      b += a[j];
      
      beauty[len] = b;
      ans[0][len] = len;
      ++len;
    }    
  }
  
  int cur = 0;
  for (int i=40; i>=0; i--) {
    int nlen = 0;
    cur ^= 1;
    for (int j=0; j<len; j++) {
      if (beauty[ans[cur^1][j]] >> i & 1) {
        ans[cur][nlen++] = ans[cur^1][j];
        
        // cerr << i << " " << ans[cur^1][j] << endl;
      }
    }
    
    if (nlen < k) cur ^= 1;
    else {
      len = nlen;
    }
  }
  
  long long ansand = ~0; 
  for (int i=0; i<k; i++) ansand &= beauty[ans[cur][i]];
  printf("%lld\n", ansand);
  
  return 0;
}


Measured memory_bytes: 12416
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC120().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC120
    {
        public void SolveA(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var c = cin.ReadInt;
            int count = 0;
            while(count < c)
            {
                if (a > b) break;
                b -= a;
                count++;
            }
            WriteLine(count);
            ReadLine();
        }
    }
}

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

const int N = 305, mod = 1000000007;

std::vector<std::pair<int, int>> v[N];

int dp[N][N][N], ans, n, m;

void up(int &x, int y) { x += y - mod, x += x >> 31 & mod; }
void check(int i) {
	for (int j = 0; j <= i; ++j)
		for (int k = 0; k <= j; ++k) {
			for (auto p : v[i])
				if ((j >= p.first) + (k >= p.first) != p.second)
					{dp[i][j][k] = 0; break;}
		}
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 0, l, r, x; i < m; ++i)
		std::cin >> l >> r >> x, v[r].emplace_back(l, x - 1);
	dp[0][0][0] = 1;
	for (int i = 0; i < n; check(++i)) {
		for (int j = 0; j <= i; ++j)
			for (int k = 0; k <= j; ++k) {
				up(dp[i + 1][j][k], dp[i][j][k]);
				up(dp[i + 1][i][k], dp[i][j][k]);
				up(dp[i + 1][i][j], dp[i][j][k]);
			}
	}
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= i; ++j)
			up(ans, dp[n][i][j]);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 108928
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for (int i = (a); i >= (b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;

const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
const ll limit3 = 1e4 + 5;

ll test;
ll n, k;
string s;
ll res = 0, sum = 0, ans = 0, kd, hkd;
bool ok = false;

void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void ReadIn(){
    cin >> s;
    if(s == "ABC") cout << "ARC";
    if(s == "ARC") cout << "ABC";
}
int main(){
    FastIn();
    ReadIn();
}
/*
* Ctrl + Shift + K Delete Line
* Ctrl + / TOGGLE LINE COMMENT
Ctrl + F Find
* Ctrl + H  REPLACE
* shift + alt + f FORMAT CODE DOCUMENT
Shift + alt + uparrow/downarrow Copy line up/down
Ctrl + ]/[ INDENT/OUTDENT LINE
Quy Hoạch Động
2 kiểu
+ Đếm cách
+ Dùng ít nhất
*/


Measured memory_bytes: 3612
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    vector<int> a(n, 0);
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> dis(n, 0);
    rep(i, n) {
        if(i+1 < n) {
            dis[i] = a[i+1] - a[i];
        } else {
            dis[i] = (a[0]+k) - a[i];
        }
    }

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

    int count = 0;
    rep(i, n-1) {
        count += dis[i];
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int dpa[100005];
int dpb[100005];
int dpc[100005];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];    
    for (int i = 1; i < N; ++i) {
        dpa[i] = a[i] + max(dpb[i-1], dpc[i-1]);
        dpb[i] = b[i] + max(dpc[i-1], dpa[i-1]);
        dpc[i] = c[i] + max(dpa[i-1], dpb[i-1]);
    }

    cout << max(dpa[N-1], max(dpb[N-1], dpc[N-1])) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

int dis[1005][1005];
int dire[4][2] = {0,1,0,-1,1,0,-1,0};
int fla,n,h,w,sx,sy,cnt;
int power = 1;
char mmap[1005][1005];
pair<int,int> tem;
queue <pair <int,int> > q;

void bfs(int st,int ed){
    tem.first = st;
    tem.second = ed;
    q.push(tem);
    dis[st][ed] = 0;

    while(!q.empty()){
        tem= q.front();
        q.pop();

        if(power > n){
            break;
        }

        for(int i = 0; i < 4; i++){
            int ii = tem.first + dire[i][0];
            int jj = tem.second  + dire[i][1];

            if(ii >= 1 && ii <= h && jj >= 1 && jj <= w && mmap[ii][jj] != 'X' && dis[ii][jj] == 0x3f3f3f3f){
                if(mmap[ii][jj] - '0' == power){
                    power++;
                    cnt += dis[tem.first][tem.second] + 1;
                    memset(dis,0x3f,sizeof(dis));
                    dis[ii][jj] = 0;
                    while(!q.empty()){
                        q.pop();
                    }
                    q.push(pair<int , int> (ii,jj));
                    break;     
                }else{
                    dis[ii][jj] = dis[tem.first][tem.second] + 1;
                    q.push(pair<int,int>(ii,jj));
                }
            }
        }
    }

}

int main(void){

    scanf("%d %d %d",&h,&w,&n);
    for(int i = 1; i <= h; i++){
        getchar();
        for(int j = 1; j <= w; j++){
            scanf("%c",&mmap[i][j]);
            if(mmap[i][j] == 'S'){
                sx = i;
                sy = j;
            }
        }
    }

    memset(dis,0x3f,sizeof(dis));
    bfs(sx,sy);
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 8072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  int m = n;
  int sum = 0;
  while(m){
    int temp = m%10;
    m /= 10;
    sum += temp;
  }
  if(n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    int n;
    cin >> n;
    int N = n % 10;
    if (N == 3) cout << "bon" << "\n";
    else if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << "\n";
    else cout << "hon" << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
double dp[3000][3000];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i, j;
    cin>>n;
   	double probability, ans = 0;
    dp[0][0] = 1;
    for(i=1; i<=n; i++) {
    	cin>>probability;
    	for(j=0; j<=n; j++) {
    		dp[i][j] = dp[i-1][j]*(1 - probability) + dp[i-1][j-1]*probability;
    	}
    }
    for(i = n/2 + 1; i <=n; i++)
    	ans += dp[n][i];
    printf("%.9lf\n", ans);
}

Measured memory_bytes: 70528
money = [10,50,100,500]
c = 0
while True:
    ans = [0,0,0,0]
    amount = int(input())
    if amount == 0:
        break
    li = list(map(int,input().split())) #[a,b,c,d]
    change = []
    m = sum(li[i] * money[i] for i in range(4)) - amount
    lis = [(m % 50) // 10,(m % 100) // 50,(m % 500) // 100,m // 500]
    if c != 0:
        print()
    for i in range(4):
        if lis[i] < li[i]:
            print(money[i],li[i] - lis[i])
    c = 1


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  sort(all(a));
  ll c=-INF;
  int ans=0;
  rep(i,n){
    if (a[i].first-a[i].second>=c){
      c=a[i].first+a[i].second;
      ans++;
    }
    else{
      c=min(c,a[i].first+a[i].second);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count = 0;
        String result = "";

        if (S.charAt(2) == S.charAt(3)) {
            count++;
        }

        if (S.charAt(4) == S.charAt(5)) {
            count++;
        }

        if (count == 2) {
            result = "Yes";
        } else {
            result = "No";
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35820
#include <iostream>
#include <string>
#include <cstring>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

void bubble(int si[],char sc[],int N)
{
  for(int i=0;i<N;i++)
  {
    for(int j=N-1;j>i;j--)
    {
      if(si[j]<si[j-1])
      {
        swap(si[j],si[j-1]);
        swap(sc[j],sc[j-1]);
      }
    }
  }
}

void selection(int si[],char sc[],int N)
{
  for(int i=0;i<N;i++)
  {
    int mini = i;
    for(int j=i;j<N;j++)
    {
      if(si[j]<si[mini]) mini=j;
    }
    swap(si[i],si[mini]);
    swap(sc[i],sc[mini]);
  }
}

int main()
{
  int N; cin>>N;
  char sc_1[N],sc_2[N];
  int si_1[N],si_2[N];
  REP(i,N) cin>>sc_1[i]>>si_1[i];;

  memcpy(sc_2,sc_1,sizeof(char)*N);
  memcpy(si_2,si_1,sizeof(int)*N);

  bubble(si_1,sc_1,N);
  selection(si_2,sc_2,N);
  REP(i,N)
  {
    if(i) cout<<' ';
    cout<<sc_1[i]<<si_1[i];
  }
  cout<<endl;
  cout<<"Stable"<<endl;

  REP(i,N)
  {
    if(i) cout<<' ';
    cout<<sc_2[i]<<si_2[i];
  }
  cout<<endl;

  bool stable=true;
  REP(i,N) if(sc_2[i]!=sc_1[i]) stable = false;
  if(stable){
    cout<<"Stable"<<endl;
  }else{
    cout<<"Not stable"<<endl;
  }
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> h;

int main()
{
    cin >> N;
    h.resize(N);
    cin >> h;
    vector<int> dp(N, 1E9);
    dp[0] = 0;
    REP(i, N - 1)
    {
        Min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i < N - 2) Min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n , d ;
	re(n,d);
	cout << (n+2*d)/(2*d+1) ;
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3640
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int a[3],mn=1000000000,mx=-1000000000;
	for(int i=0;i<3;i++){
		cin>>a[i];
		mn=min(mn,a[i]);
		mx=max(mx,a[i]);
	}
	int mid;
	for(int i=0;i<3;i++){
		if(a[i]!=mn&&a[i]!=mx){
			mid=a[i];
		}
	}
	cout<<(mid-mn)+(mx-mid);
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    cin>>a;
    if(a.size()==2){
        cout<<a<<endl;
    }else{
        for(int i=2;i>=0;i--){
            cout<<a[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	/* 入力 */
	String w = scan.next();
	int[] eng = new int[26];

	/* 文字数カウント */
	for(int i = 0; i < w.length(); i++){
	    eng[w.charAt(i)-97]++;
	}

	/* 遇奇判定 */
	int flag = 1;
	for(int i = 0; i < 26; i++){
	    if(eng[i] % 2 != 0){
		flag = -1;
		break;
	    }
	}

	if(flag == 1){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

//頂点の右と下に何個黒が存在しているのかを判定する関数を作る。

ll memo[101][101];
int done[101][101];

ll dp(int n, int m, vector<vector<int> > data)
{
    if (done[n][m] == 1)
    {
        return memo[n][m];
    }
    ll res = 0;
    if (m + 1 == data[0].size() && n + 1 == data.size())
    {
      
        return 0;
    }
    else if (m + 1 == data[0].size()) //mが一番右の時
    {
      
        if (data[n + 1][m] == 1 && data[n][m] == 0)
        {
            res += 1;
            res += dp(n + 1, m, data);
        }
        else
        {
            res += dp(n + 1, m, data);
        }
        memo[n][m] = res;
        done[n][m] = 1;

        return res;
    }
    else if (n + 1 == data.size())
    {
     
        if (data[n][m + 1] == 1 && data[n][m] == 0)
        {
            res += 1;
            res += dp(n, m + 1, data);
        }
        else
        {
            res += dp(n, m + 1, data);
        }
        memo[n][m] = res;
        done[n][m] = 1;
        return res;
    }
    else
    {
      
        ll res2 = 0;
        ll res3 = 0;
        if (data[n + 1][m] == 1 && data[n][m] == 0)
        {
            res2 += 1;
            res2 += dp(n + 1, m, data);
        }
        else
        {
            res2 += dp(n + 1, m, data);
        }
        if (data[n][m + 1] == 1 && data[n][m] == 0)
        {
            res3 += 1;
            res3 += dp(n, m + 1, data);
        }
        else
        {
            res3 += dp(n, m + 1, data);
        }
        res = min(res2, res3);
        memo[n][m] = res;
        done[n][m] = 1;
       

        return res;
    }
}

int main()
{

    int H, W;
    cin >> H >> W;
    vector<vector<int> > data(H, vector<int>(W));
    rep(i, H)
    {
        rep(j, W)
        {
            char a;
            cin >> a;
            if (a == '.')
            {
                data[i][j] = 0; //白の時は0
            }
            else if (a == '#')
            {
                data[i][j] = 1; //白の時は0
            }
        }
    }
 
  

    int res = dp(0, 0, data);
    if (data[0][0] == 1)
    {
        res += 1 ;

    }
    cout << res;
    return 0;
}



Measured memory_bytes: 8960
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

#define loop(i, a, b) for(int i = a; i < b; i++)

int main()
{
  int a, b, c = 0;
  
  while(1) {
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    if (c++)cout << endl;
    int cnt = 0;
    loop(i, a, b + 1) {
      if(i % 400 == 0) { cout << i << endl; cnt++; }
      else if(i % 100 && i % 4 == 0) { cout << i << endl; cnt++; }
    }
    if (!cnt)  cout << "NA" << endl;

  }
}

Measured memory_bytes: 1160
//SkGeN
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
vector<ll> ed[N];
ll val[N] , vis[N];
ll n , q;

void dfs(ll node , ll par , ll vv) {
	ll sum = vv;
	val[node] += sum;
	for(auto i : ed[node]) {
		if(i == par) continue;

		dfs(i , node , val[node]);
	}
}

void solve() {
	cin>>n>>q;
	for(int i = 0; i < n - 1; i++) {
		ll u ,v ;
		cin>>u>>v;
		ed[u].pb(v);
		ed[v].pb(u);
	}

	for(int i = 0 ; i < q ; i++) {
		ll node , vv ;
		cin>>node>>vv;
		val[node] += vv;
	}


	dfs(1,-1 , 0);

	for(int i = 1; i <= n ; i++) {
		cout<<val[i]<<" ";
	}
}
int main()
{
	DANGER;
	ll t = 1;
	//cin>>t;
	while(t--) {
		solve();
	}
return 0;
}
//---->O ,,

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

int main() {
	int h, w;
	char a[110][110];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << '#';
		for (int j = 0; j < w; j++) {
			cout << a[i][j];
		}
		cout << '#' << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int x = Integer.parseInt(sa[1]);
		br.close();

		if (x == 1 || x == 2 * n - 1) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");

		if (n == 2) {
			System.out.println("1");
			System.out.println("2");
			System.out.println("3");
			return;
		}

		int[] center = {x - 2, x + 1, x, x - 1};
		int min = x - 2;
		if (x == 2) {
			center[0] = x + 2;
			center[1] = x - 1;
			center[3] = x + 1;
			min = x - 1;
		}
		int num = 0;
		for (int i = 0; i < n - 3; i++) {
			num++;
			if (num == min) {
				num += 4;
			}
			System.out.println(num);
		}
		for (int i = 0; i < 4; i++) {
			System.out.println(center[i]);
		}
		for (int i = 0; i < n - 2; i++) {
			num++;
			if (num == min) {
				num += 4;
			}
			System.out.println(num);
		}
	}
}


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


int main() {
  int n, ans = 0;
  cin >> n;
  rep(i,n) {
    int x; cin >> x;
    if(i%2==0&&x%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
n = gets.split("").map(&:to_i).reverse

n.push(0)
len = n.length
ans = 0
i = 0

while i <= len - 1
    if n[i] <= 4
        ans += n[i]
    elsif n[i] > 5 && n[i] < 10
        ans += 10 - n[i]
        n[i + 1] += 1
    elsif n[i] == 5
        if n[i + 1] < 5
            ans += n[i]
        else
            ans += n[i]
            ans += 9 - n[i + 1]
            n[i + 2] += 1
            i += 1
        end
    else
        n[i + 1] += 1
    end
    i += 1
end

puts ans


Measured memory_bytes: 70300
#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 <time.h>

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::next_permutation;
using std::lower_bound;

long long max(long long a, long long b)
{
    if (a > b)
        return a;
    return b;
}
long long min(long long a, long long b)
{
    if (a > b)
        return b;
    return a;
}
typedef long long ll;
typedef pair<long long, long long> pii;
typedef pair<ll, ll> pll;

namespace MySpace{

};

#define forn(i, n) for (long long (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define int long long
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
ll n, m;
ll s[50000];
ll t[50000];
ll dp[2300][2300];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    cin >> n >> m;
    cout << (n >= m) * 10;
}


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

#define mx 200005
#define ll long long 
#define mod 1000000007

void IO()
{
     #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
}

int ar[mx];
char ch[mx];

int m,n,k,ii;

ll bigmod(ll e,ll x)
{
    if(!x)return 1;
    ll p=bigmod(e,x/2);
    p=(p*p)%mod;
    if(x%2)p=(p*e)%mod;
    return p;
}


void solve()
{
	scanf("%d",&n);
	ll sum=0;
	ll sq=0;
	for(int i=1;i<=n;i++)
	{
		ll x;
		scanf("%lld",&x);
		sum+=x;
		sq+=(x*x)%mod;
		sq%=mod;
		sum%=mod;
	}
	sum*=sum;
	sum%=mod;
	sum-=sq;
	//cout<<sum<<endl;
	sum%=mod;
	sum+=mod;
	sum%=mod;
	//cout<<sum<<endl;
	printf("%lld\n",((bigmod(2,mod-2)%mod)*sum)%mod );
}

int main()
{
	IO();

	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N, K;
    cin >> N >> K;
    int ans = N % K;
    int cand = abs(ans - K);
    ans = min(ans, cand);

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

    return 0;
}


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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if( b - a == c - b ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		
		while(!(string = reader.readLine()).equals("0")){
			int n = Integer.valueOf(string);
			int m = Integer.valueOf(reader.readLine()) - 1;
			int a = Integer.valueOf(reader.readLine()) - 1;
			int d = Integer.valueOf(reader.readLine());
			
			int node[][] = new int[n - 1][d];
			for(int i = 0; i < d; i++){
				string = reader.readLine();
				for(int j = 0; j < n - 1; j++){
					node[j][i] = string.charAt(j) - '0';
				}
			}
			
			if(doing(node, n, m, d) == a){
				System.out.println(0);
				continue;
			}else{
				boolean judge = false;
				x : for(int i = 0; i < d; i++){
					for(int j = 0; j < n - 1; j++){
						if(judge || node[j][i] == 1) continue;
						boolean l = false;
						boolean r = false;
						if(j == 0 || node[j - 1][i] == 0)
							l = true;
						if(j == n - 2 || node[j + 1][i] == 0)
							r = true;
						if(l && r){
							node[j][i] = 1;
							if(doing(node, n, m, d) == a){
								System.out.println((i + 1) + " " + (j + 1));
								judge = true;
								break x;
							}
							node[j][i] = 0;
						}
					}
				}
				if(!judge) System.out.println(1);
			}
		}
		reader.close();
	}
	
	public static int doing(int node[][], int n, int s, int d){
		for(int i = 0; i < d; i++){
			if(s > 0 && node[s - 1][i] == 1) s--;
			else if(s < n - 1 && node[s][i] == 1) s++;
		}
		return s;
	}
}

Measured memory_bytes: 24324
package main

import "fmt"

func main() {
  var n int
  var ans int64

  fmt.Scan(&n)

  ans = 1

  for i := 0; i < n; i++ {
    var t int64
    fmt.Scan(&t)
    ans = lcm(ans, t)
  }
  fmt.Println(ans)
}

func gcd(x, y int64) int64 {
  if y == 0 {
    return x
  } else {
    return gcd(y, x % y)
  }
}

func lcm(x, y int64) int64 {
  return x / gcd(x, y) * y
}

Measured memory_bytes: 512