akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

struct UniTree {
    int *par, *rank;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};


bool comp(const edge& e1,const edge& e2) {
    return e1.cost < e2.cost;
}

edge G[2000];

int main() {
    int V, E;
    cin >> V >> E;
    rep(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[i] = {a, b, -c};
    }

    ll d[1000];
    fill(d, d + V, LINF);
    d[0] = 0;
    rep(i, V) {
        bool update = false;
        rep(j, E) {
            edge e = G[j];
            if(d[e.from] != LINF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
    }

    bool nega[1000];
    fill(nega, nega + V, false);
    rep(i, V) {
        rep(j, E) {
            edge e = G[j];
            if(d[e.from] != LINF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                nega[e.to] = true;
            }

            if(nega[e.from]) nega[e.to] = true;
        }
    }

    if(nega[V - 1]) {
        cout << "inf" << endl;
    }else {
        cout << -d[V - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
H,W,M=map(int,input().split())
row=[0]*H
col=[0]*W
target=set()
for i in range(M):
    h,w=map(int,input().split())
    row[h-1]+=1
    col[w-1]+=1
    target.add((h-1,w-1))
A=max(row)
B=max(col)
a=[x for x in range(H) if row[x]==A]
b=[x for x in range(W) if col[x]==B]
cnt=0
for i in a:
    for j in b:
        cnt+=1
        if (i,j) not in target:
            print(A+B)
            exit(0)
        if cnt>M:
            print(A+B-1)
            exit(0)
print(A+B-1)

Measured memory_bytes: 83572
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]  
    n = int(input())
    a = []
    for _ in range(n):
        x, l = [int(x) for x in input().split()]  
        s = x - l
        e = x + l
        a.append((s, e))
    a.sort(key=lambda x: x[1])
    ans = 0
    l = float('-inf')
    for s, e in a:
        if s >= l:
            l = e
        else:
            ans += 1
    print(n-ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""


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


int main() {

    int n;
    cin >> n;
    for (int i = n; i > 0; --i) {
        if (i == 2 || i == 4 || i == 8 || i == 16 || i == 32 ||i == 64 ) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, C = map(int, input().split())
T = 10**5+2

c_ls = [[0] * T for _ in range(C)]
# いもす
for i in range(N):
    s, t, c = map(int, input().split())
    c_ls[c-1][s] += 1
    c_ls[c-1][t] -= 1
# 各チャンネル毎の累積和
for i in range(C):
    for j in range(1, T):
        c_ls[i][j] += c_ls[i][j-1]
# 他チャンネルとの重複を見るために開始を1早める
for i in range(C):
    for j in range(1, T):
        if c_ls[i][j] > c_ls[i][j-1]:
            c_ls[i][j-1] += 1
# 全チャンネルを合計
sm = [0] * T
for i in range(C):
    for j in range(T):
        sm[j] += c_ls[i][j]
# 重複が一番多くなる箇所が答え
print(max(sm))


Measured memory_bytes: 69848
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long W, H, x, y;
    cin >> W >> H >> x >> y;
    if(x == W / 2 and y == H / 2 and H % 2 == 0 and W % 2 == 0) {
        cout << (double)H * W / 2 << " "
             << "1" << endl;
    } else {
        cout << (double)H * W / 2 << " "
             << "0" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
csf = []
for _ in range(n - 1):
    csf.append(list(map(int, input().split())))

for i in range(n):
    tim = 0
    for c, s, f in csf[i:]:
        tim = max(-(-tim // f) * f, s) + c
    print(tim)


Measured memory_bytes: 3316
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cassert>
#include<vector>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=2e5+20;
const int mod=1e9+7;

inline void pls(int &a,int b){ a+=b;if(a>=mod)a-=mod;}

#define pii pair<int,int>

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int n,a[maxn],id[maxn];
int inv[maxn];
int S=1;
int pre[maxn],suf[maxn];

pii Pre[maxn],Suf[maxn];

inline pii operator *(pii a,pii b){ return mkr((ll)a.fi*b.fi%mod,a.se+b.se);}
inline pii operator /(pii a,pii b){ return mkr((ll)a.fi*power(b.fi,mod-2)%mod,a.se-b.se);}
inline pii Num(int x){ return !x?mkr(0,1):mkr(x,0);}

inline void init()
{
	n=read();
	REP(i,1,n)a[i]=read(),id[i]=i;
	sort(id+1,id+n+1,[](int x,int y){ return a[x]<a[y];});
	REP(i,1,n)S=(ll)S*(a[id[i]]-i+1)%mod;
	if(!S)puts("0"),exit(0);
	inv[1]=1; REP(i,2,n)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	pre[0]=1; REP(i,1,n)pre[i]=(ll)pre[i-1]*(a[id[i]]-i+1)%mod;
	suf[n+1]=1; DREP(i,n,1)suf[i]=(ll)suf[i+1]*(a[id[i]]-i+1)%mod;
	Pre[0]=mkr(1,0); REP(i,1,n)Pre[i]=Pre[i-1]*Num(a[id[i]]-i+1);
	Suf[n+1]=mkr(1,0); DREP(i,n,1)Suf[i]=Suf[i+1]*Num(a[id[i]]-i+1);
}

int s[maxn],vis[maxn],tim;
inline void Add(int x,int d,int Rev){ for(x=Rev?n-x+1:x;x<=n;x+=x&(-x))vis[x]==tim?(pls(s[x],d),0):(vis[x]=tim,s[x]=d);}
inline int Sum(int x,int Rev){ int res=0;for(x=Rev?n-x+1:x;x;x-=x&(-x))(vis[x]!=tim?(vis[x]=tim,s[x]=0):(pls(res,s[x]),0));return res;}

int ans;

inline void doing()
{
	int de=1;
	DREP(i,n,1)
	{
		int u=id[i];
		int t=Sum(u+1,1);
		pls(ans,(ll)pre[i-1]*de%mod*t%mod*(((ll)(a[u]-i+1)*(a[u]-i)>>1)%mod)%mod);
		if(a[u]-i)de=(ll)de*(a[u]-i)%mod;
		else de=1,++tim;
		Add(u,(ll)suf[i+1]*power(de,mod-2)%mod,1);
	}

	++tim;
	DREP(i,n,1)
	{
		int u=id[i];
		int t=Sum(u-1,0);
		pls(ans,(ll)t*pre[n]%mod);
		Add(u,1,0);
	}
	++tim;

	de=1;
	DREP(i,n,1)
	{
		int u=id[i];
		int t=Sum(u-1,0);
		pls(ans,mod-(ll)pre[i-1]*de%mod*t%mod*(((ll)(a[u]-i+1)*(a[u]-i)>>1)%mod)%mod);
		if(a[u]-i)de=(ll)de*(a[u]-i)%mod;
		else de=1,++tim;
		Add(u,(ll)suf[i+1]*power(de,mod-2)%mod,0);
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



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


Measured memory_bytes: 3132
#include <cstdio>
#include <iostream>
using namespace std;
int main(){

	int a[200];
	int n;
	cin >> n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	int max = -100;
	int min = 100;
	for(int i=1;i<=n;++i){
		max = a[i]<max?max:a[i];
		min = a[i]>min?min:a[i];
	}
	int r = min;
	int sum_r = 100000000;
	int sum = 0;
	for(int j=min;j<=max;++j){
		sum=0;
		for(int i=1;i<=n;++i){
			sum += (j-a[i])*(j-a[i]);
		}
		if(sum<sum_r){
			sum_r = sum;
			r = j;
		}
		
	}
	cout << sum_r;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v;
void addstr(ll s,ll n){
  if(n==9)return;
  ll a=s*10+3,b=s*10+5,c=s*10+7;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  addstr(a,n+1);
  addstr(b,n+1);
  addstr(c,n+1);
  return;
}
  
int main(){
  ll n;cin>>n;
  addstr(0,0);
  sort(v.begin(),v.end());
  //for(ll i=0;i<100;i++)cout<<v[i]<<" ";
  ll ans=0;
  for(ll i=0;i<v.size();i++){
    ll m=v[i];
    if(m>n)break;
    ll a[9];
    for(ll i=0;i<9;i++)a[i]=0;
    for(ll i=0;;i++){
      a[m%10]++;
      m=m/10;
      if(m==0)break;
    }
    if(a[3]>=1&&a[5]>=1&&a[7]>=1)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		list.add(sc.nextInt());
		list.add(sc.nextInt());
		list.add(sc.nextInt());
		int fi = 0;
		int se = 0;
		for (int i : list) {
			if (i == 5) {
				fi += 1;
			} else if (i == 7) {
				se += 1;
			}
		}
		if (fi == 2 && se == 1) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	vector<bool> used(24, false);
	ll ans  = 114514;
	used[0] = true;

	for (int i = 0; i < n; i++) {
		ll x = (i % 2 == 0) ? d[i] : (24 - d[i]) % 24;
		//dump(x);
		if (!used[x])
			used[x] = true;
		else {
			dump(0);
			return 0;
		}
	}
	//dump("unko");
	for (int i = 0; i < 24; i++) {
		for (int j = i + 1; j < 24; j++) {
			if (used[i] && used[j]) {
				ans = min(ans, (ll)min(j - i, 24 - (j - i)));
			}
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n,k;cin>>n>>k;

  if((n+1-2*k)<0){
    cout<<-1<<endl;
    return 0;
  }

  int a,b,c;
  a = k;
  c = k+2*n;
  b = c-a;

  bool use[3*n];
  REP(i,3*n){
    use[i] = false;
  }
  ll num = 0;
  use[a-k] = true;
  use[b-k] = true;
  use[c-k] = true;
  cout<<a<<" "<<b<<" "<<c<<" "<<endl;
  a++;
  b++;
  num++;
  c += 2;
  while(c<(k+3*n) && b<(k+2*n)){
    use[a-k] = true;
    use[b-k] = true;
    use[c-k] = true;
    cout<<a<<" "<<b<<" "<<c<<" "<<endl;
    a++;
    b++;
    c += 2;
    num++;
  }
  a = k;
  b = k+n;
  c = k+2*n;
  while(num<n){
    while(true){
      if(use[a-k] == true){
        a++;
      }else{
        break;
      }
    }
    while(true){
      if(use[b-k] == true){
        b++;
      }else{
        break;
      }
    }
    while(true){
      if(use[c-k] == true){
        c++;
      }else{
        break;
      }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    a++;
    b++;
    c++;
    num++;
  }




/*
  bool use[3*n];
  REP(i,3*n){
    use[i] = false;
  }

  int a,b,c;
  a = k;
  b = k+2*n - 1;
  c = a+b;
  cout<<a<<" "<<b<<" "<<c<<endl;
  use[a] = true;
  use[b] = true;
  use[c] = true;
  while(b>a){
    b--;
    a += 2;
    c = a+b;
    use[a] = true;
    use[b] = true;
    use[c] = true;
    cout<<a<<" "<<b<<" "<<c<<endl;
  }*/



 

  return 0;
}

Measured memory_bytes: 2560
N, A, B = gets.chomp.split(" ").map(&:to_i)
sum = 0

(1..N).each do |n|
  s = n%10 + (n/10)%10 + (n/100)%10 + (n/1000)%10 + (n/10000)%10
  if A <= s && s <= B
    sum += n
  end
end

p sum


Measured memory_bytes: 1788
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (n, k) = {
        let t: Vec<usize> = read_vec();
        (t[0], t[1])
    };
    let mut p: Vec<i32> = read_vec();
    p.sort();
    println!("{}", p.into_iter().take(k).fold(0, |s, x| s + x));
}

Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
 
class Program
{
    static void Main()
    {
        var S = Console.ReadLine();
        if (S.EndsWith("s")) S = S + "es";
        else S = S + "s";
 
        Console.WriteLine(S);
    }
}

Measured memory_bytes: 26192
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int n, m;
int member[101010];
vector<int> other;
int dp[202020];

bool C(int mid){

	for (int i = 0; i < 202020; i++)dp[i] = HINF;

	for (int i = 0; i < n; i++) {
		dp[i] = (~member[i] ? (member[i] >= mid ? 0 : HINF) : 1);
	}

	int count = 0;
	for (int i = 0;; i++) {
		dp[i + n] = min({ dp[i * 3] + dp[i * 3 + 1],dp[i * 3] + dp[i * 3 + 2],dp[i * 3 + 1] + dp[i * 3 + 2] });
		dp[i + n] = min(dp[i + n], HINF);
		count = dp[i + n];
		if (i * 3 + 3 == i + n) break;
	}

	int count2 = 0;

	for (int i = 0; i < other.size(); i++) {
		count2 += other[i] >= mid;
	}

	return (count <= count2);
}

int main(){
	cin >> n >> m;
	
	for (int i = 0; i < 101010; i++)member[i] = -1;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		member[--y] = x;
	}

	for (int i = 0; i < n - m; i++) {
		int x;
		cin >> x;
		other.emplace_back(x);
	}

	int left = 1, right = 1000000000;

	while (left != right) {
		int mid = (left + right + 1)>>1;

		if (C(mid)) left = mid;
		else right = mid - 1;
	}

	cout << left << endl;

}


Measured memory_bytes: 4560
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<unordered_set<int>> g(n);
  rep(i,n-1){
    int x,y;
    cin>>x>>y; --x; --y;
    g[x].insert(y);
    g[y].insert(x);
  }
  vector<int> usd(n);
  queue<int> q;
  rep(i,n)if(g[i].size()==1) q.push(i);
  while(q.size()){
    int x=q.front(); q.pop();

    if(usd[x]){
      
      continue;
    }
    if(g[x].empty()){
      break;
    }    int y=*g[x].begin();
    if(usd[y]){
      break;
      cout<<"First"<<endl;
      return 0;
    }
    //out(x,y,1);
    usd[x]=usd[y]=1;
    for(int z:g[y])if(z!=x){
	g[z].erase(y);
	if(g[z].size()==1) q.push(z);
      }
  }
  cout<<(accumulate(all(usd),0)==n?"Second":"First")<<Endl;
  return 0;
}


Measured memory_bytes: 16896
#include <stdio.h>
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    int x = a + b;
    int y = a - b;
    int z = a * b;
    if (x < z) x = z;
    if (x < y) x = y;
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

class C {
	int N, M, ans{ 0 };
	vector<int> X;
public:
	void solve()
	{
		if (M > 1 && M > N)
		{
			for (int i{ 0 }; i < M; i++)
				cin >> X[i];

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

			vector<int> dX(M - 1);
			for (int i{ 0 }; i < M - 1; i++)
				dX[i] = X[i + 1] - X[i];

			if (N > 1)
				sort(dX.begin(), dX.end());

			ans = accumulate(dX.begin(), dX.end() - (N - 1), 0);
		}

		cout << ans << endl;
	}

	C() { cin >> N >> M; X.resize(M); }
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
map<int,int>mp;
int n, a[100010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	int ans = 0;
	for (auto p : mp) {
		if (p.second > 0)ans++;
	}
	cout << ans << endl;
}



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

class Card {
	final private String str;
	final private int number, id;
	public Card(String str, int id) {
		super();
		this.str = str;
		this.number = Integer.parseInt(str.substring(2));
		this.id = id;
	}
	public final int getNumber() {
		return number;
	}
	public final int getId() {
		return id;
	}
	@Override
	public final String toString() {
		return str;
	}

}


public class Main {

	private static void swap(Card[] arr, int a, int b) {
		Card c = arr[a];
		arr[a] = arr[b];
		arr[b] = c;
	}

	private static int partition(Card[] arr, int p, int r) {
		Card x = arr[r];
		int i = p - 1;
		for (int j = p; j < r; j++) {
			if (arr[j].getNumber() <= x.getNumber()) {
				swap(arr, ++i, j);
			}
		}
		swap(arr, ++i, r);
		return i;
	}
	private static void quickSort(Card[] arr, int p, int r) {
		if (p >= r) return;
		int q = partition(arr, p, r);
		quickSort(arr, p, q - 1);
		quickSort(arr, q + 1, r);
	}
	private static boolean isStable(Card[] arr) {
		for (int i = 0, n = arr.length; i < n - 1; i++) {
			if (arr[i].getNumber() == arr[i + 1].getNumber() &&
					arr[i].getId() > arr[i + 1].getId()) {
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args)  {
		try(BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));) {
			int n = Integer.parseInt(br.readLine());
			StringBuilder sb = new StringBuilder();
			Card[] arr = new Card[n];
			for (int i = 0; i < n; i++) {
				arr[i] = new Card(br.readLine(), i);
			}
			quickSort(arr, 0, n - 1);
			sb.append(isStable(arr) ? "Stable\n" : "Not stable\n");
			for (int i = 0; i < n; i++) {
				sb.append(arr[i]).append('\n');
			}
			System.out.print(sb);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 49600
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char** argv){
    int N, K;
    string str;
    cin >> N >> K;
    cin >> str;
    int l = 0, r = 0, s = 0;
    int m = 0;
    while(r < str.length()){
        if(str[r] == '1'){
            r++;
        } else {
            s++;
            while(r < str.length() && str[r] == '0'){
                r++;
            }
            if(s > K){
                s--;
                while(l < r && str[l] == '1'){
                    l++;
                }
                while(l < r && str[l] == '0'){
                    l++;
                }
            }
        }
        m = max(m, r-l);
    }
    cout << m << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S;
  cin >> T;
  auto s = S.begin();
  auto t = T.begin();
  auto ans = true;
  while (s != S.end()) {
    // cout << *s << " " << *t << endl;
    if (*s != *t) ans = false;
    if (!ans) break;
    ++t;
    ++s;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[N][N]={0};
int color[N]={WHITE},D[N],F[N],tt=0;
void DFS_VISIT(int u){
  int v;
  color[u]=GRAY;
  D[u]=++tt;
  REP(v,n){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE) DFS_VISIT(v);
  }
  color[u]=BLACK;
  F[u]=++tt;
}
void DFS(){
  int u;
  REP(u,n) if(color[u]==WHITE) DFS_VISIT(u);
  REP(u,n) printf("%d %d %d\n",u+1,D[u],F[u]);
}
int main(){
  int u,v,k;
  scanf("%d",&n);
  REP(i,n){
    scanf("%d %d",&u,&k);
    u--;
    REP(j,k){
      scanf("%d",&v);
      M[u][--v]=1;
    }
  }
  DFS();
  return 0;
}

Measured memory_bytes: 2708
#include<bits/stdc++.h>
#define MAXN 1005
#define mod int(1e9+7)
using namespace std;
int N,M;
int a[MAXN];
long long f[25][MAXN];
long long jie[MAXN],ijie[MAXN];
long long kuaisumi(long long x,int y)
{
	long long ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}
void yuchuli()
{
	jie[0]=1; ijie[0]=1;
	for(int i=1;i<=N;i++)
	{
		jie[i]=(jie[i-1]*i)%mod;
		ijie[i]=kuaisumi(jie[i],mod-2);
	}
}
long long C(int x,int y)
{
	return jie[x]*ijie[y]%mod*ijie[x-y]%mod;
}
int main()
{
	cin>>N>>M;
	yuchuli();
	for(int i=1;i<=M;i++) cin>>a[i];
	f[0][0]=1;
	for(int i=1;i<=M;i++)
		for(int j=0;j<=N;j++)
			for(int k=0;k<=min(j,a[i]);k++)
				f[i][j]=(f[i-1][j-k]*C(N-j+k,k)%mod*C(N-k,a[i]-k)%mod+f[i][j])%mod;
	cout<<f[M][N]%mod;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int N = 1e3 + 3;
const int mod = 1e9 + 7;
int n;
int ans;
bool prime(int num){
    for(int i = 2 ; i * i <= num ; ++i){
        if(num % i == 0){
            return 0;
        }
    }
    return 1;
}
int get(int p){
    int res = 0;
    int num = n / p;
    while(num){
        res += num;
        num /= p;
    }
    return res;
}
int main(){
    cin >> n;
    ans = 1;
    for(int i = 2 ; i <= n ; ++i){
        if(prime(i)){
            ans = (1LL * ans * (get(i) + 1LL)) % mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define int long long
#define pb push_back
#define getMat(v, n, m, val) vector<vector<int>> v(n,vector<int>(m, val))
#define lb lower_bound
#define up upper_bound
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define size(v) (int)v.size()
using namespace std;
const int mod = 1e9+7;

int32_t main(){
    fastio;
    
    int n; cin >> n;
    vector<pair<int,int>> a;
    for(int i=0; i<n; i++){
        int u, v; cin >> u >> v;
        a.pb({u,v});
    }

    int cnt = 0, flag = 0;
    for(int i=0; i<n; i++){
        if(a[i].ff == a[i].ss){
            if(flag){
                cnt++;
            }else{
                flag = 1;
                cnt = 1;
            }
        }else{
            flag = 0;
        }
        if(cnt >= 3){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

  int result = 0;
  if (A+B>=C*2) {
    if (X>=Y) result = C*2*Y + min(A, C*2)*(X-Y);
    else result = C*2*X + min(B, C*2)*(Y-X);
  }
  else result = A*X + B*Y;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n, minv, maxv;
  std::cin >> n;
  int R[n];
  for (int ii = 0; ii < n; ii++) {
    std::cin >> R[ii];
  }
  minv = R[0];

  for (int i = 1; i < n; i++) {
    if (i == 1) {
      maxv = R[1] - R[0];
    }
    if (maxv < R[i] - minv) {
      maxv = R[i] - minv;
    }
    if (minv > R[i]) {
      minv = R[i];
      // maxv = R[i];
    }
  }
  std::cout << maxv << std::endl;
  return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
const ll INF = 1e9;
//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll POW_mod(auto, auto, auto);



ll comb(ll n, ll r) {
    const ll MOD = 1e9+7;
    ll sum = 1;
    for(ll i=n;i>n-r;i--) sum = (sum*i)%MOD;
    for(ll i=r;i>0;i--) sum = (sum*POW_mod(i, MOD-2, MOD)%MOD)%MOD;
    return sum;
}

int main(){
  faster();
  ll x ,y;
  cin >> x >> y;
  ll sum = x + y;
  if(sum%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll turn = sum / 3;
  ll place = ((x>=y) ? x-turn : y-turn);
  cout << comb(turn, place) << endl;
}








































//以下、ライブラリ

void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
} //ユークリッドの互除法

ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} //桁数取得

ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    y--;
    y/=2;
    ll temp = POW(x,y);
    return (temp*temp*x);
  }
  else{
    y/=2;
    ll temp = POW(x,y);
    return temp*temp;
  }
} //べき乗計算

ll POW_mod(auto x, auto y, auto z){
  if(y==0) return 1;
  if(y%2 == 1){
    return ((POW_mod(x,y-1,z)*x)%z);
  }
  else{
    ll temp = POW_mod(x,y/2,z)%z;
    return (temp*temp)%z;
  }
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- forM [1..n] (\i -> (read::String -> Int) <$> getLine)
  let sorted = reverse . sort $ arr
  forM_ arr (\x -> if x == sorted !! 0 then print (sorted !! 1) else print (sorted !! 0))


Measured memory_bytes: 106236
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

template<class T>
istream& operator >> (istream& is, T& vec){
    for(auto&& x:vec) is >> x;
    return is;
}

template<class T>
auto operator<<(std::ostream& os, const T& vec)
    -> typename std::conditional<true, std::ostream&, decltype(*vec.begin())>::type{
    os << "[ ";
    for(auto it = vec.begin(); it != vec.end(); ++it){
        os << *it << (it+1 == vec.end() ? " " : ", ");
    }
    os << "]";
    return os;
}

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

template<typename T>
struct edge{
    int f, t;
    T data;
    edge(int f_, int t_, T data_):f(f_), t(t_), data(data_){};
    edge(){};
    bool operator<(const edge& r){
        return this->data < r.data;
    }
};

template<typename T>
struct graph{
    vector< vector< edge<T> > > data;
    graph(int n):data(n){};
    graph(){};
    int size(){
        return (int)data.size();
    }
    void add_edge(int f, int t, T c){
        data[f].emplace_back(f, t, c);
    }
};

template<typename T>
vi scc_tarjan(graph<T> &g){
    vi index(g.size(), -1);
    vi lowlink(g.size(), -1);
    vi scc(g.size(), -1);
    stack<int> s;
    vb ons(g.size(), false);
    int dfs_index = 0, scc_index = 0;
    
    function<void(int)> sc = [&](int v){
        index[v] = dfs_index;
        lowlink[v] = dfs_index;
        dfs_index++;
        s.push(v);
        ons[v] = true;
        for(int i=0;i<g.data[v].size();i++){
            int w = g.data[v][i].t;
            if(index[w] < 0){
                sc(w);
                lowlink[v] = min(lowlink[v], lowlink[w]);
            }else if(ons[w]){
                lowlink[v] = min(lowlink[v], index[w]);
            }
        }
        if(lowlink[v] == index[v]){
            int w;
            do{
                w = s.top();
                s.pop();
                ons[w] = false;
                scc[w] = scc_index;
            }while(w != v);
            scc_index++;
        }
    };
    for(int i=0;i<g.size();i++)
        if(index[i] < 0)sc(i);
    return scc;
};

int main(){
    int V, E;
    cin >> V >> E;
    graph<int> g(V);
    for(int i=0;i<E;i++){
        int s, t;
        cin >> s >> t;
        g.add_edge(s, t, 0);
    }
    vi ret = scc_tarjan(g);
    int Q;cin >> Q;
    for(int i=0;i<Q;i++){
        int u, v;
        cin >> u >> v;
        cout << (ret[u] == ret[v]) << endl;
    }
    return 0;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int sum = 0, n;
	cin >> n;
	for (size_t i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int x = 1;
		
		while(N >= x){
			x = x * 2;
		}
		System.out.println(x / 2);
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    ll a_d = a / x;
    ll a_r = a % x;
    ll b_d = b / x;
    ll b_r = b % x;

    if(a_d == b_d) {
        if(a_r == 0) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    } else {
        ll ans = b_d - a_d;
        if(a_r == 0) ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"
import "sort"

func main() {
	var n int
	var a []int
	fmt.Scan(&n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	fmt.Println(a[n-1] - a[0])
}


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

long inf = 1000000007;

long calc(long a,long b,long p){
  if(b == 0){
    return 1;
  }
  else if(b % 2 == 0){
    long d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else{
    return (a*calc(a,b-1,p)) % p;
  }
}
vector<long> keiro(long start,long end,long height){
  long kekka = 1;
  //start+height-2 c height-1
  for(long i = 0;i < height-1;i++){
    kekka = (kekka*(start+height-2-i)) % inf;
    //cout << kekka << endl;
  }
  for(long i = 1;i <= height-1;i++){
    kekka = (kekka*calc(i,inf-2,inf)) % inf;
    //cout << kekka << endl;
  }
  vector<long> result;
  result.push_back(kekka);
  for(long i = start+height-1;i <= height+end-2;i++){
    kekka = (kekka*i) % inf;
    kekka = (kekka*calc(i-height+1,inf-2,inf)) % inf;
    //cout << "kekka" << ' ' <<  kekka << endl;
    result.push_back(kekka);
  }
  return result;
}

int main(){
  long h,w,a,b;
  cin >> h >> w >> a >> b;
  vector<long> x,y;
  x = keiro(b+1,w,h-a);
  y = keiro(1,w-b,a);
  reverse(y.begin(),y.end());
  long result = 0;
  //for(int i = 0;i < x.size();i++){
    //cout << x.at(i) << ' ' << y.at(i) << endl;
  //}
  for(int i = 0;i < w-b;i++){
    result += (x.at(i)*y.at(i))%inf;
    result %= inf;
  }
  cout << result << endl;
}

Measured memory_bytes: 2548
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int c;
    cin>>n>>m>>c;
    if(n<=c&&c<=m)yes;
    else no;
}


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())

    print('Yes') if '9' in str(N) else print('No')

if __name__ == '__main__':
    main()

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

using namespace std;

#define x first
#define y second
typedef long long ll;
const int N = 100010;
const int mod = 1000000007;
const int oo = 1e9;
const int base = 27;
typedef pair<int,int> pii;

int n , k;

int main() {
  cin >> n >> k;
  if((n+1)/2 >= k){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int coin[] = {10, 50, 100, 500};
int ret;
int d;
bool ok;

int main()
{
  while(cin >> ret, ret){
    if(ok) cout << endl;
    vi m;
    rep(i, 4){
      cin >> d;
      m.pb(d);
    }

    int sum = 0;
    rep(i, 4) sum += coin[i] * m[i];
    sum -= ret;
    rev(i, 4) while(sum >= coin[i]) m[i] -= 1,  sum -= coin[i];
    rep(i, 4) if(m[i] > 0) cout << coin[i] << ' ' << m[i] << endl;
    ok = true;
  }

  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<math.h>
#include<climits>
#include<map>

using namespace std;
#define ll long long

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll l;
	ll lvl;
	cin >> l;
	cin >> lvl;
	ll count = 0;
	while (l--)
	{
		ll x;
		ll y;
		cin >> x;
		cin >> y;
		x = x * x;
		y = y * y;
		x = x + y;
		if (sqrt(x) <=  lvl)
		{
			count++;
		}

	}
	cout << count;
}



Measured memory_bytes: 3680
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main 
{
	static long[][] res;
	static Scanner sc = new Scanner(System.in);
	static int vn;
	static int en;
	static int[] parent; //parent of each node in the path, for backtracking
	
	static boolean BFS() //find an augmenting path if existing
	{
//		System.out.println("BFS starts");
		boolean[] visited = new boolean[vn];
		
		int pos = 0;
		
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add(0);
		
		while(!q.isEmpty())
		{
			pos = q.pop();
			
			//reached sink?
			if(pos == vn-1)return true;
			
			for(int i = 0; i < vn; i++)
			{
				if(res[pos][i] > 0 && !visited[i])
				{
					visited[i] = true;
					parent[i] = pos;
					q.push(i);
				}
			}
		}
		
//		if(visited[vn-1])System.out.println("FATAL ERROR");
//		System.out.println("FALSE");
//		System.out.println(Arrays.toString(visited));
		
		return false;
	}
	
	public static void main(String[] args) 
	{
		int ans = 0;
		vn = sc.nextInt();
		en = sc.nextInt();

		res = new long[vn][vn];
		parent = new int[vn];
		
		for(int i = 0; i < en; i++)
		{
			int v1 = sc.nextInt();
			int v2 = sc.nextInt();
			int cap = sc.nextInt();
			
			res[v1][v2] = cap;
		}
		
		while(BFS() == true)
		{
			//update residuals on each edge in the path
			long minflow = 9999999999l;
			int backtrackpos = vn-1;
			
//			System.out.println(Arrays.toString(parent));
			while(backtrackpos != 0)
			{
				minflow = Math.min(minflow, res[parent[backtrackpos]][backtrackpos]);
				
				if(backtrackpos == 0)break;
				backtrackpos = parent[backtrackpos];
				
			}
			
			ans += minflow;
//			System.out.println("minflow " + minflow);
			//update flows
			backtrackpos = vn-1;
			while(backtrackpos != 0)
			{
				res[parent[backtrackpos]][backtrackpos] -= minflow;
				res[backtrackpos][parent[backtrackpos]] += minflow;
				
				backtrackpos = parent[backtrackpos];
			}
		}
		
		System.out.println(ans);
	}

}



Measured memory_bytes: 34816
#include<bits/stdc++.h>
using namespace std;
#define int  long long

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n, k , q;
  cin>>n>>k>>q;
  int a[n+1];
  memset(a,0,sizeof(a));
  for(int i = 0 ; i <q ; i ++){
    int p ;
    cin>>p;
    if(p==0){
      a[p]++;
      a[p+1]--;
    }else{
      a[p]++;
      a[p+1]--;
      a[1]--;
    }
  }
  for(int i = 1 ; i <= n ; i++){
    a[i]+=a[i-1];
    if(a[i]+k >0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }



int main(){
  int N,K;
  cin >> N >> K;
  cout << (N+(K-1))/K - N/K<< endl;
}
  




Measured memory_bytes: 256