akhauriyash/Code-Regression huggingface dataset:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
a,b = Line(N)
c,d = Line(N)

x = []
for i in range(N):
    x.append([a[i],b[i],0])
    x.append([c[i],d[i],1])

x.sort(key=lambda x: x[0])

use = {}
for i in range(2*N):
    use[i] = False

ans = 0
for i in range(2*N)[::-1]:
    if x[i][2] != 0:
        continue
    else:
        index = 2*N
        val = float('inf')
        for j in range(i+1,2*N):
            if x[j][1]>x[i][1] and x[j][1]<val and use[j]!=True and x[j][2]==1:
                index = j
                val = x[j][1]
        if index != 2*N:
            ans += 1
            use[index] = True

print(ans)

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >

#define HONEST '1'
#define UNKIND '2'

int N;
ll honest;

vector< tuple< ll, ll > > XY[15];

bool check(string s, ll honest) {
  ll x, y;

  for (ll i = 0; i < N; i++) {
    auto v = XY[i];

    if (s[i] == HONEST) {

      for (auto t : v) {
        x = TG0(t);
        y = TG1(t);

        if (s[x] != y) {
          return false;
        }
      }

      // cerr << "s:" << s << " i: " << i << "  x: " << x << " y:" << y << " " << checks << endl;
    }
  }

  return true;
}

void dfs(ll len, string s, ll c_honest) {
  if (len == N) {
    // check
    // cerr << "s: " << s << " honest: " << c_honest << endl;
    if (check(s, c_honest)) {
      honest = max(honest, c_honest);
    }
    return;
  }

  dfs(len + 1, s + UNKIND, c_honest);
  dfs(len + 1, s + HONEST, c_honest + 1);
}

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

  CIN(N);

  ll j;
  ll x, y;
  for (int i = 0; i < N; i++) {
    cin >> j;

    for (ll k = 0; k < j; k++) {
      cin >> x >> y;

      XY[i].push_back(make_tuple(x - 1, y == 1 ? HONEST : UNKIND));
    }
  }

  dfs(0, "", 0);

  cout << honest << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a,b = map(int,input().split())
s = list(str(input()))

flag = True
for i in range(a):
    if s[i] == '-':
        flag = False
if s[a] != '-':
    flag = False
for i in range(a + 1, a + b + 1):
    if s[i] == '-':
        flag = False

if flag:
    print("Yes")
else:
    print("No")

"""
number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
flag = True
for i in range(a):
    if s[i] not in number:
        flag = False
        #print("A")
if s[a] != '-':
    flag = False
    #print("B")
for i in range(a + 1, a + b + 1):
    if s[i] not in number:
        flag = False
        #print("C")

if flag:
    print("Yes")
else:
    print("No")
"""

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#define r(i,n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
  int n;
  long long sum=0;
  long long ans=100000000000;
  long long cnt=0;
  cin >> n;
  int a[200010];
  r(i,n){
    cin >> a[i];
    sum+=a[i];
  }

  r(i,n-1){
    cnt+=a[i];
    sum-=a[i];
    ans=min(abs(cnt-sum), ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#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,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
ll a[M];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;ll k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	ll l=1,r=1e9,m,p=-1;
	while(l<r)
	{
		m = (l+r)/2;
		if(m==p)
			m++;
		p=m;
		ll z=0;
		for(int i=1;i<=n;i++)
		{
			z+=(a[i]-1)/m;
		}
		if(z<=k)
			r=m;
		else
			l=m+1;
	}
	cout<<r<<"\n";
	return 0;
}

Measured memory_bytes: 5160
import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main {

	static int max_X;
	static int max_Y;

	public static void main(String[] args) throws UnsupportedEncodingException {

		Scanner sc = new Scanner(System.in);

		String ans = "Yes";

		int j = sc.nextInt();
		int i = sc.nextInt();
		max_X = i;
		max_Y = j;

		// 適当に格納
		ArrayList<byte[]> map = new ArrayList<byte[]>();
		int h, w;
		for (h = 0; h < j; h++) {
			String st = sc.next();
			map.add(st.getBytes());
		}

		for (h = 0; h < j; h++) {
			byte[] now_x = map.get(h);
			for (w = 0; w < i; w++) {
				if (!check(w,h, now_x, map)) {
					ans = "No";
					break;

				}
			}
		}
		System.out.println(ans);
		sc.close();
	}

	private static boolean check(int w, int h, byte[] now_x, ArrayList<byte[]> map) {
		boolean ischeck = false;

		if (now_x[w] == '.') {
			return true;
		}

		// 左
		if (w - 1 >= 0) {
			if (now_x[w] == now_x[w - 1]) {
				ischeck = true;
				return ischeck;
			}
		}

		// 右
		if (w + 1 < max_X) {
			if (now_x[w] == now_x[w + 1]) {
				ischeck = true;
				return ischeck;
			}
		}

		// 上
		if (h - 1 >= 0) {
			byte[] up_x = map.get(h - 1);
			if (now_x[w] == up_x[w]) {
				ischeck = true;
				return ischeck;
			}
		}

		// 下
		if (h + 1 < max_Y) {
			byte[] down_x = map.get(h + 1);
			if (now_x[w] == down_x[w]) {
				ischeck = true;
				return ischeck;
			}
		}
		return ischeck;
	}

}


Measured memory_bytes: 22868
class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

mod = 10 ** 9 + 7

r1, c1, r2, c2 = map(int, input().split())

mc = ModComb(r2 + c2 + 10)
def f(i, j):
    return mc.nCk(i + j, i)

print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % mod)

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

static class Program
{
    static void Main()
    {
        var inputs = Console.ReadLine().Split(" ").Select(int.Parse).ToList();
        var (d, t, s) = (inputs[0], inputs[1], inputs[2]);

        if (d <= t * s)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 28288
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc058/tasks/abc058_b

int main() {

    string O, E;
    cin >> O >> E;

    bool odd = O.length() != E.length();
    REP(i, O.length() - odd) {
        cout << O[i] << E[i];
    }

    if (odd) {
        cout << O[O.length() - 1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  //input
  string s;
  cin >> s;

  //end input

  //main
  if ( s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if ( s == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else if ( s == "Rainy") {
    cout << "Sunny" << endl;
  } 
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int tmp;
    int cnt[10] = {0};
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        if (tmp <= 399)
        {
            cnt[0] += 1;
        }else if (tmp <= 799)
        {
            cnt[1] += 1;
        }else if (tmp <= 1199)
        {
            cnt[2] += 1;
        }else if (tmp <= 1599)
        {
            cnt[3] += 1;
        }else if (tmp <= 1999)
        {
            cnt[4] += 1;
        }else if (tmp <= 2399)
        {
            cnt[5] += 1;
        }else if (tmp <= 2799)
        {
            cnt[6] += 1;
        }else if (tmp <= 3199)
        {
            cnt[7] += 1;
        }else if (tmp >= 3200)
        {
            cnt[8] += 1;
        }
        
    }

    int sum = 0;
    for (int i = 0; i <= 7; i++)
    {
        if (cnt[i] != 0)
        {
            sum += 1;
        }
        
    }
    
    int max, min;
    if (0 == cnt[8])
    {
        max = sum;
        min = sum;
    }else{
        if (0 == sum)
        {
            min = 1;
            max = sum + cnt[8];
        }else{
            min = sum;
            max = sum + cnt[8];
        }
        
    }

    cout << min << ' ' << max << endl;

    return 0;
}


Measured memory_bytes: 256
INF=int('fffFFFFffffFFFF',16)

n=int(input())
h=list(map(int,input().split()))
dp=[INF] * n

dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[n-1])

Measured memory_bytes: 20520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 10000000000000000
int main(void){
    ll n,m;cin>>n>>m;
    vector<ll>v(n);rep(i,n)cin>>v[i];sort(v.begin(),v.end());
    ll x,y;
    vector<pair<ll,ll>>r(m);
    rep(i,m){cin>>x>>y;r[i]=make_pair(y,x);}
    sort(r.begin(),r.end());reverse(r.begin(),r.end());
    int count=0;
    rep(i,m){
        ll f=r[i].first,s=r[i].second;
        while(f>v[count]&&s>0){
            v[count]=f;count++;s--;
        }
    }
    ll ans=0;
    rep(i,n)ans+=v[i];
    cout<<ans;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {

	std::string s;
	std::cin >> s;

	decltype(s.size()) zeros = std::count(s.begin(), s.end(), '0');


	std::cout << 2*std::min(zeros, s.size() - zeros) << "\n";
/*  
	std::vector<char> stack_;

	stack_.reserve(s.size());

	auto count = 0;
	for (const auto&e : s) {

		if (stack_.empty()) {
			stack_.push_back(e);
			continue;
		}
			
		if (stack_.back() != e) {
			stack_.pop_back();
			count += 2;
//			continue;
		}
		else {
			stack_.push_back(e);
		}
	}


	std::cout << count << "\n";
*/
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int count=0;
  bool win;
  while(true){
    if(count%2==0){
      c-=b;
      if(c<=0){
        win=true;
        break;
      }
    }else{
      a-=d;
      if(a<=0){
        win=false;
        break;
      }
    }
    count++;
  }
  if(win){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cmath>

#include <vector>
#include <map>
#include <utility>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k;
bool c[40000];
LL p[20], e[20], pn;
const LL MOD = 1000000007;
std::vector<LL> divisor;
std::map<LL, LL> mu, gg;
LL ans;

LL g(LL x) {
	LL ex = (x + 1) / 2;
	LL ans = 1, prod = k;
	while(ex) {
		if(ex & 1) { (ans *= prod) %= MOD; }
		(prod *= prod) %= MOD;
		ex /= 2;
	}
	
	return ans;
}

int main() {
	scanf("%lld%lld", &n, &k);
	
	for(LL i = 2; i * i > 1000000000; i++) {
		if(c[i]) { continue; }
		for(LL j = i * 2; j < 40000; j += i) { c[j] = true; }
	}
	LL nn = n;
	incID(i, 2, 40000) {
		if(! c[i] && nn % i == 0) {
			p[pn] = i;
			while(nn % i == 0) {
				e[pn]++;
				nn /= i;
			}
			pn++;
		}
	}
	if(nn != 1) {
		p[pn] = nn;
		e[pn] = 1;
		pn++;
	}
	
	LL count[21];
	inc(i, pn) { count[i] = 0; }
	LL prod = 1;
	while(true) {
		divisor.push_back(prod);
		LL m = 1;
		inc(i, pn) { if(count[i] > 1) { m = 0; } else if(count[i] == 1) { m *= -1; } }
		mu.insert(std::make_pair(prod, m));
		
		LL i = 0;
		while(i < pn && count[i] == e[i]) {
			inc(j, e[i]) { prod /= p[i]; }
			count[i++] = 0;
		}
		if(i == pn) { break; }
		prod *= p[i];
		count[i]++;
	}
	
	for(auto && e : divisor) {
		gg.insert(std::make_pair(e, g(e)));
	}
	
	for(auto && x : divisor) {
	for(auto && t : divisor) {
		if(t % x == 0) {
			(ans += mu[t / x] * (t % 2 == 0 ? t / 2 : t) * gg[x]) %= MOD;
		}
	}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
import sys
def check(t1,x1,y1,t2,x2,y2):
  if t2-t1<abs(x1-x2)+abs(y1-y2):
    return False
  if ((t2-t1)-abs(x1-x2)-abs(y1-y2))%2==0:
    return True
  return False
n=int(input())
data=[[int(i) for i in l.split()] for l in sys.stdin]
t1=0
x1=0
y1=0
for i in range(n):
  t2,x2,y2=data[i]
  if check(t1,x1,y1,t2,x2,y2):
    t1=t2
    x1=x2
    y1=y2
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 21060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_N 100000
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N+1];

//n以下の素数の数を返す
int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
  return p;
}

signed main(){
  int m;
  double a,b;
  int size=sieve(100000);
  //cout<<prime[0]<<endl;
  while(cin>>m>>a>>b,m){
    int p,q,max=0;
    double t=a/b;
    for(int i=0;prime[i]*prime[i]<=m;i++){
      int ok=i,ng=size,mid;
      while(abs(ok-ng)>1){
	mid=(ok+ng)/2;
	if(prime[i]*prime[mid]<=m)ok=mid;
	else ng=mid;
      }
      ng=ok+1;
      ok=i;
      while(abs(ok-ng)>1){
	mid=(ok+ng)/2;
	if((double)prime[i]/prime[mid]>=t)ok=mid;
	else ng=mid;
      }
      int tmp=prime[i]*prime[ok];
      if(tmp>max){
	max=tmp;
	p=prime[i];
	q=prime[ok];
      }
    }
    cout<<p<<" "<<q<<endl;
  }
  return 0;
}



Measured memory_bytes: 3240
import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(10**9)
N, K = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))
S = [0]*(N+1)
R = defaultdict(list)
R[0].append(0)
for i in range(N):
    S[i+1] = (S[i]+A[i])%K
    R[S[i+1]].append(i+1)
ans = 0
for i in range(N+1):
    a = bisect.bisect_right(R[S[i]], i)
    b = bisect.bisect_left(R[S[i]], i+K)
    ans+=b-a
print(ans)






Measured memory_bytes: 126664
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 21 23:37:30 2020

@author: liang
"""

N = int(input())

A = [int(x) for x in input().split()]

d = [0]*(10**5 + 1)

for a in A:
    if a - 1 >= 0:
        d[a-1] += 1
    d[a] += 1
    d[a+1] += 1

ans = max(d)

print(ans)

Measured memory_bytes: 20080
import sys
n , m, *e = map(int,sys.stdin.read().split())
total = n*(n-1)//2
ans =[total]
u = [-1]*(n+1)

def find(x):
    if u[x] < 0 :
        return x
    else:
        return find(u[x])

for x , y in zip(e[-2:1:-2],e[:1:-2]):
    x = find(x)
    y = find(y)
    x, y =sorted((x,y))
    if x != y:
        total -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x
    ans += [total]

print(*ans[::-1], sep="\n")

Measured memory_bytes: 25332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author marX
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

long long calc(long long a, long long b) {
    return a + (b - a - 1) / 2;
}

class A {
public:
    void solve(std::istream &in, std::ostream &out) {
        long long x, a, b;
        in >> x >> a >> b;

        long long answer;

        if ((a & 1) == (b & 1)) {
            answer = (b - a) / 2;
        } else {
            answer = min(calc(a, b), calc(x - b + 1, x - a + 1));
        }

        out << answer << endl;
    }
};


int main() {
    A solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

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

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 20;

int a[maxn][maxn];

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = -1;
    for (int i = 0; i < (1 << n); i++) {
        vector<int> cc(n);
        int res = 0;
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                for (int k = 0; k < m; k++) {
                    cc[k] += a[j][k];
                }
                res += c[j];
            }
        }
        bool f = true;
        for (int j = 0; j < m; j++) {
            if (cc[j] < x) f = false;
        }
        if (f) {
            if (ans == -1 || ans > res) {
                ans = res;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}

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

int main(){
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    for(int i=B;i>=A;--i){
        if(i%K==0){
            cout << "OK"<<endl;
            break;
        }
        else if(i == A)
                cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
//Connected Component
#include <iostream>
#include <vector>

using namespace std;

static const int N = 100000;
int n, colors[N] = {};

void dfs(vector<vector<int>>  &G, int u, int c) {
    if(colors[u] != -1) return;
    colors[u] = c;
    for(auto v: G[u]) {
        dfs(G, v, c);
    }
}

int main() {
    int m, s, t, q;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for(int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    for(int i = 0; i < n; i++) colors[i] = -1;
    for(int i = 0; i < n; i++) {
        dfs(G, i, i);
    }

    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> s >> t;
        if(colors[s] == colors[t]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 13340
import sys

N = int(input())
TASKS = []
time = 0
for i in range(1, N+1):
    A,B = map(int, input().split())
    TASKS.append([A,B])

TASKS.sort(key=lambda x: x[1])

#print(TASKS)

time = 0

for i in range(N):
    task = TASKS[i]
    a = task[0]
    b = task[1]
    time += a
    if time <= b:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")


Measured memory_bytes: 38096
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var a=input.trim().split("\n");
var x=a[1].split(" ").map(Number);
var min=Math.min(...x);
var max=Math.max(...x);
var s=max-min;
if(s%2==0)console.log(s/2);
else console.log((s+1)/2);



Measured memory_bytes: 16464
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
template<typename G>
struct SCC{
    int n;
    const G &g;
    vector<vector<int>> gg,rg,scc_tps;
    vector<int> cmp,ord,used;

    SCC(G &g):n(g.size()),g(g),gg(g.size()),rg(g.size()),cmp(g.size(),-1),used(g.size(),false){
        for(int i=0;i<n;i++){
            for(int v:g[i]){
                gg[i].emplace_back(v);
                rg[v].emplace_back(i);
            }
        }
    }

    int operator[](int k){
        return cmp[k];
    }

    void dfs(int id){
        if(used[id])return ;
        used[id]=true;
        for(int v:gg[id])dfs(v);
        ord.emplace_back(id);
    }

    void rdfs(int id,int cnt ,V<int> &tmp){
        if(cmp[id]!=-1)return ;
        tmp.push_back(id);
        cmp[id]=cnt;
        for(int v:rg[id])rdfs(v,cnt,tmp);
    }

    void build(vector<vector<int>> &t){
        for(int i=0;i<n;i++)dfs(i);
        reverse(ord.begin(),ord.end());
        int ptr=0;
        for(int v:ord){
            V<int> tmp;
            if(cmp[v]==-1){
                rdfs(v,ptr,tmp);
                ptr++;
                scc_tps.push_back(tmp);
            }
        }
        t.resize(ptr);
        for(int i=0;i<n;i++){
            for(int v:g[i]){
                if(cmp[i]==cmp[v])continue;
                t[cmp[i]].emplace_back(cmp[v]);
            }
        }
    }
};
int main(){
  int n,m,k;
  cin>>n>>m;
  V<V<int>> g(n),t;
  for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      g[a].push_back(b);
  }
  SCC<V<V<int>>> scc(g);
    scc.build(t);
   cout<<t.size()<<"\n";
   for(int i=0;i<t.size();i++){
       cout<<scc.scc_tps[i].size()<<" ";
       for(int j=int(scc.scc_tps[i].size())-1;j>=0;j--){
           cout<<scc.scc_tps[i][j]<<" ";
       }
       cout<<"\n";
   }
}

Measured memory_bytes: 125300
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> hList = new ArrayList<>();

		long cnt = 0;

		for(int i=0;i<n;i++) {
			hList.add(sc.nextInt());
		}

		Collections.sort(hList);

		//n>kの場合
		if(n>k) {
			for(int i=0;i<(n-k);i++) {
				cnt += hList.get(i);
			}
		}else {
			cnt = 0;
		}


		System.out.println(cnt);

	}
}


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

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> task(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        task[i] = P(b, a);
    }
    sort(task.begin(), task.end());

    long long time = 0;
    for (int i = 0; i < N; i++) {
        P p = task[i];
        time += p.second;
        if (time > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1920
N,M = map(int,input().split())
step  = [-1] * (N + 1)

for _ in range(M):
    a = int(input())
    step[a-1] = 0

if step[0] == -1:
    step[0] = 1

if step[1] == -1:
    step[1] = step[0]+1

for i in range(2,N):
    if step[i] == -1:
        step[i] = step[i-1]+step[i-2]

print(step[N-1] % 1000000007)


Measured memory_bytes: 460020
# UnionFind
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self, n):
    self.n = [-1]*n
    self.r = [0]*n
    self.siz = n

  def find_root(self, x):
    if self.n[x] < 0:
      return x
    else:
      self.n[x] = self.find_root(self.n[x])
      return self.n[x]

  def unite(self, x, y):
    x = self.find_root(x)
    y = self.find_root(y)
    if x == y:
      return
    elif self.r[x] > self.r[y]:
      self.n[x] += self.n[y]
      self.n[y] = x
    else:
      self.n[y] += self.n[x]
      self.n[x] = y
      if self.r[x] == self.r[y]:
        self.r[y] += 1
    self.siz -= 1

  def root_same(self, x, y):
    return self.find_root(x) == self.find_root(y)

  def count(self, x):
    return -self.n[self.find_root(x)]

  def size(self):
    return self.siz

n,q=map(int,input().split())
uf=UnionFind(n)
for _ in range(q):
  t,u,v=map(int,input().split())
  if t==0:
    uf.unite(u,v)
  else:
    print(uf.root_same(u,v)+0)

Measured memory_bytes: 13276
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N, M; cin>>N>>M;
    vector<ll> A(N), B(M);
    REP(i, N) cin>>A[i];
    REP(i, M) cin>>B[i];
    vector<ll> dp(N+10);
    ll width  = 0;
    for(int i=0; i<M-1; i++){
        width += (i+1)*(M-i-1)*(B[i+1]-B[i]);
        width %= MOD;
    }
    ll height = 0;
    for(int i=0; i<N-1; i++){
        height += (i+1)*(N-i-1)*(A[i+1]-A[i]);
        height %= MOD;
    }
    cout << height*width%MOD << endl;
    return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

int n , m , k , ans[N];
vector<int> adj[N];
bool vis[N];
vector<int> v, block[N];
set<int> st;

void dfs(int node)
{
    vis[node] = 1;
    st.insert(node);
    for(auto ch : adj[node])
        if (!vis[ch]) dfs(ch);
}

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

    cin >> n >> m >> k;
    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for(int i=1; i<=k; i++)
    {
        int x,y;
        cin >> x >> y;
        block[x].push_back(y);
        block[y].push_back(x);
    }

    for(int i=1; i<=n; i++)
    {
        if (!vis[i])
        {
            st.clear();
            dfs(i);
            for(auto it : st)
            {
                int tmp = st.size() - adj[it].size() - 1;
                for(int j=0; j<block[it].size(); j++)
                {
                    int ch = block[it][j];
                    if (st.find(ch) != st.end()) tmp--;
                }
                ans[it] = tmp;
            }
        }
    }

    for(int i=1; i<=n; i++)
        cout << ans[i] << ' ';

    return 0;
}

Measured memory_bytes: 17016
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    *max_element(a.begin(), a.end()) *= pow(2, k);
    cout << a[0] + a[1] + a[2] << endl;
}


Measured memory_bytes: 512
import sys
S = input()
T = input()
if S == T:
  print('Yes')
  sys.exit()
i = 0
while i < 100:
  x = S[-1]
  S = x+S
  S = S[:-1]
  if S==T:
    print('Yes')
    sys.exit()
  else:
    i += 1
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
const int N=3003;
typedef long double ld;
const ld pi=acos(-1);
using namespace std;
int n,m,a[N];
ld x,y;
inline void pls(long long d,int v){
	x+=v*cos(pi*d/m),y+=v*sin(pi*d/m);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		for(int j=0;j<i;j++)
		pls(a[i]+a[j],j+n-i-1),
		pls(1ll*a[i]+a[j]+m,i-j-1);
	}
	printf("%.10Lf %.10Lf",x*6/n/(n-1)/(n-2),
	y*6/n/(n-1)/(n-2));
}

Measured memory_bytes: 384
a, b = map(int, input().split())
no_count = 0 
if int(str(a // 1000)[::-1]) < a % 100:
        no_count -= 1
if int(str(b // 1000)[::-1]) > b % 100:
        no_count -= 1
print(b // 100 - a // 100 + 1 + no_count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b;
  cin >> a >> b;
  
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  
  int ans = 1;
  int now = a;
  while(now < b){
    now += a-1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

MOD=998244353
N,D = ilint()
if D[0]!=0:
    print(0)
    exit()
C = [0]*N
C[0]=1
for d in D[1:]:
    if d==0:
        print(0)
        exit()
    C[d] += 1
ans=1
for i in range(1,max(D)+1):
    ans *= powmod(C[i-1],C[i],MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 89048
#include<stdio.h>
typedef long long ll;
int main(void)
{
  ll n,y;
  scanf("%lld %lld",&n,&y);
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n;j++){
      ll k=n-i-j;
      if(k>=0){
        if(i*10000+j*5000+k*1000==y){
          printf("%lld %lld %lld\n",i,j,k);
          return 0;
        }
      }
    }
  }

  puts("-1 -1 -1");
  return 0;
}


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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define MSET(m,v) memset((m),(v),sizeof(m))
#define UB(c,v) (upper_bound((c).begin(),(c).end(),(v)))
#define LB(c,v) (lower_bound((c).begin(),(c).end(),(v)))
#define INREP int TC;cin>>TC;while(TC--)
#define CPPIO ios::sync_with_stdio(false);cin.tie(NULL);
#define PC(x) fixed<<setprecision(x)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

// SOLUTION

int main () {
	CPPIO;
  int val = 0;
  string s;
  cin >> s;
  for (int i = 0; s[i]; i++) {
    if (s[i] == '+') val++;
    else val--;
  }
  cout << val;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct edge {
    int from, to, cost;
};

int f(int n) {
    int ret = 1;
    rep(i, n) ret *= 2;
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    int ll = r;
    int cnt = 0;
    while(ll/2) {
        ll /= 2;
        cnt++;
    }
    V<edge> ans;
    rep(i, cnt) {
        ans.push_back((edge){i+1, i+2, 0});
        ans.push_back((edge){i+1, i+2, f(i)});
    }
    int l = f(cnt);
    r--;
    // [l, r] を作る　-> r - l + 1個作る必要がある
    drep(i, cnt) {
        // r - l + 1　は作らないといけない辺の種類,  f(i)の時に作るとf(i)種類追加できる
        if(r - l + 1 >= f(i)) ans.push_back((edge){i + 1, cnt + 1, l}), l += f(i);
    }
    cout << cnt+1 << " " << size(ans) << endl;
    for(auto e : ans) {
        cout << e.from << " " << e.to <<  " " << e.cost << endl;
    }
}

Measured memory_bytes: 3516
# coding:utf-8

import sys
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    h, w = LI()
    A = LI()
    A.sort()
    B = LI()
    B.sort()

    # A, B内では同じ値は存在できない
    if len(A) != len(set(A)) or len(B) != len(set(B)):
        return 0

    a_i, b_i = h - 1, w - 1
    if h * w > A[a_i] or h * w > B[b_i]:
        return 0

    res = 1
    for n in range(1, h * w + 1)[::-1]:
        while a_i > 0 and A[a_i - 1] >= n:
            a_i -= 1
        while b_i > 0 and B[b_i - 1] >= n:
            b_i -= 1

        if n == A[a_i] and n == B[b_i]:
            res *= 1
        elif n == A[a_i]:
            res *= w - b_i
        elif n == B[b_i]:
            res *= h - a_i
        else:
            res *= (h - a_i) * (w - b_i) - (h * w - n)

        res %= MOD

    return res


print(main())


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector< vector <int> > 
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define r(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

void sieve(int n, vb &prime)
{
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
            for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             }
    }
}
int32_t main ()
{
  //ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
   int h,a;    cin>>h>>a;
   cout<<(h+a-1)/a;
   
  
 
}






Measured memory_bytes: 256
#include<stdio.h>
int n, A[50];
int solve (int i, int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res=solve(i+1,m)||solve(i+1, m-A[i]);
    return res;
}

int main(){
    int q, M, i;
    
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++){
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


Measured memory_bytes: 2692
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();

    int x = a - b;
    System.out.println(Math.max(0, c - x));

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23380
local str = io.read("*l")
local a, z = 0, 0
local flag = false
for i = 1, #str do
  local char = string.sub(str, i, i)
  if flag == false and char == "A" then
    flag = true
    a = i
  elseif char == "Z" then
    z = i
  end
end
local ans = z - a + 1
print(ans)


Measured memory_bytes: 760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
   char a[50+5] , b[50+5];
   cin>>a;
   cin>>b;
   int s1 = strlen(a);
   int s2 = strlen(b);
   int s3 = min(s1,s2);
  // cout<<s1<<" "<<s2<<" "<<s3<<endl;
   for(int i = 0 ; i < s3  ; i++)
    cout<<a[i]<<b[i];
   // cout<<endl;
   for(int i  = s3 ; i < s1  ;i++){
    cout<<a[i];
   }
   for(int i = s3  ; i < s2  ; i++){
    cout<<b[i];
   }
   cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 201910277

Contest: AtCoder Beginner Contest 144.
Problem: F - Fork in the Road
Result : AC

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

typedef long long LL;

const LL MAXN = 6e2+7;

///--------------------------------------------///

double dp[MAXN], d[MAXN], ans;
vector<int> g[MAXN];
int n, m;

void process(int pos, double res[]){
    for(int i = pos; i; --i){
        double cnt = 0;
        for(auto x : g[i]) cnt += res[x]; // Bug 2 is here. Change dp[] to res[]
        int sz = g[i].size();
        res[i] = cnt / sz + 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int s, t, i = 0; i < m; ++i){
        cin >> s >> t;
        g[s].push_back(t);
    }
    process(n-1, dp);
    memcpy(d, dp, sizeof(double)*(n+1)); // Bug 1 is here. memcpy(dist, src, the number of bytes);
    ans = dp[1];
    for(int i = 1; i < n; ++i){
        int sz = g[i].size();
        if(sz < 2) continue;
        double cnt = 0, mx = 0;
        for(auto x : g[i]) {
            cnt += dp[x];
            mx = max(mx, dp[x]);
        }
        cnt -= mx;
        d[i] = cnt / (sz - 1) + 1;
        process(i-1, d);
        ans = min(ans, d[1]);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	vector<int> A(N);
	int pos;
	for (int i = 0; i < N; ++i) {
		scanf("%d", &A[i]);
		if (A[i] == 1) pos = i;
	}
	int ans = 0;
	ans += (N - 1 + K - 2) / (K - 1);
	printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <stdio.h>

#define MAX_N 100000
#define MAX_H 10000
#define MAX_K 3

int N;
typedef struct {
    int a;
    int b;
    int c;
} happiness;
int H[MAX_N][MAX_K+1];
int tmp[MAX_N+1][MAX_K+1];

int max(int a,int b){
    if(a<b){
        return b;
    }else{
        return a;
    }
}

void print_table(int *table,int height,int width, int max_width){
    for(int h=0;h<height;h++){
        printf("| ");
        for(int w=0;w<width;w++){
            printf("%d ",*(table + w + width * h));
        }
        printf("|\n");
    }
}

int ans(){
    if(N==1){
        return max(H[0][0],max(H[0][1],H[0][2]));
    }
    for(int i=2;i<=N;i++){
        int *x_2 = H[i-2];
        int *x_1 = H[i-1];

        for(int j=0;j<MAX_K;j++){
            int m=0;
            for(int k=0;k<MAX_K;k++){
                m=0;
                if(k!=j){
                    for(int l=0;l<MAX_K;l++){
                        if(k!=l){
                            m = max(m,tmp[i-2][l]+x_2[k]);
                        }
                    }
                    tmp[i-1][k] = m;
                }
                
            }
            m=0;
            for(int k=0;k<MAX_K;k++){
                if(k!=j){
                    m=max(m,tmp[i-1][k] + x_1[j]);
                }
            }
            tmp[i][j]=m;
        }
    }
    return max(max(tmp[N][0],tmp[N][1]),tmp[N][2]);
}

int main(){
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d %d %d",&H[i][0],&H[i][1],&H[i][2]);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<MAX_K+1;j++){
            tmp[i][j] = 0;
        }
    }
    printf("%d\n",ans());
    // print_table(tmp,N+1,MAX_K,MAX_K+1);
}

Measured memory_bytes: 3328