akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  while(1){
  int total, kaisuu;
  int i=1;
  int score, nowscore=0;
  scanf("%d",&total);
      if(total==0){
	break;
      }
  kaisuu=total/4;
    while(i <= kaisuu){
      scanf("%d",&score);
      nowscore += score;
	i++;
    }
	printf("%d\n",nowscore);
  }
      return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int k = 0;

    if(a != b){
      k++;
    }
    if(b != c){
      k++;
    }
    if(a != c){
      k++;
    }
    if(k == 0){
      k++;
    }
    System.out.println(k);
  }
}

Measured memory_bytes: 9812
#include <stdio.h>

int main(void)
{
 int N,A[1000],i;
 scanf("%d",&N);
 for(i=0;i<N;i++)
  scanf("%d",&A[i]);

 for(i=0;i<N;i++){
 if((A[i]%2==0)&&(A[i]%3!=0)&&(A[i]%5!=0)){
   printf("DENIED\n");
   return 0;
   }
 }

 printf("APPROVED\n");

  return 0;
}


Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        x: i64,
    };
    let mut c = 0_i64;
    let mut s = 0_i64;
    for i in 0.. {
        if s >= x {
            break;
        }
        s += i;
        c = i;
    }
    let ans = c;
    println!("{}", ans);
}


Measured memory_bytes: 2128
// D - Alter Altar
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; string C; cin>>N>>C;
	int l = 0, r = N-1, c = 0;
	while(l < r){
		if(C[l] == 'W' && C[r] == 'R'){
			swap(C[l], C[r]);
			l++; r--; c++;
		}
		else if(C[l] != 'W') l++;
		else if(C[r] != 'R') r--;
	}
	cout<< c <<endl;
}


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

int main(){
  string s,t,u ;
  cin >> s >> t >> u ;
  if(s.at(s.size()-1)==t.at(0)&&t.at(t.size()-1)==u.at(0)) cout << "YES" << endl ;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>
#include <iostream>
#include <map>

using namespace std;

const int CMax = 100000005;

int main()
{
    set <int> S;
    pair < set<int>::iterator, bool> pIt;
    int n, num, res = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &num);
        pIt = S.insert(num);
        if (pIt.first == S.begin()) res++;
    }

    printf("%d\n", res);
}



Measured memory_bytes: 9728
MOD = 10**9 + 7

def MOD_perm(n, r):
    rtn = 1
    for _ in range(r):
        rtn *= n
        rtn %= MOD
        n -= 1
    return rtn

def MOD_inv(a):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u = u % MOD
    if u < 0:
        u += MOD
    return u

def MOD_COM2(n, r):
    return MOD_perm(n, r) * MOD_inv(MOD_perm(r, r)) % MOD

def main():
    n, m, k = map(int, input().split())
    comb = MOD_COM2(n*m-2, k-2)
    ans = 0
    for i in range(1, n+1):
        U = (i-1)*i//2
        U *= m*m
        U *= comb
        U %= MOD
        ans += U
        ans %= MOD
    for j in range(1, m+1):
        L = (j-1)*j//2
        L *= n*n
        L *= comb
        L %= MOD
        ans += L
        ans %= MOD
    print(ans%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main(void)
{
    long long x, y;
    std::cin >> x >> y;

    long long count = 0;
    for (long long i = x; i <= y; i *= 2) {
        count++;
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
string S;
int main(){
    cin >> S;
    if(S == "RSR" || S == "RSS" || S=="SSR" || S == "SRS"){cout<<1;return 0;}
    else if(S == "SSS"){cout<<0;return 0;}
    else if(S == "SRR" || S == "RRS"){cout<<2;return 0;}
    else{
        cout<<3;return 0;
    }

}


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

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int R = Integer.parseInt(br.readLine());
	System.out.println(2 * R * Math.PI);
    }
}

Measured memory_bytes: 33320
def check(N, S, bi, bj):
    for i in range(N):
        for j in range(i+1, N):
            if S[(bi+i) % N][(bj+j) % N] != S[(bi+j) % N][(bj+i) % N]:
                return False
    return True


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    ans = 0
    for i in range(N):
        if check(N, S, i, 0):
            ans += N
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39664
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int n,m,ans=0;
	int min=100000,max=0;
	int L,R;

	scanf("%d %d",&n,&m);

	for(int i=0;i<m;i++){
		scanf("%d %d",&L,&R);
		if(min<L || i==0)min=L;
		if(max>R || i==0)max=R;
	}

	for(int i=1;i<=n;i++){
		if(i>=min && i<=max){
			ans++;
		}
	}

	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
nil = -1

class Node:
    def __init__(self):
        self.parent = nil
        self.left = nil
        self.right = nil

def post_tw(node, ans):
    if tree[node].left != nil:
        post_tw(tree[node].left, ans)

    if tree[node].right != nil:
        post_tw(tree[node].right, ans)

    ans.append(node + 1)

def reconst_tree(node, pretw_itr, subt):
    n_i = subt.index(node)

    left_subt = subt[:n_i]
    right_subt = subt[n_i + 1:]

    if left_subt:
        left = next(pretw_itr)
        tree[node].left = left
        reconst_tree(left, pretw_itr, left_subt)

    if right_subt:
        right = next(pretw_itr)
        tree[node].right = right
        reconst_tree(right, pretw_itr, right_subt)


n = int(input())
tree = [Node() for i in range(n)]

pretw = [int(i) - 1 for i in input().split()]
intw = [int(i) - 1 for i in input().split()]

pretw_itr = iter(pretw)

root = next(pretw_itr)

reconst_tree(root, pretw_itr, intw)

ans = []

post_tw(root, ans)

print(*ans)

Measured memory_bytes: 7800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,x,t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>x>>t;
    ll cat=n/x;
    if(n%x!=0)
        cat++;
    cout<<cat*t;
    return 0;
}


Measured memory_bytes: 3604
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0233"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T>
vector<T> convert_base(T x,T b){
  vector<T> res;
  T t=1,k=abs(b);
  while(x){
    res.emplace_back((x*t)%k);
    if(res.back()<0) res.back()+=k;
    x-=res.back()*t;
    x/=k;
    t*=b/k;
  }
  if(res.empty()) res.emplace_back(0);
  reverse(res.begin(),res.end());
  return res;
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed ABC105_C(){
  long long p;
  cin>>p;
  auto ans=convert_base(p,-2LL);
  for(auto x:ans) cout<<x;
  cout<<endl;
  return 0;
}
/*
  verified on 2019/03/31
  https://atcoder.jp/contests/abc105/tasks/abc105_c
*/

signed YUKI_499(){
  long long p;
  cin>>p;
  auto ans=convert_base(p,7LL);
  for(auto x:ans) cout<<x;
  cout<<endl;
  return 0;
}
/*
  verified on 2019/03/31
  https://yukicoder.me/problems/no/499
*/

signed YUKI_782(){
  long long t,b;
  cin>>t>>b;
  while(t--){
    long long p;
    cin>>p;
    auto ans=convert_base(p,b);
    for(auto x:ans) cout<<x;
    cout<<endl;
  }
  return 0;
}
/*
  verified on 2019/03/31
  https://yukicoder.me/problems/no/782
*/

signed main(){
  //ABC105_C();
  //YUKI_499();
  //YUKI_782();
  return 0;
}
#endif

#undef call_from_test

signed main(){
  long long p;
  while(cin>>p,p){
    auto ans=convert_base(p,-10LL);
    for(auto x:ans) cout<<x;
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 5038, mod = 1e9 + 7;
int n, m, cnt, res, vis[N], sz[N], f[N][N], p[N]; vector<int> to[N];
void dfs (int x, int la) {
	vis[x] = 1; ++sz[m];;
	for (int i = 0; i < to[x].size(); ++i) {
		if (to[x][i] != la) dfs (to[x][i], la); else ++cnt;
	}
}
void _dfs (int x, int la) {
	vis[x] = 1;
	for (int i = 0; i < to[x].size(); ++i) {
		if (to[x][i] != la) _dfs (to[x][i], la); else ++cnt;
	}
}
inline int Pow (int x, int y) {
	int res = 1; 
	while (y) {
		if (y & 1) res = res * x % mod;
		x = x * x % mod, y >>= 1; 
	} return res;
}
signed main() {
	read (n);
	for (int i = 1; i <= n; ++i) {
		read (p[i]); if (p[i] > 0) to[p[i]].push_back (i);
	}  for (int i = 1; i <= n; ++i) if (p[i] < 0) ++m, dfs (i, i);
	for (int i = 1; i <= n; ++i) if (!vis[i]) _dfs (i, i);
	res = cnt * Pow (n - 1, m) % mod; f[0][0] = 1;
	for (int i = 1; i <= m; ++i) {
		f[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			f[i][j] = (f[i - 1][j] + f[i - 1][j - 1] * sz[i]) % mod;
	} if (m) res = (res + (f[m][1] - m) * Pow (n - 1, m - 1)) % mod;
	for (int i = 2, q = 1; i <= m; ++i) {
		q = q * (i - 1) % mod;
		res = (res + f[m][i] * q % mod * Pow (n - 1, m - i)) % mod;
	} res = n * Pow (n - 1, m) - res;
	res = (res % mod + mod) % mod;
	return printf ("%lld\n", res), 0;
}

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

int main(){
  int k, x;
  cin >> k >> x;
  int p = k*500;
  if(p >= x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d[111111];
  cin>>n;
  for(int i=0;i<n;i++) cin>>d[i];
  sort(d,d+n);
  cout<<d[n/2]-d[n/2-1]<<endl;
  return(0);
}


Measured memory_bytes: 640
a = int(input())
b = int(input())

if a == 1:
    if b == 2:
        print("3")
    else:
        print("2")
elif a == 2:
    if b == 1:
        print("3")
    else:
        print("1")
elif a == 3:
    if b == 1:
        print("2")
    else:
        print("1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;

signed main() {
	int n; cin >> n; map<string, int> mp;
	for(int i =1 ; i <= n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n,T;
	cin >> n >> T;

	ll ans=T;
	int prev,now;
	cin >> prev;
	for(int i=1;i<n;i++){
		cin >> now;
		ans += min(T,now-prev);
		prev = now;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int n,d,k,res=0,sum=0,cou[200005]={},now,pushnum=0;
long long int used[100005]={},x[11][11];
queue<long long int> que[100005],task;

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    while(1){
        cin>>n;
        if(n==0){return 0;}
        
            res=0;
        for(int i=1;i<n;i++){
            sum=0;
            for(int j=0;sum<=n;j++){
                
                if(sum==n){res++;}
                sum+=i+j;
            }
        }
        cout<<res<<endl;
    }
} 



Measured memory_bytes: 70312
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())

adj = [[] for _ in range(N)]

for i in range(N):
    line = list(map(int, input().split()))
    u = line[0] - 1
    if line[1] == 0:
        continue
    vs = line[2:]
    for v in vs:
        adj[u].append(v - 1)

d = [-1] * N
f = [-1] * N

def dfs(v, t):
    d[v] = t
    nx = t + 1
    for u in adj[v]:
        if d[u] > -1:
            continue
        nx = dfs(u, nx)
    f[v] = nx
    return f[v] + 1

nx = 1
for i in range(N):
    if d[i] > - 1:
        continue
    nx = dfs(i, nx)

for i in range(N):
    print(i + 1, d[i], f[i])



Measured memory_bytes: 6216
N=int(input())
A=list(map(int,input().split()))
T=[0]*61
mod=10**9+7

for i in range(N):
  for j in range(61):
    if ((A[i]>>j) & 1):
      #print(i,j)
      T[j]+=1
#print(T)

ans=0
for i in range(61):
  ans+=2**i*(N-T[i])*T[i]
  ans%=mod
print(ans)

Measured memory_bytes: 122936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 1005
ll mod=1e9+7;
ll mul(ll a,ll b){
  return (a*b)%mod;
}

int n,m,a,b;
vector<int> G[MAX],g[MAX];
int p[MAX];
bool flg[MAX];

int update(int x){
  flg[x]=true;
  if(p[x]==x)return x;
  return p[x]=update(p[x]);
}

int find(int x){
  if(p[x]==x)return x;
  return find(p[x]);
}

ll dfs(int pos){
  ll res=1;
  for(int i=0;i<(int)g[pos].size();i++)
    res=mul(res,dfs(g[pos][i]));  
  return (res+1LL)%mod;
}

int main(){
  while(cin>>n>>m){
    for(int i=1;i<=n;i++){
      p[i]=i;
      flg[i]=false;
      G[i].clear();
      g[i].clear();
    }
    for(int i=0;i<m;i++){
      cin>>a>>b;
      G[b].push_back(a);
      if(find(b)==a)update(b);
      else p[a]=b;
    }
    for(int i=1;i<=n;i++){
      for(int j=0;j<(int)G[i].size();j++){
        int w=G[i][j];
        if(flg[w])continue;
        if(flg[i]){
          g[p[i]].push_back(w);
        }else{
          g[i].push_back(w);
        }
      }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)if(p[i]==i)
        ans=mul(ans,dfs(i));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1300
#include<stdio.h>
#include<string.h>

void exchange(char *t){
	while (*t != '\0'){
		if (65 <= *t && *t <= 90)
			*t = *t + 32;
		t++;
	}
}

int count(char t[1000][101],char w[11],int n){
	int i,c=0;
	for (i = 0; i < n; i++){
		exchange(t[i]);
		if (strcmp(&t[i], w) == 0)
			c++;
		else
			;
	}
	return c;
}

int main(void){
	char t[1000][101]; //単語毎に格納していく
	char w[11];
	scanf("%s", w);
	int i=0;
	do{
		scanf("%s",t[i]);
	} while (strcmp(t[i++], "END_OF_TEXT") != 0);

	int n = i-1;
	printf("%d\n", count(t,w,n));


	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
	int H, W;
	std::vector<int> h, w;
	
	int cnt = 0;
	while(1)
	{
		std::cin >> H >> W;
		
		if( H == 0 && W == 0 ) break;
		
		else 
		{
			h.push_back(H);
			w.push_back(W);
		}
		
		cnt++;
	}
		
	for(int i = 0; i < cnt; i++)
	{
		for(int j = 0; j < h[i]; j++)
		{
			for(int k = 0; k < w[i]; k++)
			{
				if( ( ( j + 1 ) + ( k + 1 ) ) % 2 == 0 )
					std::cout << "#";
				
				else 
					std::cout << ".";
			}
			
			std::cout << std::endl;
		}
		
		std::cout << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3152
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for (int i = 0; i < strlen(str); i++){
            sum += (str[i] - '0');
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 2728
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int32_t main(){_
	int n,k ;
	cin >> n ;
	vi a(n) ; inp(a)
	int ans = 0 ;
	for(int i = 1 ; i < n ; i++){
		if(a[i] == a[i-1]){
			ans++ ;
			a[i] = N ;
		}
	}
	cout << ans << endl ;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int A, B, C;
  cin >> A >> B >> C;
  if(A + B >= C) cout << "Yes" << endl;
  else cout<< "No" << endl;
}

Measured memory_bytes: 256
import math
n,d = (int(x) for x in input().split())
x = []
y = []
for i in range(n):
  a,b = (int(x) for x in input().split())
  x.append(a)
  y.append(b)

dist = []
for j in range(n):
  kyori = math.sqrt(x[j]**2+y[j]**2)
  dist.append(kyori)

count = 0
for k in range(n):
  if (dist[k] <= d):
    count += 1

print(count)

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

using namespace std;

int main() {
    // 入力値
    string S;
    cin >> S;

    vector<string> stringOptions = {"dream", "dreamer", "erase", "eraser"};

    // 左右反転
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) {
        reverse(stringOptions.at(i).begin(), stringOptions.at(i).end());
    }

    string res = "YES";
    int length = S.size();
    for (int i = 0; i < S.size();) {
        bool canDevide = false;
        for (int j = 0; j < stringOptions.size(); j++) {
            if (stringOptions.at(j) == S.substr(i, stringOptions.at(j).size())) {
                i += stringOptions.at(j).size();
                canDevide = true;
            }
        }
        if (!canDevide) {
            res = "NO";
            break;
        }
    }

    // 出力値
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 10;
const int MAXM = 600010;
const int MAXK = 110;
const int MAXQ = 200010;

ll binPowMod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % m;
        a = a * a % m;
        b >>= 1LL;
    }
    return res;
}

ll f[2000010], rev[2000010];

ll C(ll n, ll k) {
    return f[n] * rev[n-k] % MODBASE * rev[k] % MODBASE;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    f[0] = 1;
    rev[0] = binPowMod(f[0], MODBASE-2, MODBASE);
    FOR(i,1,2000000) {
        f[i] = f[i-1] * i % MODBASE;
        rev[i] = binPowMod(f[i], MODBASE-2, MODBASE);
    }
    int x, y;
    cin >> x >> y;

    if ((2 * x - y) % 3) { cout << 0; return 0; }
    else if ((2 * y - x) % 3) { cout << 0; return 0; }

    int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
    if (a < 0 || b < 0) { cout << 0; return 0; }

    // cout << a << ' ' << b << endl;

    cout << C(a+b, a);
    return 0;
}


Measured memory_bytes: 31488
import java.util.*; 
import java.lang.*; 

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		String S = scan.next();	
		if(S.charAt(2)==S.charAt(3) && S.charAt(4)==S.charAt(5)){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n),c(m),d(m),l(n);
  int kyo;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    int kyo=400000001;
    for(int j=0;j<m;j++){
      if(kyo>abs(a[i]-c[j])+abs(b[i]-d[j])){
        kyo=abs(a[i]-c[j])+abs(b[i]-d[j]);
        l[i]=j+1;
      }
    }
    cout << l[i] << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (!s.contains("KIH") || s.contains("AA")) {
            System.out.println("NO");
            return;
        }
        s = s.replaceAll("A", "");
        if (s.equals("KIHBR")) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N, K, x, y, dp[2009]; vector<int> a[15];
int main() {
	cin >> N >> K;
	for(int i = 0; i < N; i++) {
		cin >> x >> y; y--;
		a[y].push_back(x);
	}
	for(int i = 0; i < 10; i++) {
		sort(a[i].begin(), a[i].end(), greater<int>());
	}
	fill(dp + 1, dp + K + 1, -999999999);
	for(int i = 0; i < 10; i++) {
		for(int j = K; j >= 0; j--) {
			int sum = 0, cnt = 0;
			for(int k = 0; j - k >= 0; k++) {
				dp[j] = max(dp[j], dp[j - k] + sum + cnt * (cnt - 1));
				if(k != (int)a[i].size()) sum += a[i][k], cnt++;
				else break;
			}
		}
	}
	printf("%d\n", dp[K]);
	return 0;
}

Measured memory_bytes: 3292
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1e18;
constexpr ll MAX_N = 200;

ll dist[MAX_N + 1][MAX_N + 1];

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

    ll N, M, R;
    cin >> N >> M >> R;

    vector<ll> cities(R);
    for (auto&& city : cities) {
        cin >> city;
    }

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

    for (ll i = 1; i <= N; i++) {
        for (ll j = 1; j <= N; j++) {
            dist[i][j] = dist[j][i] = i == j ? 0 : INF;
        }
    }

    for (ll i = 0; i < M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        dist[a][b] = dist[b][a] = c;
    }

    for (ll k = 1; k <= N; k++) {
        for (ll i = 1; i <= N; i++) {
            for (ll j = 1; j <= N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = INF;

    do {
        ll d = 0;
        for (ll i = 1; i < R; i++) {
            d += dist[cities[i]][cities[i - 1]];
        }

        ans = min(ans, d);
    } while (next_permutation(cities.begin(), cities.end()));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
typedef complex<double> Point;
int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}
double dot(Point a, Point b){
  return real(conj(a) * b);
}
struct Line : public vector<Point> {
  Line(Point a, Point b){
    push_back(a); push_back(b);
  }
  Point vector() const{
    return back() - front();
  }
};
struct Circle{
  Point p; double r;
  Circle() {}
  Circle(Point p, double r) : p(p), r(r) {}
};
Line circle_tangent(Circle& C, double th){
  Point p0 = C.p + polar(C.r, th);
  Point p1 = p0 + polar(1.0, th + M_PI / 2);
  return Line(p0, p1);
}
vector<double> common_tangents(Circle& C, Circle& D){
  vector<double> res;
  Point v = D.p - C.p;
  double l = abs(v);
  double a = arg(v);
  if(sign(l - abs(C.r - D.r)) > 0){
    double a1 = acos((C.r - D.r) / l);
    res.push_back(a + a1);
    res.push_back(a - a1);
    if(sign(l - (C.r + D.r)) > 0){
      double a2 = acos((C.r + D.r) / l);
      res.push_back(a + a2);
      res.push_back(a - a2);
    }
  }
  if((sign(l - abs(C.r - D.r)) == 0 || sign(l - (C.r + D.r)) == 0) && sign(l) != 0){
    res.push_back(a);
  }
  return res;
}
Point projection(const Line& l, Point p){
  double t = dot(p - l[0], l.vector()) / norm(l.vector());
  return l[0] + t * l.vector();
}
double distanceLP(const Line& l, Point p){
  return abs(p - projection(l, p));
}
int main(){
 int N;
  while(cin >> N && N){
    vector<Point> ps(N);
    vector<double> r(N);
    vector<double> m(N);
    REP(i, N) cin >> ps[i].real() >> ps[i].imag() >> r[i] >> m[i];
    int ans = 1;
    REP(i, N) REP(j, N) REP(b1, 2) REP(b2, 2) if(i != j){
      Circle C(ps[i], r[i] + b1 * m[i]);
      Circle D(ps[j], r[j] + b2 * m[j]);
      vector<double> args = common_tangents(C, D);
      REP(j, args.size()){
        Line l = circle_tangent(C, args[j]);
        int sub_ans = 0;
        REP(k, N) if(sign(distanceLP(l, ps[k]) - r[k]) >= 0 && sign(distanceLP(l, ps[k]) - (r[k] + m[k])) <= 0) sub_ans++;
        ans = max(ans, sub_ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1396
N = int(input())
S,T = list(map(str,input().split()))

ans = []
j = 0
k = 0

for i in range(N*2):
    if i%2 == 1:
        ans.append(T[j])
        j += 1
    else:
        ans.append(S[k])
        k += 1
        
for i in range(N*2):
    print(ans[i],end="")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n;
	cin >> n;
	int a[n];
	int xr = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		xr = (xr ^ a[i]);
	}
	for(int i = 0; i < n; ++i){
		int c = xr ^ a[i];
		cout << c << " ";
	}
	cout << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 5144
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main() {
	int a[5];
	int t = 10;
	int s = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 5; i++) {
		if (0 < a[i] % 10 && a[i] % 10 < t) {
			t = a[i] % 10;
		}
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 == 0)
			s += a[i] / 10;
		else
			s += a[i] / 10 + 1;
	}
	cout << 10 * (s - 1) + t << endl;
}


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

int64_t a[5000];
int64_t dp[2][5000];

int64_t solve(int n){
  int64_t summax=INT64_MIN;
  for(int i=0;i<n;i++){
    if(summax < a[i]){
      summax = a[i];
    }
  }

  for(int i=1;i<n;i++){
    for(int j=0;j<n-i;j++){
      dp[i%2][j] = dp[(i-1)%2][j] + a[i+j];

      if(summax < dp[i%2][j]){
        summax = dp[i%2][j];
      }
    }
  }
  return summax;
}

int main(){
  int64_t n;
  while(cin >> n,n!=0){

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

    cout << solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  const ll mod = 1e9 + 7;
  int n, k; cin >> n >> k; n++;
  ll ways = 0, lo = 0, hi = 0;
  for (int p = 1; p <= n; p++) {
    lo += p;
    hi += n + 1 - p;
    if (p >= k) ways += (hi - lo + 1) % mod;
  }
  ways %= mod;
  cout << ways << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    sort(_all(a));
    bool ok = false;
    if(a[n - 1] - a[0] >= 2){
    }
    else if(a[n - 1] - a[0] == 1){
        int cnt = 0;
        for(auto& e : a){
            if(e == a[0]) cnt++;
            else break;
        }
        int rc = a[0] - cnt + 1;
        if(rc >= 1){
            int lb = rc * 2;
            if(n - cnt >= lb){
                ok = true;
            }
        }
    }
    else { // a[n - 1] - a[0] == 0
        int lb = a[0] * 2;
        if(n >= lb){
            ok = true;
        }
        if(n == a[0] + 1){
            ok = true;
        }
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())


# nの約数列挙
def divisor(n):
    ans = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans.append(i)
            if i**2 == n:
                continue
            ans.append(n // i)
    return ans  # sortされていない


MOD = 10 ** 9 + 7

ans = 0
num = 0
CNT = [0] * (K+1)
for i in range(K, 1, -1):
    n = K // i
    c = pow(n, N, MOD)

    c -= CNT[i]

    num += c

    f = divisor(i)
    for n in f:
        CNT[n] += c

    ans += c * i
    ans %= MOD


al = pow(K, N, MOD)
ans += al - num
ans %= MOD

print(ans)


Measured memory_bytes: 75504
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

enum { U = 0, D = 1, L = 2, R = 3 };

/* global variables */

bool mtx[4][4] = {{0, 1, 0, 1}, {1, 0, 0, 1}, {1, 1, 0, 1}, {0, 0, 0, 0}};
int ch2d[26];

/* subroutines */

/* main */

int main() {
  ch2d['U' - 'A'] = U;
  ch2d['D' - 'A'] = D;
  ch2d['L' - 'A'] = L;
  ch2d['R' - 'A'] = R;

  int c;
  cin >> c;

  while (c--) {
    string score;
    cin >> score;

    int len = score.length();
    bool yes = false;
    
    for (int st = 0; st <= 1; st++) {
      int prvd = ch2d[score[0] - 'A'];
      int prvf = st;
      int ok = true;

      for (int i = 1; ok && i < len; i++) {
	int curd = ch2d[score[i] - 'A'];
	if ((prvf == 0 && ! mtx[prvd][curd]) ||
	    (prvf == 1 && ! mtx[curd][prvd])) {
	  ok = false;
	  break;
	}
	prvd = curd;
	prvf ^= 1;
      }

      if (ok) {
	yes = true;
	break;
      }
    }

    cout << (yes ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 1328
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin >> n;
		if(n >= 30) cout << "Yes";
		else cout << "No";
	}
	return 0;
}

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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll x, k, d;	cin >> x >> k >> d;

	x = abs(x);

	if( k - x / d < 0 ){
		cout << x - k * d << endl;
	}else{
		k -= x/d;
		x %= d;

		if( k % 2 == 0 ){
			cout << x << endl;
		}else{
			cout << abs(x - d) << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <vector>
#define INF 1e+9
using namespace std;

typedef pair<int,int> P;
struct edge{ int to,cost; };

int main(){
	int n,k,c[5000],r[5000];
	int d[5000];
	vector<int> vec[5000];
	vector<edge> G[5000];
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> c[i] >> r[i];
		d[i] = INF;
	}
	d[0] = 0;
	for(int i = 0;i < k;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	for(int i = 0;i < n;i++){
		bool used[5000] = {};
		queue<int> que;
		que.push(i);
		used[i] = true;
		for(int j = 0;j < r[i];j++){
			int siz = que.size();
			for(int k = 0;k < siz;k++){
				int v = que.front();que.pop();
				for(int l = 0;l < vec[v].size();l++){
					if(!used[vec[v][l]]){
						G[i].push_back({vec[v][l],c[i]});
						used[vec[v][l]] = true;
						que.push(vec[v][l]);
					}
				}
			}
		}
	}
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			if(d[v] + e.cost < d[e.to]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	cout << d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 127620
#include <iostream>
using namespace std;
struct node{
    int rank;
    int p;
};
node N[10001];
int findSet(int x){
    if(x!=N[x].p){
        N[x].p=findSet(N[x].p);
    }
    return N[x].p;
}
void unite(int x,int y){
    if(N[findSet(x)].rank>N[findSet(y)].rank){
        N[findSet(y)].p=findSet(x);
    }
    else{
        N[findSet(x)].p=findSet(y);
        if(N[findSet(x)].rank==N[findSet(y)].rank){
            N[findSet(y)].rank=N[findSet(y)].rank+1;
        }
    }
}
bool same(int x,int y){
    return findSet(x)==findSet(y);
}
int main(void){
    int n,q,i,num,x,y;

    cin>>n>>q;
    for(i=0;i<n;i++){
        N[i].rank=0;
        N[i].p=i;
    }
    for(i=0;i<q;i++){
        cin>>num;
        cin>>x>>y;
        if(num==0){
            unite(x,y);
        }
        else
        {
            if(same(x,y)) {
                cout<<"1"<<endl;
            }
            else {
                cout<<"0"<<endl;
            }
        }
    }
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
double ans;
long n,m,d;
main()
{
	cin>>n>>m>>d;
	if(d>0)ans=d*2+(n-d*2)*2;
	else ans=n;
	ans=ans/n/n;
	ans*=(m-1);
	cout<<fixed<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		Integer A, B;
		Integer minSum = 100;

		for (A=1; A<N-1; A++) {
			B = N-A;

			String aStr = A.toString();
			String bStr = B.toString();

			List<String> aDigitList = Arrays.asList(aStr.split(""));
			List<String> bDigitList = Arrays.asList(bStr.split(""));

			int sum=0;

			for(String aDigit : aDigitList) {
				sum += Integer.parseInt(aDigit);
			}

			for(String bDigit : bDigitList) {
				sum += Integer.parseInt(bDigit);
			}

			minSum = Math.min(minSum, sum);
		}

		if(N==2) {
			minSum = 2;
		}


		System.out.println(minSum);
	}
}



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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    string K;
    int D;
    cin >> K >> D;
    for (char &c : K) {
        c -= '0';
    }
    int n = K.size();
    constexpr int MOD = 1'000'000'007;
    vector<vector<pair<int, int>>> dp(n + 1, vector<pair<int, int>>(D, {0, 0}));
    dp[0][0] = {1, 0};
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < D; ++j) {
            int nj = (j + K[i]) % D;
            dp[i + 1][nj].first = (dp[i + 1][nj].first + dp[i][j].first) % MOD;
            for (int dig = 0; dig < K[i]; ++dig) {
                nj = (j + dig) % D;
                dp[i + 1][nj].second = (dp[i + 1][nj].second + dp[i][j].first) % MOD;
            }
            for (int dig = 0; dig < 10; ++dig) {
                nj = (j + dig) % D;
                dp[i + 1][nj].second = (dp[i + 1][nj].second + dp[i][j].second) % MOD;
            }
        }
    }
    cout << ((dp[n][0].first + dp[n][0].second - 1) % MOD + MOD) % MOD << "\n";

    return 0;
}

Measured memory_bytes: 10240
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class F
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, D, A) = Scanner.Scan<int, int, int>();
            var E = new (int X, long H)[N];
            for (var i = 0; i < N; i++)
            {
                var (x, h) = Scanner.Scan<int, long>();
                E[i] = (x, h);
            }
            Array.Sort(E, (x, y) => Comparer<int>.Default.Compare(x.X, y.X));
            var counts = new long[N + 1];
            var answer = 0L;
            var current = 0L;
            for (var i = 0; i < N; i++)
            {
                var h = E[i].H;
                current -= counts[i];
                var damage = current * A;
                h -= damage;
                if (h <= 0) continue;

                var count = h / A;
                if (h % A > 0) count++;
                current += count;
                answer += count;

                var l = i;
                var r = N;
                while (r - l > 1)
                {
                    var m = l + (r - l) / 2;
                    if (E[m].X - E[i].X <= D * 2) l = m;
                    else r = m;
                }
                counts[r] += count;
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

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

    int h, w;
    cin >> h >> w;

    int A[h][w];
    REP(i, h) REP(j, w) cin >> A[i][j];

    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {-1, 1, 0, 0};

    vector<vector<int>> B;

    REP(i, h){
        REP(j, w){
            if(A[i][j] == 0) continue;
            if(A[i][j] % 2 == 1){
                REP(k, 4){
                    int nx, ny;
                    nx = i + dx[k];
                    ny = j + dy[k];
                    if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                        continue;
                    }
                    if((A[nx][ny] % 2 != 1) and (nx < i or ny < j)) continue;
                    A[nx][ny]++;
                    
                    vector<int> C(4);
                    C[0] = i + 1;
                    C[1] = j + 1;
                    C[2] = nx + 1;
                    C[3] = ny + 1;

                    B.push_back(C);

                    C.clear();

                    A[i][j]--;
                    break;
                }
            }
        }
    }

    cout << B.size() << endl;
    REP(i, B.size()){
        REP(j, B[i].size()){
            if(j) cout << " " << B[i][j];
            else cout << B[i][j];
        }
        cout << endl; 
    }

    /*
    REP(i, h){
        REP(j, w){
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
    */
    

    return 0;
}

Measured memory_bytes: 10032
A, B = map(int, input().split())

if A == B:
    print(0)
elif (A+B) / 2 == (A+B) // 2:
    print((A+B) // 2)
elif (A-B) / 2 == (A-B) // 2:
    print((A-B) // 2)
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d) puts("Left");
    else if(a+b == c+d) puts("Balanced");
    else puts("Right");
    return 0;
}

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

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	int m = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			int tmp = a.at(i) - a.at(j);
			m = max(tmp, m);
		}
	}

	cout << m << endl;
}


Measured memory_bytes: 256