akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

// #define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; string S; cin >> N >> S;
  if(N % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  string s1 = S.substr(0, N/2), s2 = S.substr(N/2, N/2);
  cout << (s1==s2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int count = 0;
    int m = n;
    while(m > 0){
        count += m % 10;
        m /= 10;
    }
    if(n % count == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

string s;
int a,b;

int main(){
	for(int i=0;i<9;i++){
		cin>>s>>a>>b;
		cout<<s<<' '<<a+b<<' '<<200*a+300*b<<endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i,n) cin>>v[i];

    int ans=0;
    rep(l,n+1){
        rep(r,n+1){
            if(l+r>n) continue;
            int rest=k-(l+r);
            if(rest<0) continue;

            vector<int> has;
            rep(i,l) has.push_back(v[i]);
            rep(i,r) has.push_back(v[n-1-i]);
            sort(all(has));

            int sm=0;
            for(auto e : has) sm+=e;
            int nn=has.size();
            rep(i,min(rest,nn)){
                if(has[i]<0) sm-=has[i];
            }
            ans=max(ans,sm);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.*;

public class Main {
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


    }

    public static void main(String[] args) {
        FastReader s = new FastReader();
        Main obj = new Main();
        long sum=0;
        long h=s.nextLong();
        if(h==1)
            System.out.println(1);

        else
        {
            long count=1;
            while(h>1)
            {
                h=h/2;
                sum+= (long) Math.pow(2,count);
                count++;
            }
            System.out.println(sum+1);
        }
    }






}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
int main(void){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int res=a[n-1];
    rep(i,n-1) res=gcd(res,a[i]);
    cout<<res<<endl;
}


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

int main() {
	int n,m;
	int ara[1000];
	cin>>n>>m;
	
	for (int i=0;i<n;i++){
		cin>>ara[i];
	}
	sort(ara,ara+n);
	int s=0;
	for (int i=0;i<m;i++){
		s=s+ara[i];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3640
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min,max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(d:usize);
    print!("Christmas");
    for i in 0..25-d {
        print!(" Eve");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#define INF 999999
int main(){
	int n,m,s[256],i,j,ta=0,tb=0,suma=INF,sumb=INF;
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)break;
		for(i=0;i<n+m;i++)scanf("%d",&s[i]);
		ta=0;
		tb=0;
		suma=INF;
		sumb=INF;
		for(i=0;i<n;i++)ta+=s[i];
		for(i=n;i<n+m;i++)tb+=s[i];
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(ta-s[i]+s[n+j]==tb+s[i]-s[n+j]){
					if(suma+sumb>s[i]+s[n+j]){
						suma=s[i];
						sumb=s[n+j];
					}
				}
			}
		}
		if(suma==INF||sumb==INF)printf("-1\n");
		else printf("%d %d\n",suma,sumb);
	}
	return 0;
}

Measured memory_bytes: 1040
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 800010
vector<pair<int, int> >a[N];
vector<pair<int, int> >aa;
vector<pair<int, int> >b;
int val[N];
int wgt[N];
int n, k, nn, kk, mx, sz, q, lim, vec, xx, yy, zz;
int x, y, z;
int ans;
int main() {
	scanf("%d", &n);
	x = n + 1;
	y = 0;
	while (x > 1) {
		x /= 2;
		y++;
	}
	y = min(11, y);
	k = 1;
	f(i, y)k *= 2;
	f(i, n) {
		scanf("%d %d", &val[i + 1], &wgt[i + 1]);
	}
	a[1].push_back(make_pair(0, 0));
	a[1].push_back(make_pair(wgt[1], val[1]));
	for (int i = 2; i < k; i++) {
		x = i / 2;
		sz = a[x].size();
		aa = a[x];
		f(j, sz) {
			y = a[x][j].first + wgt[i];
			z = a[x][j].second + val[i];
			aa.push_back(make_pair(y, z));
		}
		sort(aa.begin(), aa.end());
		sz *= 2;
		mx = -1;
		f(j, sz) {
			if (mx < aa[j].second) {
				a[i].push_back(aa[j]);
				mx = aa[j].second;
			}
		}
	}
	scanf("%d", &q);
	f(qq, q) {
		scanf("%d %d", &vec, &lim);
		b.clear();
		b.push_back(make_pair(0, 0));
		while (vec >= k) {
			aa = b;
			sz = b.size();
			f(j, sz) {
				y = b[j].first + wgt[vec];
				z = b[j].second + val[vec];
				aa.push_back(make_pair(y, z));
			}
			sort(aa.begin(), aa.end());
			b.clear();
			sz *= 2;
			mx = -1;
			f(j, sz) {
				if (mx < aa[j].second) {
					b.push_back(aa[j]);
					mx = aa[j].second;
				}
			}
			vec /= 2;
		}
		sz = a[vec].size();
		x = 0;
		y = b.size();
		y--;
		ans = 0;
		while ((x < sz) && (y >= 0)) {
			xx = (a[vec][x].first) + (b[y].first);
			yy = (a[vec][x].second) + (b[y].second);
			if (xx <= lim) {
				ans = max(ans, yy);
				x++;
			}
			else {
				y--;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 45656
from collections import deque

H, W = map(int, input().split())
CH, CW = map(int, input().split())
DH, DW = map(int, input().split())

S = []
for _ in range(H):
    S.append(list(input()))

d = [[-1 for i in range(W)] for j in range(H)]

Q = deque([[CH - 1, CW - 1, 0]])

while Q:
    x, y, cnt = Q.popleft()
    if d[x][y] != -1:
        continue
    d[x][y] = cnt

    for tx in range(-2, 3):
        for ty in range(-2, 3):
            nx = x + tx
            ny = y + ty
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                if abs(tx) + abs(ty) == 1:
                    Q.appendleft([nx, ny, cnt])
                elif abs(tx) + abs(ty) >= 2:
                    Q.append([nx, ny, cnt + 1])

ans = d[DH - 1][DW - 1]

# print(f'{d=}')
print(ans)


Measured memory_bytes: 263728
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<usize>();
    let mut sum_jp:f64 = 0.0;
    let mut sum_btc:f64 = 0.0;
    for _ in 0..n{
        let t = read_vec::<String>();
        if t[1] == "JPY" {
            sum_jp += t[0].parse::<f64>().unwrap();
        } else {
            sum_btc += t[0].parse::<f64>().unwrap();
        }
    }
    let ans = sum_jp + (sum_btc*380000.0);
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  string output;
  int point;
  cin >> s;
  point = 0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B'){
      //output.at(point) = '';
      //point = max(point-1,0);
      if(output.size()!=0)output.pop_back();
    }else{output += s.at(i);
          //point++;
         }
  }
  cout << output << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	unsigned long long a=1;
	int w=0;
	int i;
	scanf("%d",&n);
for(i=1;i<=n;i++){
	a=a*i%(1000000000+7);
	//printf("%lld\n",a);
}
printf("%lld\n",a);
	
	return 0;
}

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

int n, d, x;

int main() {
  cin >> n >> d >> x;
  vector<int> a(n);
  rep (i, n) {
    cin >> a.at(i);
  }
  rep (i, n) {
    x += d%a.at(i) == 0 ? d/a.at(i) : d/a.at(i)+1;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri May 29 19:25:06 2020

@author: naoki
"""
import sys

A,B,C,D = map(int,input().split())
time = [A,B,C,D]
time.sort()
if B <= C or D <= A:
    print(0)
    sys.exit()
else:
    print(time[2]-time[1])
    
    

Measured memory_bytes: 3060
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)


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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(N - 1), b(N - 1);
    vector<vector<int>> edge(N, vector<int>(0));
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
    }
    int K = 0;
    rep(i, N) {
        if (K < edge[i].size()) K = edge[i].size();
    }
    queue<vector<int>> q;
    vector<bool> done(N, false);
    q.push({0, 0});
    map<vector<int>, int> m;
    while (q.size()) {
        int v = q.front()[0], c = q.front()[1];
        done[v] = true;
        q.pop();
        rep(i, edge[v].size()) {
            int u = edge[v][i];
            if (done[u]) continue;
            c++;
            m[{min(u, v), max(u, v)}] = c % K;
            q.push({u, c % K});
        }
    }
    cout << K << endl;
    rep(i, N - 1) {
        cout << m[{a[i], b[i]}] + 1 << endl;
    }
}

Measured memory_bytes: 17792
(N, M) = list(map(int, input().split()))
ans = []
for k in range(N):
  ans.append(0)
for i in range(M):
  (a, b) = list(map(int, input().split()))
  ans[a-1] += 1
  ans[b-1] += 1

for i in ans:
  print(i)


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=50005;
const int maxm=1000005;
int n,m,q,mod,g;
int u[maxn],v[maxn],c[maxn];
bool valid[2][maxm];
namespace Dsu{
	int f[maxn*6];
	void init(){
		rep(i,n*6)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
	int merge(int x,int y){
		f[find(x)]=find(y);
	}
}
int getid(int x,int f1,int f2){
	return x*6+f2*2+f1;
}

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

int main(){
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	Dsu::init(); 
	g=mod;
	rep(i,m){
		scanf("%d%d%d",&u[i],&v[i],&c[i]);
		u[i]--;v[i]--;
		g=gcd(g,abs(c[i]-c[0]));
	}
	if(mod/g%3==0)mod=3*g;
	else mod=g;
	int z=c[0]%g;
	rep(i,m){
		int w=(c[i]-z)/g%3;
		rep(f1,2)rep(f2,3){
			Dsu::merge(getid(u[i],f1,f2),getid(v[i],f1^1,(f2*2+w)%3));
			Dsu::merge(getid(v[i],f1,f2),getid(u[i],f1^1,(f2*2+w)%3));
		}
	}
	for(int i=0,j=z;i<2*mod;i++,j=2LL*j%mod)
		valid[i&1][j]=true;
	while(q--){
		int s,t,r;
		scanf("%d%d%d",&s,&t,&r);
		s--;t--;
		bool ok=false;
		rep(f1,2)rep(f2,3){
			if(Dsu::find(getid(s,f1,f2))==Dsu::find(getid(t,0,0))){
				if(valid[f1][(r+z+(3-f2)*g)%mod]){
					ok=true;
					break;
				}
			}
		}
		puts(ok?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <vector>
#include <string.h>
using namespace std;

#define abs(x) ((x) > 0 ? (x) : -(x))
bool prime[11000000];
bool b[11000000];
int n;
bool used[210], go[210][210];
int ans;
int ind[210];
int cnt0, cnt1;
int m;
int Link[210];

bool fi(int x) {
	for (int i = 1; i <= m; i++)
		if (go[x][i] && !used[i]) {
			used[i] = true;
			if (!Link[i] || fi(Link[i])) {
				Link[i] = x;
				return true;
			}
		}
	return false;
}

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= 10000000; i++)
		prime[i] = true;
	for (int i = 1; i * i <= 10000000; i++)
		if (prime[i])
			for (int j = i * i; j <= 10000000; j += i)
				prime[j] = false;
	prime[2] = false;

	for (int i = 1; i <= n; i++) {
		int t;
		scanf("%d", &t);
		b[t] ^= 1;
		b[t + 1] ^= 1;
	}
	for (int i = 1; i <= 10000001; i++)
		if (b[i]) {
			m += 1;
			ind[m] = i;
		}
	for (int i = 1; i <= m; i++)
		if (ind[i] % 2 == 0) {
			cnt0 += 1;
			for (int j = 1; j <= m; j++)
				if (ind[j] % 2 == 1 && prime[abs(ind[i] - ind[j])])
					go[i][j] = true;
		}
	int ans = 0;
	for (int i = 1; i <= m; i++)
		if (ind[i] % 2 == 0) {
			memset(used, false, sizeof used);
			if (fi(i))
				ans += 1;
		}
	int aa = ans;
	cnt1 = m - cnt0;
	// printf("?? %d %d\n", cnt0, cnt1);
	cnt0 -= ans;
	cnt1 -= ans;
	if (cnt0 % 2 == 0)
		aa += cnt0 + cnt1;
	else
		aa += 3 + (cnt0 - 1) + cnt1 - 1;
	printf("%d\n", aa);
}


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

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		if (b == 'H')cout << 'H' << endl;
		else cout << 'D' << endl;
	}
	else {
		if (b == 'H')cout << 'D' << endl;
		else cout << 'H' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>

using namespace std;

#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

typedef long long ll;
const int Mod = static_cast<int>(1e9 + 7);

int main()
{
	int s, w;
	cin >> s >> w;
	if (s <= w)  cout << "unsafe" << endl;
	else  cout << "safe" << endl;
}

Measured memory_bytes: 3132
using System;
public class Program{
    public static void Main(){
        string[] s=Console.ReadLine().Split();
        int a=int.Parse(s[0]);
        int b=int.Parse(s[1]);
        int c=int.Parse(s[2]);
        
        int min=a;
        if(min>b)min=b;
        if(min>c)min=c;
        if(min==a){
            if(a+b<a+c){
                Console.WriteLine(a+b);
            }else{
                Console.WriteLine(a+c);
            }
        }else if(min==b){
            if(b+a<b+c){
                Console.WriteLine(b+a);
            }else{
                Console.WriteLine(b+c);
            }
        }else{
            if(c+a<c+b){
                Console.WriteLine(c+a);
            }else{
                Console.WriteLine(c+b);
            }
        }
    }
}


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

const int N = 1e5 + 5;
long long dp[N][2];
vector<int>a[N];
const int m = 1e9 + 7;
long long solve(int u, int c, int p){
    if(dp[u][c] != -1) return dp[u][c];
    long long ans = 1;
    for(auto v : a[u]){
        if(v == p) continue;
        if(c == 0){
            ans = (ans *(solve(v, 0, u) + solve(v, 1, u)) )%m;
        }
        else ans = (ans * solve(v, 0, u)) % m;
    }
    dp[u][c] = ans;
    return ans;
}
int main(){
    int n, x, y;
    cin >> n;
    for(int i = 1; i < n; i++){
        cin >> x >> y;
        x --, y --;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    memset(dp, -1, sizeof(dp));
    long long ans = (solve(0, 0, -1) + solve(0, 1, -1))%m;
    cout << ans << "\n";
    return 0;
}

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

inline int num (const std::string& S, int idx){ return S.at(idx) - '0'; }
inline unsigned int bitMask(int i){ return (1 << i); }
inline bool isTrue(unsigned int bit, int i){ return bit & bitMask(i); }
inline bool isEven(int num) { return !num%2; }
inline bool isOdd(int num) { return num%2; }

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a==c || b==c){
		cout << "No" << endl;
		return 0;
	}
	if( a + b >= c ){
		cout << "No" << endl;
		return 0;
	}
	long double ld_a, ld_b, ld_c;
	ld_a = a;
	ld_b = b;
	ld_c = c;
	//if( sqrt(ld_a)+sqrt(ld_b) < sqrt(ld_c) ){
	if( 2.0*sqrt(ld_a*ld_b) < ld_c - ld_a - ld_b ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
ans = 0
ans += abs(abs(y) - abs(x))
if abs(x) <= abs(y):
    if x < 0:
        ans += 1
    if y < 0:
        ans += 1
else:
    if x >= 0:
        ans += 1
    if y > 0:
        ans += 1
print(ans)


Measured memory_bytes: 9040
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back

using namespace std;
using ll=long long;
// using ll=int;

const ll mod = (ll)(1e9+7);

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){

    /*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("myoutput.txt", "w", stdout);
    #endif
    */

    fast;
    ll t = 1;
    //cin >> t;
    while(t--){
        ll n, m; cin >> n >> m;
        if(n == m) cout << "Yes\n";
        else cout << "No\n";
        
    }
    // cerr << (double)clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 998244353;
const i64 INF = 2e15;

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

	int a, b, c;
	cin >> a >> b >> c;

	int d = a - b;

	if (d > c) cout << 0 << endl;
	else cout << c - d << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

N, M = map(int, input().split())
box = 1
b = []
a = []
for i in range(N):
    a.append(1)
    b.append(0)
a.append(1)
b.append(0)

b[1] = 1

for i in range(M):
    x, y = map(int, input().split())
    if b[x] == 1:
        if a[x] == 1:
            b[x] = 0
        b[y] = 1
    a[x] -= 1
    a[y] += 1
cnt = 0
for i in range(N + 1):
    if b[i] == 1:
        cnt += 1
print(cnt)



Measured memory_bytes: 4748
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long int

int main(void) {
    char s[11];
    scanf("%s", s);
    int n = (int)strlen(s);
    ll total = 0, a;
    int b;
    for(int i = 0; i < n; i++) {
        a = 0;
        for(int j = i; j < n; j++) {
            a = 10 * a + s[j] - '0';
            b = n - 1 - (j - i);
            if(i > 0) b--;
            if(j + 1 < n) b--;
            total += a << b;
        }
    }
    printf("%lld\n", total);
    return 0;
}


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

int main(){
long long a,b,c,K;
  cin>>a>>b>>c>>K;
  if(K%2==0){
    cout<<a-b<<endl;
  }
  else{
 cout<<b-a<<endl;   
}
}

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

int main() {
	long n, a, min_a = 10000000, max_a = -10000000, sum_a = 0;
	cin >> n;
	cin >> a;
	min_a = a;
	max_a = a;
	sum_a = a;
	for (long i=1; i != n; ++i){
		cin >> a;
		sum_a += a;
		if (a > max_a){
			max_a = a;
		}else if (a < min_a){
			min_a = a;
		}
	}
	cout << min_a << ' ' << max_a << ' ' << sum_a << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
#define KEYMAX 2000000000

int parent(int);
int left(int);
int right(int);

int main(){
  int H, i;
  int A[MAX+1];
  scanf("%d",&H);
  if(H > 250)
    exit(1);
  for(i = 1; i <= H; i++){
    scanf("%d",&A[i]);
    if(A[i] < (KEYMAX * (-1)) || A[i] > KEYMAX)
      exit(1);
  }

  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)
      printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H)
      printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H)
      printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}



Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int sigma(int n) {
    int ans = n*(n+1)/2;
    return ans;
}
double kitaiti(int n) {
    double ans = (double)sigma(n)/n;
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    ll max = 0;
    ll sum = 0;
    int maxi;
    int p[220000];
    rep(i,n) cin >> p[i];
    rep(i,k) {
        sum += p[i];
    }
    for (int i = 1; i <=(n-1)-(k-1); i++) {
        sum = sum - p[i-1] + p[i+k-1];
        if(sum > max) {
            max = sum;
            maxi = i;
        }
    }
    double answer = 0;
    for(int i = maxi; i < maxi+k; ++i) {
        answer += kitaiti(p[i]);
    }
    cout << fixed << setprecision(10) << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
string print(string, int, int);
string reverse(string, int, int);
string replace(string, int, int, string);

string print(string str, int a,int b) {
  string ans="";
  for(int i = a; i < b+1; i++) {
    ans += str[i];
  }
  return ans ;
}
string reverse(string str, int a, int b) {
  string ans="";
  REP(i,a) {
    ans+=str[i];
  }
  for(int i=b;i>=a;i--) {
    ans+=str[i];
  }
  for(int i=b+1;i < str.length();i++) {
    ans+=str[i];
  }
  return ans;
}
string replace(string str, int a, int b, string p) {
  string ans="";
  REP(i,str.length()) {
    if(a<=i&&i<=b) {
      ans+=p[i-a];
    } else {
      ans+=str[i];
    }
  }
  return ans;
}

int main() {
  string str,p;
  int n,a,b;
  cin >> str >> n;
  string ans,s;
  REP(i,n) {
    cin >> s;
    if(s=="print") {
      cin >> a >> b;
      ans = print(str,a,b);
      cout << ans << endl;
    } else if(s=="reverse") {
      cin >> a >> b;
      str = reverse(str,a,b);
    } else if(s=="replace") {
      cin >> a >> b >> p;
      str = replace(str,a,b,p);
    }
  }
  
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;
 
signed main(){
    ll h,w;
    cin >> h >> w;
    char c[h][w];
    rep(i,0,h) rep(j,0,w) cin >> c[i][j];
    ll memo[h][w] = {};

    rep(i,0,h){
        ll cnt1 = 0,cnt2 = 0;
        rep(j,0,w){
            memo[i][j] += cnt1++;
            if(c[i][j] == '#') cnt1 = 0;

            memo[i][w-j-1] += cnt2++;
            if(c[i][w-j-1] == '#') cnt2 = 0;
        } 
    }
    rep(i,0,w){
        ll cnt1 = 0,cnt2 = 0;
        rep(j,0,h){
            memo[j][i] += cnt1++;
            if(c[j][i] == '#') cnt1 = 0;

            memo[h-j-1][i] += cnt2++;
            if(c[h-j-1][i] == '#') cnt2 = 0;
        } 
    }
    ll ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            if(c[i][j] == '#') continue;
            ans = max(ans,memo[i][j]);
        } 
    }

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


Measured memory_bytes: 35456
#include<iostream>

const int INF = 1 << 24;
int m, n, a[100];//dansu, honsu
bool C(double x){
	int i = 0, j = 0, l = 0;
	while(i < n && j < m){
		if(l + a[i] <= x){//入る
			l += a[i];
			i++;
		}else{//もう入らない
			l = 0;
			j++;
		}
	}

	if(i == n && j < m)return true;
	return false;
}

int main(){
	while(std::cin >> m >> n, m){
		for(int i=0;i<n;i++){
			std::cin >> a[i];
		}

		int lb = 0, ub = INF;

		for(int i=0;i<100;i++){
			int mid = (lb + ub) / 2;
			if(C(mid))ub = mid;
			else lb = mid;
		}

		std::cout << ub << std::endl;
	}
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
int digitsum(int n,int k=10){
	int ans=0;
	while(n>0){
		ans+=n%k;
		n/=k;
	}
	return ans;
}
int main(){
    int n,m=1e9;
    scanf("%d",&n);
    for(int a=1;a<n;a++){
        m=std::min(m,digitsum(a)+digitsum(n-a));
    }
    printf("%d",m);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll arr[n];
	input(arr,n);
	sort(arr,arr+n);
	vector<pair<ll,ll> >v;ll ans;
	if(n==2)
	{
			if(arr[1]-arr[0]>arr[0]-arr[1])
			cout<<arr[1]-arr[0]<<endl<<arr[1]<<" "<<arr[0]<<endl;
			else
			cout<<arr[0]-arr[1]<<endl<<arr[0]<<" "<<arr[1]<<endl;
			return 0;
	}
	if(arr[0]<0&&arr[n-1]>=0)
	{
		ll pos=n-1;
		for(ll i=n-1;i>=0;i--)
		if(arr[i]>0)pos=i;
		for(ll i=pos;i<n-1;i++)
		v.push_back({arr[0],arr[i]}),
		arr[0]-=arr[i];
		for(ll i=0;i<pos;i++)
		v.push_back({arr[n-1],arr[i]}),
		arr[n-1]-=arr[i];
		ans=arr[n-1];
	}
	else if(arr[n-1]<0)
	{
		for(ll i=0;i<n-1;i++)
		v.push_back({arr[n-1],arr[i]}),
		arr[n-1]-=arr[i];
		ans=arr[n-1];
	}
	else
	{
	
		
		v.push_back({arr[0],arr[1]});
		arr[1]=arr[0]-arr[1];
		for(ll i=2;i<n-1;i++)
		v.push_back({arr[1],arr[i]}),
		arr[1]-=arr[i];
		v.push_back({arr[n-1],arr[1]});
		ans=arr[n-1]-arr[1];
	}
	cout<<ans<<endl;
	for(ll i=0;i<v.size();i++)
	cout<<v[i].f<<" "<<v[i].s<<endl;
}

Measured memory_bytes: 4336
// D.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	bool odd = false;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a % 2) {
			odd = true;
		}
	}
	cout << (odd ? "first" : "second") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int k, n;
    cin >> k>>n;
    int a[n];
    for(int i = 0; i< n; i++){
        cin >> a[i];
    }
    int max = 0;
    for(int i = 1; i < n; i++){
        if((a[i] - a[i-1]) > max)max = a[i] - a[i-1];
    }
    if((a[0] + k - a[n-1]) > max)max = (a[0] + k - a[n-1]);
    cout << k - max<< endl;
    return 0;

}


Measured memory_bytes: 1024
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = list(map(int, r.split()))
    a, b = map(int, input().split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    cnt = 0
    if a-b == 0:
        print('Yes')
    else:
        print('No')

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
N, M = input().split(' ')
N = int(N)
M = int(M)
min = 1
max = N
for i in range(M):
  l, m = input().split(' ')
  l = int(l)
  m = int(m)
  if min>m or max<l:
    print(0)
    break 
  if min < l:
    min = l
  if max > m:
    max = m
else:
  print(max-min+1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>
#define vec2(var, n, m)  vector<vector<int>> var(n, vector<int>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  string a, b;
  cin >> a >> b;

  if(a.size()<b.size()){
    prt("LESS");
    return 0;
  } else if(a.size()>b.size()){
    prt("GREATER");
    return 0;
  }

  rep(i,a.size()){
    if(a[i]<b[i]){
      prt("LESS");
      return 0;
    } else if(a[i]>b[i]){
      prt("GREATER");
      return 0;
    }
  }

  prt("EQUAL");

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
long long l[61],r[61];
void get(long long k1,int k2,int k3){
	if (k1==1){
		if (k2==1) putchar('1'); else putchar('0');
		return;
	}
	long long now=1ll<<(k1-1);
	//cout<<k2-now<<" "<<now<<" "<<l[k1-1]<<" "<<r[k1-1]<<endl;
	if (k1%2==0) now=-now;
	if (k2-now>=l[k1-1]&&k2-now<=r[k1-1]){
		putchar('1');
		get(k1-1,k2-now,1);
	} else {
		if (k3) putchar('0');
		get(k1-1,k2,k3);
	}
}
int main(){
	scanf("%d",&n);
	l[0]=r[0]=0;
	for (int i=1;i<=60;i++){
		long long now=1ll<<(i-1);
		if (i%2==0) now=-now;
		if (now>0) l[i]=l[i-1],r[i]=r[i-1]+now;
		else l[i]=l[i-1]+now,r[i]=r[i-1];
	}
	if (n==0){
		puts("0"); return 0;
	}
	get(60,n,0); puts("");
}

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

int main()
{
    string S;
    int cnt[26] = {};
    bool flag = false;

    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        cnt[S[i] - 'a']++;
        if(cnt[S[i] - 'a'] >= 2) flag = true;
    }

    if(flag) cout << "no" << endl;
    else cout << "yes" << endl;

    return (0);
}


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

string ans;
char con[11];

char NOT(char a){
  if(a=='T')return 'F';
  return 'T';
}
char AND(char a,char b){
  if(a=='T' && b=='T')return 'T';
  return 'F';
}
char OR(char a,char b){
  if(a=='F' && b=='F')return 'F';
  return 'T';
}
char IMP(char a,char b){
  if(a=='T' && b=='F')return 'F';
  return 'T';
}

char cal(string s)
{
  stack<char> S;

  for(int i=0;i<s.length();i++){
    if(s[i]==')'){
      while(!S.empty()){
	char a=S.top();S.pop();
	char b=S.top();S.pop();

        if(b=='('){
	  S.push(a);
	  break;
	}
	if(b=='-'){
	  S.push(NOT(a));
	}
	if(b=='+'){
	  char c=S.top();S.pop();
	  while(S.top()=='-'){
	    S.pop();
	    c=NOT(c);
	  }
          S.push(OR(c,a));
	}
	if(b=='*'){
	  char c=S.top();S.pop();
	  while(S.top()=='-'){
	    S.pop();
	    c=NOT(c);
	  }
	  S.push(AND(c,a));
	}
	if(b=='>'){
	  S.pop();
	  char c=S.top();S.pop();
	  while(S.top()=='-'){
	    S.pop();
	    c=NOT(c);
	  }
          S.push(IMP(c,a));
	}
      }	  
    }
    else {
      if('a'<=s[i] && s[i]<='k')S.push(con[(s[i]-'a')]);      
      else S.push(s[i]);
    }
  }
  //cout<<S.top()<<endl;
  return S.top();
}

void dfs(string l,string r,int n)
{
  
  if(n==11){
    char a=cal( '('+l+')' ),b=cal( '('+r+')' );
    if(a!=b)ans="NO";
  }
  else {
    dfs(l,r,n+1);
    con[n]='T';
    dfs(l,r,n+1);
    con[n]='F';
  }
}

int main()
{
  string s,l,r;

  while(1){
    cin>>s;
    if(s[0]=='#')break;
    for(int i=0;i<11;i++)con[i]='F';
    for(int i=0;i<s.length();i++){
      if(s[i]=='='){
	l=s.substr(0,i);
	r=s.substr(i+1,s.length());
      }
    }
    ans="YES";
    dfs(l,r,0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	int angle = 90;
	double x = 0,
		   y = 0;

	double d, a;
	char c;
	while (cin >> d >> c >> a) {
		//cout << "d:" << d << ' ' << "a:" << a << endl;

		double dx, dy;
		dx = cos(angle * PI / 180) * d;
		dy = sin(angle * PI / 180) * d;

		x += dx;
		y += dy;

		angle -= a;
	}

	cout << (int)x << endl;
	cout << (int)y << endl;
}


Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

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

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

using namespace std;

int large[100001];
int small[100001];
int mod2[100001];
bool arrived[100001];
bool used[100001];
vector<int> edge[100001];
bool dfs(int V,int S,int L, int flag){
   //cout << V << ": " << S << "-" << L <<", "<< flag<<endl;
   if( arrived[V] || used[V] ) return true;
   if( S!=L && large[V]==small[V] ){
      if( S<=large[V] && large[V] <= L ) return true;
      return false;
   }
   arrived[V] = true;
   L=min(large[V],L);
   S=max(small[V],S);
   if( L%2!=flag ) L--;
   if (S%2!=flag ) S++;
   if( L < S ) return false;
   if( mod2[V] != -1 && mod2[V] != flag ) return false;
   //cout << V << ": " << S << "-" << L <<", "<< flag<<endl;
   large[V]=L;
   small[V]=S;
   mod2[V]=flag;
   for( int i = 0 ; i < (int)edge[V].size(); i++ ){
      if( arrived[edge[V][i]]!=true ){
         if( dfs( edge[V][i], S-1, L+1, 1-flag ) == false ){
            return false;
         }
      }
   }
   return true;
}
void dfs2(int V, int P){
   if( arrived[V] ) return ;
   arrived[V] = true;
   large[V]=P;
   small[V]=P;
   for( int i = 0 ; i < (int) edge[V].size(); i++ ){
      if( arrived[edge[V][i]] != true ){
         int next = edge[V][i];
         if( large[next] >= P+1 && small[next] <= P+1 ){
            dfs2(next,P+1);
         }
         else if( large[next] >= P-1 && small[next] <= P-1 ){
            dfs2(next,P-1);
         }
         else{
            cout <<" ERROR" << endl;
         }
      }
   }
}
int main(){
   int N;
   cin >> N;
   for( int i = 0 ; i < N+1; i++ ){
      large[i] = INT_MAX/2;
      small[i] = INT_MAX/-2;
   }
   for( int i = 0 ; i+1 < N ; i++ ){
      int A,B;
      cin >> A >> B;
      edge[A].push_back(B);
      edge[B].push_back(A);
   }
   int K;
   cin >> K;
   bool ok = true;
   memset( used, false,sizeof(used));
   memset( mod2, -1, sizeof(mod2));
   int Vs[K];
   int Ps[K];
   for( int i = 0 ; i <K; i++ ){
      int V,P;
      cin >> V>>P;
      small[V]=large[V]=P;
      Vs[i]=V;Ps[i]=P;
   }
   for( int i = 0 ; i <K; i++ ){
      if(ok){
         memset(arrived,false,sizeof(arrived));
         ok= dfs(Vs[i],Ps[i],Ps[i],Ps[i]%2);
         used[Vs[i]]=true;
      }
   }
   if( ok == false ){
      cout<< "No"<<endl;
      return 0;
   }
   else{
      cout << "Yes" << endl;
      memset(arrived,false,sizeof(arrived));
      dfs2(Vs[0], Ps[0]);
   }
   for( int i = 1 ; i <= N; i++ ){
      cout << large[i] << endl;
   }
   return 0;
}


Measured memory_bytes: 14208
from collections import defaultdict
import math

## 素因数分解実施用
def find(x):
  limit = math.sqrt(x)
  p = 2
  while True:
    if limit < p:
      d[x] += 1
      return 0
    if x%p == 0:
      d[p] += 1
      return find(x//p)
    p += 1
  
## 結果からいくつ取り出せる探す
def extract(y):
  cnt  = 1
  patn = 0
  while True:
    y -= cnt
    patn += 1
    cnt += 1
    ## 判定部分
    if y == 0:
      return patn
    elif y < 0:
      return patn-1

N = int(input())

d = defaultdict(int)

if N == 1:
  print(0)
else:
  _ = find(N)
  cnt = 0
  for i in d.keys():
    cnt += extract(d[i])
  print(cnt)

  

Measured memory_bytes: 9460
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	int i = 1;
	while(i * (i + 1) / 2 < n) i++;
	cout << i;
		
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define NIL -1
struct tree {
	int father,brother,left,right,deep,height;
};
struct tree t[30];
int node,i,k;
//递归查询深度，先左子结点再右子结点，直到是叶子结点
void setDeep(int u,int deep) {
	t[u].deep=deep;
	if(t[u].left!=NIL) setDeep(t[u].left,deep+1);
	if(t[u].right!=NIL) setDeep(t[u].right,deep+1);
}
//递归查询高度 先找左子结点，再找右子结点，直到是叶子结点，开始返回记录高度，h1左方向，h2右方向
int setHeight(int u) {
	int h1=0,h2=0;
	if(t[u].left!=NIL) h1=setHeight(t[u].left)+1;
	if(t[u].right!=NIL) h2=setHeight(t[u].right)+1;
	return t[u].height=(h1<h2 ? h2:h1);
}

int main() {
	int n,l,r;
	scanf("%d",&node);
	memset(t,-1,sizeof(t));
	for(i=0; i<node; i++) {
		scanf("%d%d%d",&n,&l,&r);
		t[n].left=l;
		t[n].right=r;
		t[l].father=n;
		t[l].brother=r;
		t[r].father=n;
		t[r].brother=l;
	}
	int root=0;
	for(k=0; k<node; k++)
		if(t[k].father==NIL) root=k;
	setDeep(root,0);
	setHeight(root);

	for(k=0; k<node; k++) {
		printf("node %d: parent = %d, sibling = %d, ",k,t[k].father,t[k].brother);
		if(t[k].left!=-1&&t[k].right!=-1) printf("degree = 2, ");
		else if(t[k].left!=-1||t[k].right!=-1) printf("degree = 1, ");
		else printf("degree = 0, ");
		printf("depth = %d, height = %d, ",t[k].deep,t[k].height);
		if(t[k].father==NIL) printf("root\n");
		else if(t[k].left==-1&&t[k].right==-1) printf("leaf\n");
		else printf("internal node\n");
	}
	return 0;
}


Measured memory_bytes: 2132
import itertools
H, W, K = map(int, input().split())
C = []
for _ in range(H):
    C.append(input())
r = 0
for i in range(1, H+1):
    for ii in itertools.combinations(range(H), i):
        for j in range(1, W+1):
            for jj in itertools.combinations(range(W), j):
                l = 0
                for x in [C[iii] for iii in ii]:
                    xx = [x[jjj] for jjj in jj]
                    l += len([xxx for xxx in xx if xxx == '#'])
                if l == K:
                    r += 1
print(r)

Measured memory_bytes: 69220
import bisect, heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

for i in range(1,N+1):
    a = bisect.bisect_right(A,i) - bisect.bisect_left(A,i)
    b = bisect.bisect_right(B,i) - bisect.bisect_left(B,i)

    if a + b > N:
        print("No")
        exit()

B = B[::-1]

j, bef = 0, -1
for i in range(N):
    if A[i] != bef:
        j = 0
    if A[i] == B[i]:
        while j < N:
            if A[j] != B[i] and B[j] != A[i]:
                B[i], B[j] = B[j], B[i]
                break
            j += 1
    bef = A[i]

print("Yes")
for b in B:
    print(b,end=" ")
print("")

Measured memory_bytes: 42040
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n, x, y, d, sum=0;
  	cin >> n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++){
    	cin >> a[i];
    	sum+=a[i];
    }
  	cin >> d;
  	for(int i=0;i<d;i++){
      	cin >> x >> y;
      	cout << sum+(y-a[x-1]) << "\n";
    }
}

Measured memory_bytes: 3568
#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;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    int a='M'-'A',b='Z'-'A',c='m'-'A';
    string s;
    cin >> s;
    int x=0,y=0;
    rep(i,n){
        int t=s.at(i)-'A';
        if (t<=a) y++;
        else if (t<=b) y--;
        else if (t<=c) x++;
        else x--;
    }
    cout << abs(x)+abs(y) << endl;
    if (x>0){
        rep(i,x) cout << 'a';
    }
    else{
        rep(i,-x) cout << 'n';
    }
    if (y>0){
        rep(i,y) cout << 'A';
    }
    else{
        rep(i,-y) cout << 'N';
    }
    cout << endl;
}



Measured memory_bytes: 3340
N, M = map(int, input().split())
lmax = 0
rmin = 10**5
for i in range(M):
    L, R = map(int, input().split())
    lmax = max(lmax, L)
    rmin = min(rmin, R)
ans = rmin - lmax
if ans >= 0:
    print(ans + 1)
else:
    print(0)

Measured memory_bytes: 9140
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <functional>
#include <string>
#include <cstdlib>
 
using namespace std;
 
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
        printf("%s\n", (n%10 == n/100) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256