akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1000;
const long INF=1e13;
int N,M;
vector<pair<int,long>> g[size];
long score[size]={};int check[size]={};
void dfs(int v){
    check[v]++;
	for(pair<int,long> p:g[v]){
		int u=p.first;
		if(score[u]==INF) continue;
        else if(score[u]<score[v]+p.second){
            if(check[u]) score[u]=INF;
            else score[u]=min(score[v]+p.second,INF);
            dfs(u);
        }
	}return;
}
int main(){
	cin>>N>>M;
	int a,b;long c;
	rep(i,0,M){
		cin>>a>>b>>c;a--;b--;
		g[a].push_back({b,c});
	}
    rep(i,1,N) score[i]=-INF;
	dfs(0);
    //print(score,N);
	if(score[N-1]==INF) cout<<"inf"<<endl;
    else cout<<score[N-1]<<endl;
}

Measured memory_bytes: 384
# 入力高速化

import sys

def rerooting(n, edges, identity, merge, add_node):
    # 全方位木 dp
    # 参考1: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
    # 参考2: https://atcoder.jp/contests/abc160/submissions/15255726
    from functools import reduce
    G = [[] for _ in range(n)]
    for a, b in edges:
        G[a].append(b)
        G[b].append(a)
    # step 1
    order = []  # 行きがけ順
    stack = [0]
    while stack:
        v = stack.pop()
        order.append(v)
        for u in G[v]:
            stack.append(u)
            G[u].remove(v)
    # 下から登る
    dp_down = [0]*n  # 自身とその下
    for v in order[:0:-1]:
        dp_down[v] = add_node(reduce(
            merge, (dp_down[u] for u in G[v]), identity
        ), v)
    # step 2
    # 上から降りる
    dp_up = [identity] * n  # 親とその先
    for v in order:
        Gv = G[v]
        if len(Gv) == 0:
            continue
        cum = identity
        right = [identity]
        for u in Gv[:0:-1]:
            cum = merge(dp_down[u], cum)
            right.append(cum)
        right.reverse()
        cum = dp_up[v]
        for u, cum_r in zip(Gv, right):
            dp_up[u] = add_node(merge(cum, cum_r), v)
            cum = merge(cum, dp_down[u])
    results = [add_node(
        merge(
            reduce(merge, (dp_down[u] for u in Gv), identity),
            dp_up[v]
        ), v
    ) for v, Gv in enumerate(G)]
    return results

class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

def main():
    N = int(sys.stdin.buffer.readline())
    m = map(int, sys.stdin.buffer.read().split())
    AB = tuple((a-1, b-1) for a, b in zip(m, m))
    mod = 10**9 + 7
    comb = Combination(202020)
    identity = (1, 0)
    fac, facinv = comb.fac, comb.facinv
    def merge(a, b):
        a0, a1 = a
        b0, b1 = b
        return a0*b0*fac[a1+b1]*facinv[a1]*facinv[b1]%mod, a1+b1
    def add_node(a, idx):
        a0, a1 = a
        return a0, a1+1
    Ans = rerooting(N, AB, identity, merge, add_node)
    print("\n".join(str(ans) for ans, _ in Ans))

main()


Measured memory_bytes: 167040
n = int(input())
dic_items = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k'\
             ,11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s'
             ,19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
ans = []
while n != 0:
  n -= 1
  ans.append(n%26)
  n = n//26
for i in range(len(ans)):
  print(dic_items[ans[len(ans)-1-i]],end='')



Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;


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

    if(N%2 == 1){
        cout << N/2+1 << endl;
        return 0;
    }
    cout << N/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 998244353;
ll combi(ll N_, ll C_) {
    const int NUM_=4005;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}
ll hcomb(ll P_,ll Q_) { return (P_==0&&Q_==0)?1:combi(P_+Q_-1,Q_);}
ll mod_pow(ll a,ll b){//a^b
    ll ans = 1;
    while(b!=0){
        if(b%2==0){
            b = b/2;
            a = (a*a)%mod;
        }
        else{
            ans = (ans *a)%mod;
            b--;
        }
    }
    return ans;
}
int main(){
    ll k, n;
    cin >> k >> n;
    vector<ll>res;
    for(ll i = 2; i <= k+1; i++){
        ll ans = 0;
        if(i%2){
            ll jiyu = max(0LL,k-i+1);
            ll pea = i/2;
            for(ll q = 0; q <= pea; q++){
                ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+n-q-1+1,q-1+jiyu-1+1))%mod;
            }
        }else{
            //i/2が0個
            {
                ll jiyu = max(0LL,k-i+1);
                ll pea = i/2-1;
                for(ll q = 0; q <= pea; q++){
                    ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+n-q-1+1,q-1+jiyu-1+1))%mod;
                }
            }
            //1個
            {
                ll jiyu = max(0LL,k-i+1);
                ll pea = i/2-1;
                for(ll q = 0; q <= pea; q++){
                    ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+(n-1)-q-1+1,q-1+jiyu-1+1))%mod;
                }
            }
        }
//        cout << ans << endl;
        res.push_back(ans);
    }
    rep(i,k){
        cout << res[i] << "\n";
    }
    res.pop_back();
    reverse(res.begin(),res.end());
    rep(i,k-1){
        cout << res[i] << "\n";
    }
}

Measured memory_bytes: 384
def main():
    from math import sqrt
    n = int(input())
    N = n
    i = 2
    ans = []
    while i<=sqrt(n):
        if n%i==0:
            n //= i
            ans.append(str(i))
        else:
            i += 1
    if n != 1:
        ans.append(str(n))
    print(str(N)+':', ' '.join(ans))

main()



Measured memory_bytes: 5664
# coding: utf-8

(koma_count, target_count) = [int(i) for i in input().rstrip().split(" ")]
target = sorted([int(i) for i in input().rstrip().split(" ")])
area = sorted([target[j] - target[j-1] for j in range(1, target_count)])
must = max(0, target_count-koma_count)

ans = 0
if must > 0:
    ans = sum(area[0:must])
print(ans)


Measured memory_bytes: 13196
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, p;
  cin >> n >> p;
  vector<int> d(5001);
  d[0] = 1;
  for (int i = 1; i <= n; i++) {
    int t; cin >> t;
    for (int j = 5000; j >= t; j--) {
      d[j] += d[j - t];
    }
  }
  int ans = 0;
  for (int i = 0; i <= 5000; i++) {
    if (i % 2 == p) ans += d[i];
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3636
N = int(input())
sum = 0
half_N = int((N ** (1/2)) // 1)
for i in range(half_N):
	if 0 == (N - (i+1)) % (i+1):
		if ((N-(i+1)) / (i+1)) > (i+1):
			sum += ((N - (i+1)) / (i+1))
		
print(int(sum))

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
write = sys.stdout.write

INF = 10**9
def solve():
    N = int(readline())
    if N == 0:
        return False
    K = 0
    E = [[INF]*10 for i in range(10)]
    for i in range(N):
        a, b, c = map(int, readline().split())
        E[a][b] = E[b][a] = c
        K = max(K, a+1, b+1)
    for i in range(K):
        E[i][i] = 0
    for k in range(K):
        for i in range(K):
            for j in range(K):
                E[i][j] = min(E[i][j], E[i][k] + E[k][j])
    k = -1; s = INF
    for i in range(K):
        Ei = E[i]
        v = sum(Ei[j] for j in range(K) if Ei[j] < INF)
        if v < s:
            s = v; k = i
    write("%d %d\n" % (k, s))
    return True
while solve():
    ...


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

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

    int N, x;
    cin >> N >> x;
    if(x==1 || x==2*N-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    if(x==2){
        int cur = 3;
        for(int i=1; i<N-2; i++){
            if(cur==x) cur++;
            cout << cur << endl;
            cur++;
        }
        if(N!=2)
        cout << 2*N-2 << endl;
        cout << 1 << endl;
        cout << x << endl;
        cout << 2*N-1 << endl;
        for(int i=N+2; i<2*N; i++){
            if(cur==x) cur++;
            cout << cur << endl;
            cur++;
        }
    }else{
        int cur=2;
        for(int i=1; i<N-1; i++){
            if(cur==x || cur==x-1) cur++;
            if(cur==x || cur==x-1) cur++;
            cout << cur << endl;
            cur++;
        }
        cout << 1 << endl;
        cout << x << endl;
        cout << 2*N-1 << endl;
        cout << x - 1 << endl;
        for(int i=N+3; i<2*N; i++){
            if(cur==x || cur==x-1) cur++;
            if(cur==x || cur==x-1) cur++;
            cout << cur << endl;
            cur++;
        }
    }
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	// #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n;
	cin>>n;
	if(n == 1){
		cout<<"Hello World";
	}
	else{
		LL a,b;
		cin>>a>>b;
		cout<<a+b;
	}

  	return 0;
}

Measured memory_bytes: 3668
import sys
def input():
    return sys.stdin.readline()[:-1]

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf=UnionFind(N+1)
  
for i in range(M):
  a,b=map(int, input().split())
  uf.union(a,b)

print(uf.group_count()-2)

Measured memory_bytes: 77580
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
   long int small;
   int i,j,pos,n,m,k;

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

    long int a[n],b[n],c[m],d[m],distance[m];

    for(i=0;i<n;i++)
    scanf("%ld%ld",&a[i],&b[i]);

    for(i=0;i<m;i++)
    scanf("%ld%ld",&c[i],&d[i]);


    for(i=0;i<n;i++)
        {
        for(j=0;j<m;j++)
            {
            distance[j]=labs(a[i]-c[j])+labs(b[i]-d[j]);
            }

        small=distance[0];
        pos=1;
        for(k=1;k<m;k++){
            if(distance[k]<small){
            small=distance[k];
            pos=k+1;
            }
        }

        printf("%d\n",pos);
    }
    return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
#include<math.h>
int d;
double data[20];
bool wrong(int c){
    int i,j,check;
    if(c==0)check=1,i=2;
    else check=0,i=1;
    double ans=0.0,tmp;
    //printf("check=%d ",check);
    for(;i<d+3;i++){
        if(i==c)continue;
        tmp=data[i];
        //printf("tmp=data[%d]",i);
        if(c==0)j=2;
        else j=1;
        for(;j<d+3;j++){
                if(j==c)continue;
                if(j==i)continue;
                tmp*=(check-j);
                tmp/=(i-j);
                //printf("*(%d-%d)>%d",check,j,i-j);
        }
        ans+=tmp;
    }
    //printf("%lf %lf\n",ans,data[check]);
    if(fabs(ans-data[check])<1e-3)return true;
    else return false;
}
int main(){
    int i;
    while(scanf("%d",&d)&&d){
        for(i=0;i<d+3;i++)scanf("%lf",data+i);
        for(i=0;i<d+3;i++){
            if(wrong(i)){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX_N 1000010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main(){
    GetInv(); GetFactorial();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    long long ans = 0;
    for (int i = 0; i < min(n, k+1); i++) {
        ans += combination(n, i) * combination(n-1, n-i-1) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	map<string, ll> mp;
	rep(i, n){
		string s;
		cin >> s;
		sort(s.begin(),s.end());

		if(mp.count(s) == 0) mp[s] = 0;
		mp[s]++;
	}

	ll ans = 0;
	for(auto p : mp){
		ll x = p.second;
		ans += x * (x - 1) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	ll bT, aT;
	a--;
	
	ll lcm = LCM(c, d);

	

	bT = b / c + b / d;
	bT  -= b / lcm;
	
	b = b - bT;

	aT = a / c + a / d;
	aT -= a / lcm;

	
	a = a - aT;



	cout << b - a << endl;




}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.input();
    let m: i64 = sc.input();
    let arr: Vec<i64> = sc.vec(m as usize);

    let sum: i64 = arr.iter().sum();
    println!("{}", if n - sum >= 0 { n - sum } else { -1 });
}


Measured memory_bytes: 2168
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
#define sz(x) (int)(x.size())
#define all(x) (x).begin(),(x).end()
template<typename tp> void read(tp &x) {cin >> x;}
template<typename tp, typename... Args> void read(tp& x, Args&... args) {read(x);read(args...);}
const int mxN = (int)1e5,INF = (int)1e9,MOD = (int)1e9+7;

void solve()
{
	int n;
	read(n);
	string s;
	read(s);
	int ans = 0;
	for(int i=0;i<=sz(s)-3;i++)
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			ans++;
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int test = 1;
	//read(test);
	while(test--)
		solve();
	return 0;
}



Measured memory_bytes: 3644
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int ans = 100000000;
		for(int i = 0; i < s.length() - 2; i++) {
			ans = Math.min(ans, Math.abs(Integer.parseInt(s.substring(i, i + 3)) - 753));
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    ll N,D,X;
    cin >> N >> D >> X;
    vector<int> V(N);
    rep(i,N) {
        cin >> V[i];
    }
    int ans = X;
    rep(j,N) {
        int t = 1;
        int count = 0;
        while (t <= D) {
            count++;
            t += V[j];
        }
        ans += count;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
long long nxt[100001],head[100001],to[100001],f[100001],degree[100001],tot=0;
void addedge(long long u,long long v)
{
        ++tot;
        nxt[tot]=head[u];
        to[tot]=v;
        head[u]=tot;
}
long long dfs(long long n)
{
        long long u,v;
        f[n]=0;
        for(u=head[n];u;u=nxt[u])
        {
                v=to[u];
                if(f[v]!=-1)
                        f[n]=max(f[n],f[v]+1);
                else
                        f[n]=max(f[n],dfs(v)+1);
        }
        //printf("%lld %lld\n",n,f[n]);
        return f[n];
}
int main()
{
        long long i,n,m,a,b,ans=0;
        scanf("%lld %lld",&n,&m);
        memset(f,0xff,sizeof(f));
        for(i=1;i<=m;i++)
        {
                scanf("%lld %lld",&a,&b);
                addedge(a,b);
                degree[b]++;
        }
        for(i=1;i<=n;i++)
        {
                if(degree[i]==0)
                {
                        ans=max(ans,dfs(i));
                }
        }
        printf("%lld",ans);
        return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
void solve(){
	string s;
	cin>>s;
	if(s.size() && s.back()=='s') cout<<s<<"es";
	else cout<<s<<"s";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();

}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll X;
    cin >> X;

    REP(a, 10000) REP(b, 10000) REP(i, 2) REP(j, 2) {
        if (i) a = -a;
        ll A = pow(a, 5);

        if (j) b = -b;
        ll B = pow(b, 5);

        if (A - B == X) {
            cout << a << " " << b << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4252
#include<cstdio>
int main(){
	int m,d,i,j,ans=0;
	scanf("%d%d",&m,&d);
	for(i=1;i<=m;++i)
		for(j=22;j<=d;++j)if(j/10>=2&&j%10>=2&&(j/10)*(j%10)==i)++ans;
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
  string s; cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13));
  dp[0][0] = 1;

  rep(i, n) {
    rep(j, 13) {
      if (s[i] == '?') {
        rep(x, 10) {
          (dp[i+1][(j*10+x)%13] += dp[i][j]) %= mod;
        }
      } else {
        int x = s[i] - '0';
        (dp[i+1][(j*10+x)%13] += dp[i][j]) %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;

  return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a - b, max(a + b, a*b)) << endl;
	return 0;
}


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

// ?????§????´¢
bool BinarySearch(int A[], int n, int key) {
	int left = 0 , right = n, mid;

	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid])
			return true;
		
		if(key > A[mid])
			left = mid + 1;
		if (key < A[mid])
			right = mid;
	}
	return false;

}
int main() {
	int n, q, key;
	int sum = 0;
	int A[100000 + 10];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (BinarySearch(A, n, key))
			sum++;
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(void) {
    int S, Sh, Sm, h, m, s;
    
    scanf("%d", &S);
    
    h = S / 3600;
    Sh = S %3600;
    m = Sh / 60;
    Sm = Sh %60;
    s = Sm;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
long long a[100005],b[100005],c[100005],x[100005],y[100005];
int main()
{
	long long n,m,k,mn1=10000005,mn2=10000005,sum1=10000005,sum2=10000005;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	for(int i=0;i<k;i++)
		cin>>x[i]>>y[i]>>c[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]<mn1)
			mn1=a[i];
	}
	for(int i=0;i<m;i++)
	{
		if(b[i]<mn2)
			mn2=b[i];
	}
	sum1=mn1+mn2;
	for(int i=0;i<k;i++)
		sum2=min(a[x[i]-1]+b[y[i]-1]-c[i],sum2);
	cout<<min(sum1,sum2);

	return 0;
}

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

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

	long long int n,k,ans =0; cin >> n >> k;	
	
	long long int m = 1000000007;
	for(long long int i =k;i<=n+1;i++){
		ans += (i*n - (i-1)*i +1)%m;
		ans = ans%m;
	}

	cout << ans ;
	

}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,to) for(i=0;i<(to);i++)

int main() {
	int i, ans = 0;
	vector<int> a(3);

	REP(i, 3) 
		cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());

	while (a[0] != a[1]) {
		a[1]++; a[2]++; ans++;
	}
	while (1) {
		if (a[0] == a[2]) break;
		if (a[0] - a[2] == 1) {
			ans += 2;
			break;
		}
		a[2] += 2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int cnt=0;
  if(n*2<m) {
    cnt+=n;
    m-=n*2;
  }
  else if(n*2==m) {
    cnt+=n;
    m=0;
  }
  else {
    cnt+=min(n,m/2);
    m=0;
  }
  cout<<cnt+m/4<<endl;
}

Measured memory_bytes: 256
import pprint
N, M, C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))

cnt = 0
for j in range(N):
    calc_result = 0
    for k in range(M):
        calc_result += A[j][k] * B[k]
    calc_result += C
    if calc_result > 0:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3572
#include <stdio.h>

int A[10001],n;
int list_accord(int key)
{
	int i;
	int flag = 0;
	for (i = 0; i < n; i++) {
		if (A[i] == key) {
			flag = 1;
			break;
		}
	}
	return flag;
}

int main()
{
	int i, m, temp;
	int sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &temp);
		sum += list_accord(temp);
	}
	printf("%d\n", sum);

	return 0;
}



Measured memory_bytes: 2124
#include <stdio.h>
int main(){

  int kaisu,plus,result=0,i;

  while(1){

    result=0;
    scanf("%d",&kaisu);

    if(kaisu != 0){

      for(i = 0; i < kaisu/4; i++){

        scanf("%d",&plus);

        result += plus;

      }

      printf("%d\n",result);

    } else {

      break;

    }

  }

  return 0;

}

Measured memory_bytes: 596
import sys

if __name__ == "__main__":
    line1 = sys.stdin.readline().strip()
    param1 = line1.split(" ")
    n = int(param1[0])
    m = int(param1[1])
    h = [int(h_i) for h_i in sys.stdin.readline().strip().split(" ")]

    roads = [[] for i in range(n)]

    for i in range(m):
        data = [int(a) - 1 for a in sys.stdin.readline().strip().split(" ")]
        A = data[0]
        B = data[1]
    
        roads[A].append(B)
        roads[B].append(A)

    print(sum([
        1 if len(roads[i]) == 0 or (h[i] > max([ h[j] for j in roads[i]])) else 0
        for i in range(n)        
    ]))



Measured memory_bytes: 30304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }

    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }

    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        y--;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }

    }


    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

int n, a, b;
mint frct[200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a >> b;
    mint ans(2);
    ans.modpow(n);
    frct[0] = 1;
    mint c1(1);
    for(int i = 0; i < a; i++){
        c1 *= (n - i);
        c1 /= (i + 1);
    }

    mint c2(1);
    for(int i = 0; i < b; i++){
        c2 *= (n - i);
        c2 /= (i + 1);
    }
    cout << ans - c1 - c2 - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (K); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

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

  vector<int> a(n), b(n), c(n);
  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  vector<vector<int>> dp(n+1, vector<int>(3, 0));
  REP(i, n){
    dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
    dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
    dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
  }

  int ans = max(dp[n][0], dp[n][1]);
  chmax(ans, dp[n][2]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6912
def main():
    x = int(input())
    
    if x>=1800:
        print(1)
    elif x>=1600:
        print(2)
    elif x>=1400:
        print(3)
    elif x>=1200:
        print(4)
    elif x>=1000:
        print(5)
    elif x>=800:
        print(6)
    elif x>=600:
        print(7)
    elif x>=400:
        print(8)

if __name__ == "__main__":
    main()

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e16;
const int MB = 20;
const int MOD = 2019;

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

	map<int, int> mp;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += mp[i - a[i]];
		mp[a[i] + i]++;
	}
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	//srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 27292
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n, k, q;
vector<int> a;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k >> q;
    a.assign(n, 0);
    F0R(qr, q)
    {
        int x;
        cin >> x;
        a[x - 1]++;
    }
    int sum = 0;
    F0R(i, n)
    {
        sum += a[i];
    }
    F0R(i, n)
    {
        if(sum - a[i] < k) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n,a[100];
  string ans="APPROVED";
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
    if(a[i]%2==0 and a[i]%3!=0 and a[i]%5!=0)
      ans="DENIED";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n;
ll arr[100005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    int cnt=0;
    bool zero=false;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        if(arr[i] < 0){
            cnt++;
        }
        if(arr[i]==0){
            zero=true;
        }
    }
    ll sum=0;
    for(int i=1;i<=n;i++){
            sum += abs(arr[i]);
            arr[i]=abs(arr[i]);
        }
    if(!zero){
        if(cnt%2==1){
            sort(arr+1,arr+1+n);
            sum -= 2*arr[1];
        }
    }
    cout << sum << el;
    return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int x,a,b;
  std::cin >> x >> a >>b;

  if(b<=a)printf("delicious\n");
  else if(b-a<=x)printf("safe\n");
  else printf("dangerous\n");
  return 0;
}


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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        System.out.println((100_000 - n) % 1_000);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

Measured memory_bytes: 32744
#include <iostream>

int main(void)
{
	int n;
	int m = 100000;

	std::cin >> n;

	while (n--) {
		m *= 1.05;
		m = (m + 999) / 1000 * 1000;
	}

	std::cout << m << std::endl;

	return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<pii> a(n);
	rep(i,n){
		cin >> a.at(i).first;
		a.at(i).second = i + 1;
	}
	sort(a.begin(),a.end());
	rep(i,n){
		if(i == n-1) cout << a.at(i).second << endl;
		else cout << a.at(i).second << " ";
	}
}


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

int main() {
		long long int N;
		cin >> N;
		long long int sum = (N - 1) * N /2;
		if(N == 1){
				cout << 0 << endl;
		} else {
				cout << sum << endl;
		}
}
		


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 N;
  cin >> N;
  set<i64> S;
  i64 x;
  REP(i, N) {
    cin >> x;
    S.insert(x);
  }
  if (S.size() == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define inf 1e9

ll n,k;
vector<P> g[111111];
ll dist[111111];
ll vn[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		g[a].pb(P(b,1)); g[b].pb(P(a,1));
	}
	cin>>k;
	memset(vn,-1,sizeof(vn));
	rep(i,k){
		int v,p;
		cin>>v>>p;
		g[0].pb(P(v,p));
		vn[v]=p;
	}
	rep(i,111111)dist[i]=inf;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0,0));
	while(q.size()){
		ll nd=q.top().fi,nv=q.top().se;
		q.pop();
		if(dist[nv]!=inf)continue;
		dist[nv]=nd;
		for(P np:g[nv]){
			q.push(P(np.se+nd,np.fi));
		}
	}
	bool ok=true;
	repl(i,1,n+1){
		if(vn[i]!=-1&&vn[i]!=dist[i])ok=false;
		for(P np:g[i]){
			if(abs(dist[i]-dist[np.fi])!=1)ok=false;
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
		repl(i,1,n+1){
			cout<<dist[i]<<endl;
		}
	}else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 18288
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	ll n,m;cin>>n>>m;
	ll ans = 1;
	FOR(i,1,sqrt(m)+1) {
		if(m%i==0 && m%(m/i)==0 && i*m/i==m) {
			db(i);
			if(n*i<=m) maxself(ans,i);
			if(n*(m/i)<=m) maxself(ans,m/i);
		}
	}
	cout<<ans;

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long a,b;cin>>a>>b;
long c=__gcd(a,b),ans=1;
for(int i=2;i<=1e6;i++){if(c%i!=0)continue;while(c%i==0)c/=i;ans++;}
cout<<ans+(c>1)<<endl;
}


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

#define int int64_t
const int maxn = 1e5 + 13;

int root[maxn], sz[maxn];
int n, m;
int64_t ans = 0;

int dsu_find (int a) {
    if (a == root[a])
        return a;
    return root[a] = dsu_find(root[a]);
}

void dsu_unite (int a, int b) {
    a = dsu_find(a);
    b = dsu_find(b);
    if (a != b) {
        ans -= int64_t(sz[a]) * int64_t(sz[b]);
        if (sz[b] > sz[a]) 
            swap(b, a);
        root[b] = a;
        sz[a] += sz[b];
    }
}

signed main () {
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
        root[i] = i, sz[i] = 1;
    vector < pair < int, int > > edge(m);
    for (int i = 0; i < m; ++i)
        cin >> edge[i].first >> edge[i].second;
    deque < int > answer;
    ans = (int64_t(n) * int64_t(n - 1)) / 2;
    for (int i = m - 1; i >= 0; --i) {
        answer.push_front(ans);
        dsu_unite(edge[i].first, edge[i].second);
    }
    for (int i = 0; i < int(answer.size()); ++i)
        cout << answer[i] << '\n';
}


Measured memory_bytes: 5248