akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


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

vi g[MX];
int h[MX];

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

    int cnt = 0;
    int  n, m;
    cin >> n >> m;
    fi(0, n)
    	cin >> h[i];
    fi(0, m) {
    	int a, b;
    	cin >> a >> b;
    	--a;
    	--b;
    	g[a].push_back(b);
    	g[b].push_back(a);
    }
    fi(0, n) {
    	bool good = true;
    	fx(to, g[i])
    		good &= h[i] > h[to];
 		cnt += good;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 12604
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();
        long a=sc.nextLong()-1;
        long b=sc.nextLong();
        long c=sc.nextLong();
        long d=sc.nextLong();
        long ans=0;
        long l=c*d/gcd(c,d);
        ans = b -b/c -b/d +  + b/l;
		ans -= a -a/c -a/d +  + a/l;
		
        out.println(ans);
        out.flush();
    }
    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    double c;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    	this.c=(double)b/a;
//    }
//
//    public int compareTo(P p){
//        return Double.compare(p.c,c);
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21076
N,K = map(int,input().split())
p = list(map(int,input().split()))
want = sum(p[0:K])
change = sum(p[0:K])

for i in range(1,N-K+1):
    change = change - p[i-1] + p[i+K-1]
    want = max(change,want)

print((K+want)/2)

Measured memory_bytes: 71792
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
set<string>S;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		string str1;
		cin>>str1;
		S.insert(str1);
	}
	cout<<S.size()<<endl;
	return 0;
}


Measured memory_bytes: 19220
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair< int, pair<int, int> > hpq;

int main()
{
	int n, m, a, i;


	while( cin >> n >> m >> a, (n||m||a))
	{
		vector<hpq> vec;
		vec.clear();

		for( i = 0 ; i < m ; i++)
		{
			hpq bar;
			int h, p, q;
			cin >> h >> p >> q;

			bar.first = h;
			bar.second.first = p;
			bar.second.second = q;

			vec.push_back(bar);
		}

		sort(vec.rbegin(), vec.rend() );
		int nowh = vec[0].first;


		for( i = 0; i < vec.size(); i++)
		{
			if( nowh >= vec[i].first )
				if( vec[i].second.first == a)
				{
					a = vec[i].second.second;
					nowh--;
				}
				else if( vec[i].second.second == a)
				{
					a = vec[i].second.first;
					nowh--;
				}
		}

		cout << a << endl;
	}

	return 0;
}

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

typedef long long ll;
const int N = 4054, mod = 1000000007;

int fact[N], finv[N];

ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init(int n) {
	int i;
	for (*fact = i = 1; i <= n; ++i) fact[i] = (ll)fact[i - 1] * i % mod;
	finv[n] = PowerMod(fact[n], mod - 2);
	for (i = n; i; --i) finv[i - 1] = (ll)finv[i] * i % mod;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k), init(n + k), --k;
	printf("%d\n", (int)PowerMod(2, std::max(n - k - 2, 0), (ll)fact[n + k - 1] * finv[k] % mod * finv[n] % mod * (n - k) % mod));
	return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
// const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k, x, y;
    int ans;
    cin >> n >> k >> x >> y;
    ans = min(n, k) * x + max(0, (n - k)) * y;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#diverta2019_2 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]
mi = a[0]
log = []
for i in a[1:-1]:
    if i >= 0:
        log.append([mi,i])
        mi -= i
    else:
        log.append([ma,i])
        ma -= i
log.append([ma,mi])
print(ma-mi)
for i in range(n-1):
    x,y = log[i]
    print(x,y)


Measured memory_bytes: 68892
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, x = map(int, raw_input().split())
a = map(int, raw_input().split())

ans = 0
if a[0] > x:
    ans = a[0] - x
    a[0] = x
for i in range(N - 1):
    if a[i] + a[i + 1] > x:
        ans += a[i] + a[i + 1] - x
        a[i + 1] = x - a[i]

print ans

Measured memory_bytes: 11560
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b[10000],c,d,e=0,i,x=0,y;
    cin>>a>>c;
    for(i=0;i<a;i++)
    {
        cin>>b[i];
    }
    sort(b,b+a);
    for(i=0;i<c;i++)
    {
        e+=b[i];
    }
    cout<<e<<endl;


}



Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    vector<int>sr(4,0);
    int a;
    for(int i=0; i<6; i++){
        cin >> a;
        a--;
        sr[a]++;
    }
    sort(sr.begin(),sr.end());
    if(sr[0]==1 && sr[1]==1 && sr[2]==2 && sr[3]==2){
        puts("YES");
    }else{
        puts("NO");
    }
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, ans = 1000000001;
  cin >> n;
  vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  rep(i, 1, n)
    ans = min(ans, __gcd(a[0], a[i]));
  
  cout << ans << "\n";
}

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

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

  float avg = (a + b) / 2;
  float rest = (a + b) % 2;
  if (rest == 0) {
    cout << avg << endl;
  } else {
    cout << avg+1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    int a;
    vector<int> ans(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        ans[a - 1] = i + 1;
    }
    for (int i = 0; i < N; i++)
    {
        printf("%d", ans[i]);
        if (i != N - 1)
        {
            printf(" ");
        }
    }
    printf("\n");
    return (0);
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
    n: usize,
    xy: [(f64, f64); n]
    }
    let mut t: Vec<usize> = (0..n).collect();
    let mut ans = 0.0;
    let mut c = 0.0;
    while {
        let mut d= 0.0;
        for i in 0..n - 1 {
            let (x1, y1) = (xy[t[i]].0, xy[t[i]].1);
            let (x2, y2) = (xy[t[i + 1]].0, xy[t[i + 1]].1);
            d += ((x1 - x2).powf(2.0) + (y1 - y2).powf(2.0)).sqrt();
        }
        c += 1.0;
        ans += d;
        t.next_permutation()
    } {}
    ans /= c;
    println!("{}", ans);
}

pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T] where T: Ord {
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }

    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);

    int ab = b-a;
    int ac = c-a;
    int ad = d-a;
    int ae = e-a;
    int bc = c-a;
    int bd = d-b;
    int be = e-b;
    int cd = d-c;
    int ce = e-c;
    int de = e-d;
    
    if(k>=ab&&k>=ac&&k>=ad&&k>=ae&&k>=bc&&k>=bd&&k>=be&&k>=cd&&k>=ce&&k>=de){
        puts("Yay!");
    }else{
        puts(":(");
    }

    return 0;

}

Measured memory_bytes: 128
def we_love_golf():
    K = int(input())
    condition = input()
    condition_list = condition.split()
    A = int(condition_list[0])
    B = int(condition_list[1])
    
    for i in range(A, B+1):
        if i % K == 0:
            print('OK')
            return
    
    print('NG')
    return

we_love_golf()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
const int INF = (int)1e9;

ll a[1001];
int main() {
#ifdef WIN32
	//freopen("input.txt", "rt", stdin);
#endif

	ll n, k; scanf("%lld%lld", &n, &k);
	ll m = n % k;

	printf("%lld\n", min({ n, m, abs(m - k), abs(k - m) }));

	return 0;
}

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

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 M, D; cin >> M >> D;

    i64 cnt = 0;
    i64 ndays = M * D;
    REP(i, ndays) {
        i64 m = i / D + 1;
        i64 d = i % D + 1;
        i64 d1 = d % 10;
        i64 d10 = d / 10;
        if (d1 * d10 == m && d1 >= 2 && d10 >= 2) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int s[100010];
int n,nu,ans,cnt;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&nu);
		if(nu==i)
		{
			if(cnt){cnt=0;continue;}
			ans++;
			cnt=1;		
		}
		else cnt=0;
	}
	cout<<ans<<endl;
	return 0;
}


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

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

class UnionFind
{
    private:
        std::vector<int> parent;  // parent[x]: x の根の番号
                                  //            x が根の場合はその連結成分の大きさ
        std::vector<int> rank;    // rank[x]  : x が属する木の高さ
        std::size_t sz;           // 連結成分の数

    public:
        // x が親の場合、parent[x] = -(その連結成分の大きさ)
        UnionFind( std::size_t n ): parent(n, -1), rank(n, 0), sz(n) {}

        // x が属する集合の親を返し、x を親に直接繋ぎ直す(経路圧縮)
        int find( int x )
        {
            if( parent[x] < 0 ) return x;
            else return parent[x] = find( parent[x] );
        }

        // x が属する集合と y が属する集合を統合する
        bool unite( int x, int y )
        {
            x = find( x );
            y = find( y );
            if( x == y ) return false;

            // 大きい方(x)に小さい方(y)を繋げる
            if( rank[x] < rank[y] ) std::swap( x, y );

            parent[x] += parent[y];  // x に連結している成分の大きさを更新する
            parent[y] = x;           // y を x に繋ぐ
            if( rank[x] == rank[y] ) rank[x]++;
            sz--;

            return true;
        }

        bool same( int x, int y ) { return find(x) == find(y); }
        std::size_t size()        { return sz; }
        std::size_t size( int x ) { return - parent[find(x)]; }
};


int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(M), B(M), C(K), D(K);
    REP(i, M){
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    REP(i, K){
        cin >> C[i] >> D[i];
        --C[i], --D[i];
    }

    UnionFind uni(N);
    vector<int> num_friend(N);
    REP(i, M){
        uni.unite(A[i], B[i]);
        ++num_friend[A[i]], ++num_friend[B[i]];
    }

    vector<int> ans(N);
    REP(i, N) ans[i] = uni.size(i) - num_friend[i] - 1;
    REP(i, K){
        if(uni.same(C[i], D[i])) --ans[C[i]], --ans[D[i]];
    }
    REP(i, N) cout << ans[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3968
#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>;
int main(){ 
   int n;
   cin>>n;
   int x=(n+1000-1)/1000;
    int ans=x*1000-n;
    cout<<ans<<endl;
   /*int a,b,x,y,z,count=0;
  
   cin>>x;
  while(x>=1000)x%=1000;
  if(x>=500)x=1000-x;
  auto answer=x;
  cout<<answer<<endl;*/
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);*/
//        int b = int.Parse(input[2]);
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
        string temp = ReadLine();
        for(int i=0;i<temp.Length;i++){
            if(i%2==0){
                Write(temp[i]);
            }
        }
        WriteLine();
    }
}

Measured memory_bytes: 11360
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
vector<ll> v(100005);
vector<ll> vis(100005, 0); ll c = 0, check = 0;
queue<ll>que;
/*void bfs(ll a, ll src) {
	vis[a] = src;
	que.push(src);
	while (!que.empty()) {
		src = que.front();
		for (ll x = 1; x <= v[src];x++) {
			if (vis[x] == 0) {
				c++;
				vis[x] = src;
				que.push(x);
			}
		}
		que.pop();
	}
}*/
int main() {
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll tmp = 1;
	rep(i, n) {
		if (a[i] <= 1000000000000000000 / tmp) {
			tmp *= a[i];
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << tmp << endl;
}

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

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

    vector<long int> H(N);
    for(int i=0; i<N; i++){
        cin >> H.at(i);
    }

    vector<int> A(M);
    vector<int> B(M);
    for(int i=0; i<M; i++){
        cin >> A.at(i) >> B.at(i);
    }

    vector<int> good(N,1);

    for (int i=0; i<M; i++){
        int a = A.at(i) -1;
        int b = B.at(i) -1;
        long int Ha = H.at(a);
        long int Hb = H.at(b);
        if(Ha < Hb){
            good.at(a) --;
        }
        else if(Ha == Hb){
            good.at(a) --;
            good.at(b) --;
        }
        else{
            good.at(b) --;
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        if (good.at(i) == 1){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5016
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    if A[i+1] == A[i] +1:
        sum += C[A[i]-1]

for i in range(N):
    sum += B[A[i]-1]
    
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[101010],has,d[101010],j;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<i;j++)
			if(a[j]>a[i])
				d[i]=max(d[i],d[j]+1);
		has=max(has,d[i]+1);		
	}
	cout<<has<<"\n";
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    string s;
    cin >> s;
    bool ans;
    int y, m;
    y = stoi(s.substr(0, 4));
    m = stoi(s.substr(5, 2));

    if (y < 2019 or (y == 2019 and m < 5))
        ans = true;
    else
        ans = false;

    print(ans ? "Heisei" : "TBD");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> snuke(n, false);

  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      --a;
      
      snuke[a] = true;
    }
  }
  int ans = 0;
  rep(i, n) {
    // cout << snuke[i] << endl;
    if (snuke[i] == false) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n, s = 0;
	cin >> n;
	vector<int> x(n);
	REP(i, n) {
		cin >> x[i];
		s += x[i];
	}
	int p = s / n;
	int res = 0;
	REP(i, n) {
		res += (x[i] - p) * (x[i] - p);
	}
	p++;
	int tmp = 0;
	REP(i, n) {
		tmp += (x[i] - p) * (x[i] - p);
	}
	chmin(res, tmp);
	put(res);
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int H, W;
    cin >> H >> W;

    Graph<int> As(H, vint(W));
    rep(y, H) {
        rep(x, W) {
            cin >> As[y][x];
        }
    }

    int N = 0;
    vector<std::tuple<int, int, int, int>> tupleList;
    rep(y, H) {
        rep(x, W) {
            if (y != H - 1) {
                if (As[y][x] % 2 == 1) {
                    As[y][x]--;
                    As[y+1][x]++;
                    tupleList.push_back(std::make_tuple(y+1, x+1, y+2, x+1));

                    // cout << y << " " << x << " " << y+1 << " " << x << " ";
                    N++;
                }
            } else if (x != W - 1) {
                if (As[y][x] % 2 == 1) {
                    As[y][x]--;
                    As[y][x+1]++;

                    tupleList.push_back(std::make_tuple(y+1, x+1, y+1, x+2));
                    N++;
                }
            }
        }
    }
    
    cout << N << endl;
    rep(i, N) {
        cout << std::get<0>(tupleList[i]) << " " << std::get<1>(tupleList[i]) << " " << std::get<2>(tupleList[i]) << " " << std::get<3>(tupleList[i]) << endl;
    }
}

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

int main()
{
    int n;
    cin>>n;
    
    int a[n];
    
	for(int i=0;i<n;i++)cin>>a[i];
    
	int f,count=0;
    
	do{
        f=0;
        for(int i=0;i<n;i++)
		{
            if(a[i]%2==0)
			{
                a[i]=a[i]/2;
            }
            else
			{
                f=1;
                break;
            }
        }
        if(f==0)count++;
    }while(f==0);
    cout<<count<<endl;
    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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b) cout << c << '\n';
  else if(b==c) cout << a << '\n';
  else cout << b << '\n';
  return 0;
}

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

int main()
{
    unsigned long long n, x;
    std::cin >> n >> x;
    std::vector<unsigned long long> a(n);
    for(auto &i : a)
        std::cin >> i;
    unsigned long long result = -1ULL;
    for(unsigned long long i = 0; i != n + 1; ++i)
    {
        result =
            std::min(result, std::accumulate(a.begin(), a.end(), 0ULL) + x * i);
        decltype(a) newA(a.size());
        for(std::size_t i = 0; i != a.size(); i++)
        {
            std::size_t target = (i == 0 ? a.size() - 1 : i - 1);
            newA[i] = std::min(a[target], a[i]);
        }
        a = std::move(newA);
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector <vector<int> > people(n, vector<int> (2));
    vector <vector<int> > check(m, vector<int>(2)) ;
    for(int i = 0; i < n; i++){
        cin >> people.at(i).at(0) >> people.at(i).at(1);
    }
    for(int i = 0; i < m; i++){
        cin >> check.at(i).at(0) >> check.at(i).at(1);
    }
    for(int i = 0; i < n; i++){
        int number = 0;
        int len = 1000000007;
        for(int j = 0; j < m; j++){
            if(abs(people.at(i).at(0) - check.at(j).at(0)) + abs(people.at(i).at(1) - check.at(j).at(1)) < len){
                len = abs(people.at(i).at(0) - check.at(j).at(0)) + abs(people.at(i).at(1) - check.at(j).at(1));
                number = j + 1;
            }
        }
        cout << number << endl;
    }
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,n1,n2,h1,h2,m1,m2,money,kyori,cnt;
	scanf("%d",&n1);
	while(n1!=0) {
		scanf("%d %d",&h1,&m1);
		scanf("%d",&n2);
		scanf("%d %d",&h2,&m2);
		money=0;
		if((n1==1 && n2==2)||(n1==2 && n2==1)) {
			money=300;
			kyori=6;
		}
		if((n1==1 && n2==3)||(n1==3 && n2==1)) {
			money=500;
			kyori=13;
		}
		if((n1==1 && n2==4)||(n1==4 && n2==1)) {
			money=600;
			kyori=18;
		}
		if((n1==1 && n2==5)||(n1==5 && n2==1)) {
			money=700;
			kyori=23;
		}
		if((n1==1 && n2==6)||(n1==6 && n2==1)) {
			money=1350;
			kyori=43;
		}
		if((n1==1 && n2==7)||(n1==7 && n2==1)) {
			money=1650;
			kyori=58;
		}
		if((n1==2 && n2==3)||(n1==3 && n2==2)) {
			money=350;
			kyori=7;
		}
		if((n1==2 && n2==4)||(n1==4 && n2==2)) {
			money=450;
			kyori=12;
		}
		if((n1==2 && n2==5)||(n1==5 && n2==2)) {
			money=600;
			kyori=17;
		}
		if((n1==2 && n2==6)||(n1==6 && n2==2)) {
			money=1150;
			kyori=37;
		}
		if((n1==2 && n2==7)||(n1==7 && n2==2)) {
			money=1500;
			kyori=52;
		}
		if((n1==3 && n2==4)||(n1==4 && n2==3)) {
			money=250;
			kyori=5;
		}
		if((n1==3 && n2==5)||(n1==5 && n2==3)) {
			money=400;
			kyori=10;
		}
		if((n1==3 && n2==6)||(n1==6 && n2==3)) {
			money=1000;
			kyori=30;
		}
		if((n1==3 && n2==7)||(n1==7 && n2==3)) {
			money=1350;
			kyori=45;
		}
		if((n1==4 && n2==5)||(n1==5 && n2==4)) {
			money=250;
			kyori=5;
		}
		if((n1==4 && n2==6)||(n1==6 && n2==4)) {
			money=850;
			kyori=25;
		}
		if((n1==4 && n2==7)||(n1==7 && n2==4)) {
			money=1300;
			kyori=40;
		}
		if((n1==5 && n2==6)||(n1==6 && n2==5)) {
			money=600;
			kyori=20;
		}
		if((n1==5 && n2==7)||(n1==7 && n2==5)) {
			money=1150;
			kyori=35;
		}
		
		if((n1==6 && n2==7)||(n1==7 && n2==6)) {
			money=500;
			kyori=15;
		}
		cnt=0;
		if(17<=h1 && h1<=19) {
			if(h1==17) {
				if(30<=m1) {
					cnt++;
				}
			}
			if(h1==18) {
				cnt++;
			}
			if(h1==19) {
				if(m1<=30) {
					cnt++;
				}
			}
		}		
		if(17<=h2 && h2<=19) {
			if(h2==17) {
				if(30<=m2) {
					cnt++;
				}
			}
			if(h2==18) {
				cnt++;
			}
			if(h2==19) {
				if(m2<=30) {
					cnt++;
				}
			}
		}
		////////////////////////
		if(kyori<=40 && cnt!=0) {
			money=money/2;
			if(money%50!=0) {
				for(i=1;i<=100;i++) {
					money++;
					if(money%50==0) {
						break;
					}
				}
			}
			printf("%d\n",money);
		}
		else {
			printf("%d\n",money);
		}
	scanf("%d",&n1);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[100000];
signed main(){
  int n, x;
  scanf("%lld%lld", &n, &x);
  rep(i,n)scanf("%lld", &a[i]);
  int ans = 0;
  sort(a, a+n);
  rep(i,n){
    if(x < a[i])break;
    if(i == n-1 and x != a[i])break;
    ans++;x -= a[i];
  }
  printf("%lld\n", ans);
	return 0;
}








Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);
vector<ll> to[200500];

int main() {  // TODO
  ll N, M;
  cin >> N >> M;
  rep1(M) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<ll> g(N, -1);
  ll top = 0;
  ll gid = 0;
  rep(N) {
    if (g[i] != -1) continue;
    queue<ll> q;
    gid += 1;
    g[i] = gid;
    ll gmem = 1;
    q.push(i);
    while (!q.empty()) {
      ll v = q.front();
      q.pop();
      for (ll f : to[v]) {
        if (g[f] != -1) continue;
        g[f] = gid;
        gmem += 1;
        q.push(f);
      }
    }
    top = max(top, gmem);
  }
  cout << top << endl;

  return 0;
}

Measured memory_bytes: 18476
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
  int x, y;
  cin >> x >> y;
  int p = 0;
  if(x==1){
    p+=300000;
  }else if(x==2){
    p+=200000;
  }else if(x==3){
    p+=100000;
  }
  if(y==1){
    p+=300000;
  }else if(y==2){
    p+=200000;
  }else if(y==3){
    p+=100000;
  }
  if(x==1&&y==1){
    p+=400000;
  }
  printf("%d\n", p);

}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int X;

    cin >> X;

    ll ans = 0;

    for(int i=1;i<=1000;i++){
        for(int j=2;j<=1000;j++){
            if(X>=pow(i,j)&&pow(i,j)>ans){
                ans = pow(i,j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
saiaku=0

n=int(input())
b_list=input().split(' ')

for bl in range(len(b_list)):
    b_list[bl]=int(b_list[bl])
#print(b_list)

junretu=[]
nagasa=len(b_list)

sakasa=[]
#print(b_list[1:])
for kaisu in range(nagasa):
    maxn=0
    swit=0
    for i in range(nagasa):
        if b_list[i]==i+1:
            maxn=i #i>=0
            swit=1
            #print(maxn)
    sakasa.append(maxn+1)
    b_list=b_list[:maxn]+b_list[maxn+1:]
    nagasa=len(b_list)
    if swit==0:
        saiaku=1
    #print(b_list)
#print(sakasa)
if saiaku==0:
    shin=[]
    for sks in range(len(sakasa)):
        print(sakasa[len(sakasa)-sks-1])
    """
    for sks in range(len(sakasa)):
        shin.append(sakasa[len(sakasa)-sks-1])
    print(shin)
    """
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

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

    int passed = 0;
    int bpassed = 0;
    for (int i = 0; s[i]; ++i) {
        if (s[i] == 'a') {
            if (passed < a + b) {
                cout << "Yes" << endl;
                passed++;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (passed < a + b && bpassed < b) {
                cout << "Yes" << endl;
                passed++;
                bpassed++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
using namespace std;

int main(){

  map < string, int > str;

  int j=0,a=0,max=0;
  string n,tmp,z,tmp2;

  getline(cin,n);

  for(int i=0; i<n.size(); i++){
    if(n[i]==' '){

      z = n.substr(j,i-j);
      str[z]++;

      if(a <= str[z]){
	a = str[z];
	tmp = z;
      }

      if(tmp2.size() < z.size() ){
	tmp2 = z;
      }

      j=i+1;

    } 

  }

      z = n.substr(j);
      str[z]++;

      if(a <= str[z]){
	a = str[z];
	tmp = z;
      }

      if(tmp2.size() < z.size() ){
	tmp2 = z;
      }   
  cout << tmp << ' ' << tmp2 <<  endl;
}

Measured memory_bytes: 1192
n, q = gets.chomp.split.map(&:to_i)
h = {}
gets.chomp.split.map(&:to_i).each{|x| h[x] = true}
max = h.keys.max

q.times{
    d = gets.to_i
    (d - 1).downto(0){|i|
        m, found = 0, false
        while d * m + i <= max
            if h[d * m + i]
                puts i
                found = true
                break
            end
            m += 1
        end
        break if found
    }
}


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

long long l, a, b, MOD;

struct Matrix {
    vector<vector<long long> > val;
    Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
    void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); }
    int size() const { return (int)val.size(); }
    inline vector<long long>& operator [] (int i) { return val[i]; }
};

Matrix operator * (Matrix A, Matrix B) {
    Matrix R((int)A.size(), (int)B[0].size());
    for (int i = 0; i < (int)A.size(); ++i) {
        for (int j = 0; j < (int)B[0].size(); ++j) {
            for (int k = 0; k < (int)B.size(); ++k) {
                R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD;
            }
        }
    }
    return R;
}

Matrix pow(Matrix A, long long n) {
    Matrix R((int)A.size(), (int)A.size());
    for (int i = 0; i < (int)A.size(); ++i) R[i][i] = 1; // 正方行列
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll kyu(int n) {
    ll res = 0;
    for (int i = 0; i < n; i++) res = res * 10 + 9;
    return res;
}

Matrix mat(int n) {
    Matrix res(3,3);
   	res[0][0] = modpow(10, n);
    res[0][1] = 0;
    res[0][2] = 0;
    res[1][0] = 1;
    res[1][1] = 1;
    res[1][2] = 0;
    res[2][0] = 0;
    res[2][1] = b % MOD;
    res[2][2] = 1;
    return res;
}

int main() {
    cin >> l >> a >> b >> MOD;
    Matrix data(1,3);
    data[0][0] = 0;
    data[0][1] = a % MOD;
    data[0][2] = 1;
    for (int i = 1; i <= 18; i++) {
        ll from = kyu(i-1), to = kyu(i);
        from = ( from - a < 0 ? -1 : (from - a) / b ); 
        to = ( to - a < 0 ? -1 : (to - a) / b );
        if (from >= l - 1) break;
        if (to < 0) continue;
        if (to >= l - 1) to = l - 1;
        ll count = to - from;
        data = data * pow(mat(i), count);
    }
    cout << data[0][0] % MOD << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using II = pair<int, int>;
using Graph = vector<vector<II>>;

void	dfs(const Graph &graph, int v, int par, vector<int> &color, int N)
{
	for (auto pr : graph.at(v)) {
		int	child = pr.second;
		if (child == par)
			continue;
		color.at(child) = (color.at(v) + pr.first) % 2;
		dfs(graph, child, v, color, N);
	}
}

int	main()
{
	int	N;
	int	u, v, w;
	cin >> N;
	Graph	graph(N);
	for (int i = 0; i < N - 1; ++i) {
		cin >> u >> v >> w;
		--u; --v;
		graph.at(u).push_back(make_pair(w, v));
		graph.at(v).push_back(make_pair(w, u));
	}
	vector<int>	color(N);
	dfs(graph, 0, -1, color, N);
	for (int i = 0; i < N; ++i)
		cout << color.at(i) << endl;
}


Measured memory_bytes: 10496