akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int t = ri();
	int q = ri();
	vi a(n), s(n);
	FOR(i,n) a[i] = s[i] = ri();
	sort(all(s));
	
	int res = INF;
	FOR(i,n) {
		vvi v;
		int l = 0;
		FOR(j,n) {
			if (a[j] < s[i]) {
				if (l < j-1) v.push_back(vi(a.begin()+l,a.begin()+j));
				l = j+1;
			}
		}
		if (l != n) v.push_back(vi(a.begin()+l,a.begin()+n));
		vi p;
		for (auto& j : v) {
			sort(all(j));
			FOR(k,j.size()-t+1) p.push_back(j[k]);
		}
		if (p.size() >= (size_t)q) {
			sort(all(p));
			res = min(res,p[q-1]-s[i]);
		}
	}
	cout << res << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n - 1; i++){
    cout << a[i].second << " ";
  }
  cout << a[n - 1].second << endl;
}

Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  vector< vector <int> > q(26);

  for (int i = 0; i < s.size(); i++) {
    q[s[i] - 'a'].push_back(i);
  }

  for (int i = 0; i < t.size(); i++) {
    if (q[t[i] - 'a'].empty()) {
      cout << "-1" << endl;
      return 0;
    }
  }

  // sの中でどこを探しているかを記録
  int position = 0;
  // 何回連結を行ったか
  int loopNum = 0;

  for (int i = 0; i < t.size(); i++) {
    // qから探す
    auto pos = lower_bound(q[t[i] - 'a'].begin(), q[t[i] - 'a'].end(), position);
    if (pos == q[t[i] - 'a'].end()) {
      pos = q[t[i] - 'a'].begin();
      loopNum++;
    }
    position = *pos + 1;
  }

  cout << loopNum * s.size() + position << endl;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
 
const ll oo=1e18;
const int MOD=1000000007;
const int INF=1000000000;
const ld EPS=0.000000001;
 
int dp[100005],h[100005],n,k=2;
 
signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,0x3f3f,sizeof dp);
    dp[1]=0;
    h[0]=0;
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>h[i];
    for(int i=2;i<=n;++i) {
        for(int j=1;j<=min(k,i);++j) {
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
Scanf.scanf "%d %d %d" (fun w h n ->
    let rec loop i x0 y0 x1 y1 =
        if i = n then (x1 - x0) * (y1 - y0) else
            let x0, y0, x1, y1 = Scanf.scanf " %d %d %d" (fun x y a ->
                match a with
                | 1 -> if x > x1 then x, y0, x, y1 else max x x0, y0, x1,       y1
                | 2 -> if x < x0 then x, y0, x, y1 else x0,       y0, min x x1, y1
                | 3 -> if y > y1 then x0, y, x1, y else x0, max y y0, x1,       y1
                | 4 -> if y < y0 then x0, y, x1, y else x0,       y0, x1, min y y1
                | _ -> failwith "??"
            )
            in
            loop (i + 1) x0 y0 x1 y1
    in
    loop 0 0 0 w h |> Printf.printf "%d\n"
)

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr ll mod = 1e9 + 7;
    int n, m; cin >> n >> m;
    vector<int> s(n), t(m);
    REP(i, n) cin >> s[i];
    REP(i, m) cin >> t[i];

    auto dp = make_v(n+1, m+1, 0LL);
    REP(i, n+1) dp[i][0] = 1;
    REP(i, m+1) dp[0][i] = 1;
    FOR(i, 1, n+1)FOR(j, 1, m+1){
        if(s[i-1] == t[j-1]){
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        } else {
            ll tmp = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            while(tmp < 0) tmp += mod;

            dp[i][j] = tmp % mod;
        }
    }
    
    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <iostream>

using namespace std;

int main()
{
  int H=0;
  int W=0;
  int i;
  int j;
  
  while(1)
  {
    cin >> H >> W;
    
    if(H==0 && W==0)
      goto EXIT;
    
   /* for(i=0;i<H;i++)
    {
      switch(a)
      {
      case 0:check=0; a=1; break;
      case 1:check=1; a=0; break;
      }
      for(j=0;j<W;j++)
      {
        switch(check)
        {
        case 0:cout << "#"; check=1; break;
        case 1:cout << "."; check=0; break;
        }
      }
      cout <<"\n";
    }
  
  cout << "\n";*/
  
  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      if(i%2==0 && j%2==0)
        cout << "#";
      if(i%2==0 && j%2==1)
        cout << ".";
      if(i%2==1 && j%2==0)
        cout << ".";
      if(i%2==1 && j%2==1)
        cout << "#";
    }
    cout <<"\n";
  }
   cout << "\n";
   
  }
  EXIT:;
}

Measured memory_bytes: 1120
# coding:utf-8

import math
import re

def main(params):
    total = 0
    a = []
    b = []
    for i in range(len(params)):
        s = params[i]
        total += s.count("AB")
        if s[0] == "B":
            b.append(i)
        if s[-1:] == "A":
            a.append(i)
    if min(len(a),len(b)) > 0 and len(a) == len(b):
        total += min(len(a), len(b))
        chk = True
        for i in a:
            if not i in b:
                chk = False
        if chk == True:
            total -= 1
    else:
        total += min(len(a),len(b))
    print total

if __name__ == "__main__":
    n = int(raw_input())
    #cnt = 1 # TODO: edit here
    params = []
    for i in range(n):
        param = raw_input()
        params.append(param)
    main(params)



Measured memory_bytes: 3692
import math

a, b, h, m = map(int, input().split())

theta_a = (60*h+m)/720*2*math.pi
theta_b = m/60*2*math.pi
theta_a_b = abs(theta_a-theta_b)

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(theta_a_b))
print(ans)

Measured memory_bytes: 9380
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

map<int, int> memo[10000001];

ll getCountDivisors(ll x) {
    //xの正の約数の個数を返す
    ll store_x = x;
    map<int, int> m;
    for(int i = 2; i * i <= x; ++i) {
        if(x % i == 0) {
            memo[store_x][i]++;
            x /= i;
            for(auto itr = memo[x].begin(); itr != memo[x].end(); ++itr) {
                memo[store_x][itr -> first] += itr -> second;
            }
            x = 0;
        }
    }
    if(x > 1) {
        memo[store_x][x]++;
    }
    ll ret = 1;
    for(auto itr = memo[store_x].begin(); itr != memo[store_x].end(); ++itr) {
        ret *= (itr -> second + 1);
    }
    return ret;
}

int main() {
    ll n; cin >> n;
    ll ans = 0;
    for(ll j = 1; j <= n; ++j) {
        //初項: j, 末項: (n / j) * j
        ll m = (n / j);
        ans += j * m * (m + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 472360
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n, k;
    cin >> k >> n;
    if (k*500 < n) cout << "No";
    else cout << "Yes";
    cout << '\n';
    

    return 0;
}



Measured memory_bytes: 256
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int a , b , c , x , y;
int answ;

int main(){
    cin>>a>>b>>c>>x>>y;
    int t = min(x , y);
    int k = min(a + b , 2 * c);
    answ += k * t;
    if(x > y){
        t = x - y;
        k = min(a , 2 * c);
        answ += k * t;
    }
    else{
        t = y - x;
        k = min(b , 2 * c);
        answ += k * t;
    }
    cout<<answ<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>

#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

using namespace std;

const int MAX_A = 100;
int a[3] ={1,10,9};

int task(){
  int x,y = 0;
  std::sort(a,a+SIZE_OF_ARRAY(a));
  x = a[1]-a[0];
  y = a[2]-a[1];
  cout << x+y;
  return 0;
}

int main(){
  for(int i=0;i<3;i++){
    cin >> a[i];
  }
  task();
  return 0;
}


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


  int n ,a;


  

  while( cin >> n ){




  a = n % 39;


    if(  a > 0   &&  a < 10) cout << "3C0"  <<  a  <<endl;
    else if( a >= 10 ) cout << "3C"  <<  a  <<endl;
    else if( a == 0) cout << "3C39"  <<endl;

  }

  return 0 ;

}

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const ll mod = 1e9 + 7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


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

    modint x = 2;
    x = x.pow(n);
    modint y = 1;
    for (int i = n; i >= n - a + 1; --i) {
        y *= i;
    }
    modint yb = 1;
    for (int i = 1; i <= a; ++i) {
        yb *= i;
    }
    y *= yb.pow(mod-2);
    modint z = 1;
    for (int i = n; i >= n - b + 1; --i) {
        z *= i;
    }
    modint zb = 1;
    for (int i = 1; i <= b; ++i) {
        zb *= i;
    }
    z *= zb.pow(mod-2);
    modint ans = x - y - z - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string n;
  cin >> n;
  string ans;
  for(int i=0;i<n.length();i++){
    if(n.substr(i,1)=="1"){
      ans += "9";
    }else{
      ans += "1";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
N, M, R = map(int, input().split())
r=[int(x) for x in input().split()]
r=[i-1 for i in r]
d=[[float("inf")]*N for _ in range(N)]
for i in range(N):
	d[i][i]=0
for _ in range(M):
	a, b, c = map(int, input().split())
	a-=1
	b-=1
	d[a][b]=min(d[a][b], c)
	d[b][a]=min(d[b][a], c)

#d[i][j]は2頂点間i, j間の移動コストを格納, Vは頂点数
def warshall_floyd(d, V): 
	for k in range(V):
		for i in range(V):
			for j in range(V):
				d[i][j] = min(d[i][j], d[i][k] + d[k][j])

	return d #d[i][j]に頂点i, j間の最短距離を格納

d=warshall_floyd(d, N)
ans=float("inf")
for l in list(itertools.permutations(r)):
	temp=sum([d[l[i]][l[i+1]] for i in range(R-1)])
	ans=min(ans, temp)
print(ans)

Measured memory_bytes: 81532
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int[] h = new int[n];
        float answer = -1;
        int index = -1;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            float temp = (float) (t - (h[i] * 0.006));
            if (answer == -1) {
                answer = Math.abs(a - temp);
                index = i + 1;
                continue;
            }
            if (Math.abs(a - temp) < answer) {
                answer = Math.abs(a - temp);
                index = i + 1;
            }
        }

        System.out.println(index);
    }
}


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

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

    ll n, m;
    cin >> n >> m;

    vector<ll> a(n);
    priority_queue<ll> pq;
    rep(i, n){
        cin >> a[i];
        pq.push(a[i]);
    }


    rep(_, m){
        ll t = pq.top();
        pq.pop();
        t /= 2;
        pq.push(t);
    }

    ll res = 0;
    rep(i, n){
        res += pq.top();
        pq.pop();
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5040
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;
char s[12];

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if ((a + b) == (c + d)) cout << "Balanced" << endl;
	if ((a + b) > (c + d)) cout << "Left" << endl;
	if ((a + b) < (c + d)) cout << "Right" << endl;

	return 0;
}

Measured memory_bytes: 256
n,t= map(int, input().split())
l=[]
for i in range(n):
        l.append(list(map(int, input().split())))
ans = 10**9
for i in range(n):
        cost = l[i][0]
        time = l[i][1]
        if time <= t and cost < ans:
                ans=cost
if ans == 10**9:
        print("TLE")
else:
        print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;

int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
    int x;
     cin>>x;
  cout<<(x/500)*1000+((x%500)/5)*5;
}



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

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

    int n;
    cin >> n;

    int two = 0, four = 0, other = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(!(a % 4)) four++;
        else if(!(a % 2)) two++;
        else other++;
    }

    /*four += (two / 2);
    two %= 2;
    other += two;*/
    
    cout << (four+ !two  >= other ? "Yes" : "No") << endl;
    

    return 0;
}


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

class A7{
  struct Tree{
    public int id;
    public int parent;
    public int depth;
    public int[] childlen;
    public string type;
  }

  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    var tree = new Tree[n];

    for(int i = 0;i < n;i++) tree[i].parent = -1;
    for(int i = 0;i < n;i++){
      int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      //int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      var id = input[0];
      tree[id].id = id;

      var k = input[1];
      if(k == 0) tree[id].type = "leaf";
      else tree[id].type = "internal node";
      tree[id].childlen = new int[k];
      for(int j = 0;j < k;j++){
        tree[id].childlen[j] = input[2 + j];
        tree[input[2 + j]].parent = id;
      }
    }
    for(int i = 0;i < n;i++){
      if(tree[i].parent == -1){
        tree[i].type = "root";
        Depth(tree,i,0);
        break;
      }
    }
    for(int i = 0;i < n;i++){
      Console.Write("node ");
      Console.Write(tree[i].id);
      Console.Write(": parent = ");
      Console.Write(tree[i].parent);
      Console.Write(", depth = ");
      Console.Write(tree[i].depth);
      Console.Write(", ");
      Console.Write(tree[i].type);
      Console.Write(", [");
      Console.Write(string.Join(", ",Array.ConvertAll(tree[i].childlen, (e) => e.ToString())));
      Console.WriteLine("]");
    }
  }

  static void Depth(Tree[] tree,int id,int depth){
    tree[id].depth = depth;
    for(int i = 0;i < tree[id].childlen.Length;i++)
      Depth(tree,tree[id].childlen[i],depth + 1);
    }
}


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

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

  vector<int> a(N);
  for(auto& aa: a){
    cin >> aa;
  }

  // taro lose: K < a[0], 0 <= K - a[i] - a[j] < a[0] for any i for some j
  // jiro lose: 0 <= K - a[i] < a[0],
  // dp[i] := win
  // dp[0] = false
  // dp[i] = true if dp[i - a[j]] == false for some j
  vector<bool> dp(K + 1, false);
  dp[0] = false;
  for(int k = 1; k <= K; k++){
    for(int i = 0; i < N; i++){
      if(k - a[i] >= 0 && !dp[k - a[i]]){
        dp[k] = true;
      }
    }
  }

  if(dp[K]){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }

}


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

int main(){
     int W,H,x,y,r;

     cin >> W >> H >> x >> y >> r;

     if((x+r>W || y+r>H) || (x-r<0 || y-r<0)){
          cout << "No" << endl;
     }
     else{
          cout << "Yes" << endl;
     }

     return 0; 
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector<long long> a(n);
    bool flag = false;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] == 0)
            flag = true;
    }
    if(flag)
        cout << "0";
    else
    {
        long long product = 1;
        for(int i = 0; i < n; i++)
        {
            if(a[i] > (long long)1e18 / product)
            {
                cout << "-1";
                return 0;
            }
            product *= a[i];
        }
        cout << product;
    }

    return 0;
}


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

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

    int cnt = 0;
    while (b <= a) {
        cnt++;
        b *= 2;
    }
    while (c <= b) {
        cnt++;
        c *= 2;
    }

    if (cnt <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3500
from collections import Counter

N = int(input())
a = [int(input()) for _ in range(N)]

def solve(n,a):
  d = Counter(a)
  if len(d) == 1:
    return a
  d_lst = list(sorted(d.keys()))
  first = d_lst[-1]
  second = d_lst[-2]
  if d[first] != 1:
    return [first]*n
  else: # first は一つだけ
    return [second if a[i] == first else first for i in range(n)]

print(*solve(N,a),sep="\n")


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

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

	map<int,ll> m;
	vector<int> balls(n);

	for(int i = 0; i < n; i++) {
		scanf("%d",&balls[i]);
		m[balls[i]]++;
	}

	ll total = 0;
	for(auto it = m.begin(); it != m.end(); it++) {
		total += (it->second*(it->second-1))/2;
	}

	for(int i = 0; i < n; i++) {
		int balls_here = m[balls[i]];
		cout << total-balls_here+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 11392
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int arr[2][101];
int dp[2][101];

int solve(int i,int j)
{
    if(i>1 || j>=n)
        return 0;
    if(i==1 && j==n-1)
        return arr[i][j];
    int &ret=dp[i][j];
    if(ret!=-1)
        return ret;
    ret=0;
    return ret=max(arr[i][j]+solve(i,j+1),arr[i][j]+solve(i+1,j));
}

int main()
{

    scanf("%d",&n);
    for(int i=0;i<2;i++)
        for(int j=0;j<n;j++)
            scanf("%d",&arr[i][j]);
    memset(dp,-1,sizeof(dp));
    printf("%d",solve(0,0));
    return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    var ans = ""
    next().forEach {
        when(it) {
            '0' -> ans += it
            '1' -> ans += it
            else -> ans = ans.dropLast(1)
        }
    }
    println(ans)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31920
#include <stdio.h>

int main( void ) {
	double w;

	while ( scanf( "%lf", &w ) != EOF )
		puts( w <= 48.0 ? "light fly" : w <= 51.0 ? "fly" : w <= 54.0 ? "bantam" : w <= 57.0 ? "feather" : w <= 60.0 ? "light" : w <= 64.0 ? "light welter" : w <= 69.0 ? "welter" : w <= 75.0 ? "light middle" : w <= 81.0 ? "middle" : w <= 91.0 ? "light heavy" : "heavy" );

	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  ans=ans+(n/100);
  n=n%100;
  ans=ans+(n/10);
  n=n%10;
  ans=ans+n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from datetime import datetime as dt
s = input()
s = dt.strptime(s, '%Y/%m/%d')
cm = dt.strptime("2019/4/30", '%Y/%m/%d')
# print((s-cm).days)
if (s-cm).days > 0:
    print("TBD")
else:
    print("Heisei")


Measured memory_bytes: 4592
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll n=in();
    vector<ll>h(n);REP(i,n)h[i]=in();
    for(ll i=n-1;i>=1;--i){
        ll def=h[i-1]-h[i];
        if(def>1){
            cout<<"No"<<endl;
            return 0;
        }else if(def==1){
            --h[i-1];
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
n=int(input())
a=[]
for i in range(n):
    a.append([int(s) for s in input().split()])
x=a[0]
for i in range(1,n):
    #print(max(x[1],x[2])+a[i][0])
    x=[max(x[1],x[2])+a[i][0],max(x[0],x[2])+a[i][1],max(x[0],x[1])+a[i][2]]
    #print(x)
print(max(x))    
    
        

Measured memory_bytes: 28532
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int h, n, a, num = 0;
	cin >> h >> n;
	rep(i, n) {
		cin >> a;
		num = num + a;
	}
	if (h > num)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		if (500*K >= X) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextInt()<1200?"ABC":"ARC");

    }



}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25324
def CountTimesforT(N, T):
    t = T
    count = 0
    while N % t == 0:
        count += 1
        N //= t
        t *= T
    while N % T == 0:
        N //= T
    return [count, N]

N = int(input())
M = int(pow(N, 0.5)) + 2
ans = 0
if N != 1:
    for i in range(2, M):
        if N % i == 0:
            l = CountTimesforT(N, i)
            N = l[1]
            ans += l[0]
    if N != 1:
        ans += 1
print(ans)

Measured memory_bytes: 9488
#include <iostream>
using namespace std;
int main(void){
    
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r ;
    
    if((x-r)<0 || (y-r)<0) cout << "No" << endl;
    else if((x+r)>W || (y+r)>H) cout << "No" << endl;
    else cout << "Yes" << endl;
    
}



Measured memory_bytes: 3100
#include <cstdio>
#include <queue>

class processTime {
public:
  int time;
  char name[12];
}; 

int n;
int q;
std::queue<processTime> processQueue;

void solve() {
  int time = 0;

  while (!processQueue.empty()) {
    processTime pt = processQueue.front(); processQueue.pop();
    if (pt.time <= q) {
      time += pt.time;
      printf("%s %d\n", pt.name, time);
    } else {
      time += q;
      pt.time -= q;
      processQueue.push(pt);
    }
  }
}

int main() {
  scanf("%d %d", &n, &q);
  for (int i=0; i<n; i++) {
    processTime pt;
    scanf("%s", pt.name);
    scanf("%d", &(pt.time));
    processQueue.push(pt);
  }

  solve();
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int n;
vector<ll> memo;

ll dp(int now, const vvll &a) {
  //cout << now << endl;
  if(memo[now] != -LINF) {
    return memo[now];
  }

  ll tmp = 0;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      if(((now>>i)&1) && ((now>>j)&1)) {
        tmp += a[i][j];
      }
    }
  }
  ll res = tmp;
  
  for(int t=(now-1)&now;t>0;t=(t-1)&now) {
    res = max(res, dp(t, a) + dp(now^t, a));
  }

  return memo[now] = res;

}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n;
  vvll a(n, vll(n));
  for(int i=0;i<n;++i) {
    for(int j=0;j<n;++j) {
      cin >> a[i][j];
    }
  }

  memo.resize(1<<n, -LINF);

  cout << dp((1<<n)-1, a) << endl;

  //printv(memo);


}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;
static int c[N + 1][N + 1] = {};

static int lcs(string& X, string& Y) {
  const size_t m(X.size());
  const size_t n(Y.size());
  X = ' ' + X;
  Y = ' ' + Y;

  int lcs = 0;
  
  for (size_t i = 1; i <= m; i++) {
    for (size_t j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      lcs = max(lcs, c[i][j]);
    }
  }
  return lcs;
}

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

  string X, Y;
  for (int i = 0; i < n; i++) {
    cin >> X;
    cin >> Y;
    cout << lcs(X, Y) << endl;
  }
 
  return 0;
}



Measured memory_bytes: 7044
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
char s1[10000000];
char s2[10000000];
char s3[10000000];
int main()
{
    ll test,n,i,j,k,l,m;
    cin>>s1>>s2;
    cin>>m>>n;
    cin>>s3;
    if(strcmp(s1,s3)==0)
    {
        cout<<m-1<<" "<<n;
    }
    else cout<<m<<" "<<n-1;
    return 0;
}


Measured memory_bytes: 4352
// Amsal Shoma Ro Gaedan Ye Amal Pasandidas !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 998244353;
const int N = 3e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}
ll dp[N][N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a,b, c, d;
	cin >> a >> b >> c >> d;

	dp[a][b] = 1;
	for(int i = a + 1; i <= c; i++){
		for(int j = b; j <= d; j++){
			dp[i][j] = mul(dp[i][j - 1] + dp[i - 1][j - 1], i - 1);
		}
		for(int j = b; j <= d; j++){
			dp[i][j] += mul(dp[i - 1][j], j);
			dp[i][j] %= Mod;
		}
	}
	//cout << dp[1][2] << '\n';
	//cout << dp[2][2] << '\n';
	ll ans = 0;
	for(int mx = b; mx <= d; mx ++){
		ll z = 1;
		for(int i = 0; i < d - mx; i++) z = mul(z, c);
		ans += mul(dp[c][mx], z);
		ans %= Mod;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 74064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(b%a==0)
	{
		printf("%d",b+a);
	}
	else
	{
		printf("%d",b-a);
	}
	return 0;
}

Measured memory_bytes: 256
def examA():
    X, Y = LI()
    ans = X + Y//2
    print(ans)
    return

def examB():
    N = I()
    T, A = LI()
    H = LI()
    cur = 10**9; ans = 0
    for i in range(N):
        now = abs(A - (T - H[i]*0.006))
        if cur>now:
            cur = now
            ans = i
    print(ans+1)
    return

def examC():
    N, M = LI()
    PY = [[]for _ in range(M)]
    d = defaultdict(int)
    ans = [[]for _ in range(M)]
    for i in range(M):
        PY[i] = LI()
        PY[i].append(i)
    PY.sort(key=lambda x:x[1])
    for p,y,s in PY:
        d[p] +=1
        cur = str(p).zfill(6) + str(d[p]).zfill(6)
        ans[s] = cur
    for v in ans:
        print(v)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 47472
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.000000001
#define ld long double
#define inf 5e18
#define N 2000005
#define K 17


int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a * b) / gcd(a , b);
}
int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int k;
    cin >> k;
    cout << lcm(360,k) / k;
    return 0;
    
}   

Measured memory_bytes: 3652
import Control.Applicative

import Control.Monad
    (replicateM)

import Data.List
    (transpose)

type Vector = [Int]

type Matrix = [Vector]

type Problem = (Matrix, Matrix)

type Result = Matrix

multiply :: Vector -> Vector -> Int

multiply matrix1 matrix2
    = sum $ zipWith (*) matrix1 matrix2

solve :: Problem -> Result

solve (matrix1, matrix2)
    = [[multiply vector1 vector2 | vector2 <- matrix2t] | vector1 <- matrix1] where
        matrix2t = transpose matrix2

output :: Result -> String

output matrix
    = init.concat $ [outputVector vector ++ "\n" | vector <- matrix]

outputVector :: Vector -> String

outputVector vector
    = init.concat $ [show x ++ " " | x <- vector]

input :: IO Problem

input
    = do
        [n, m, _] <- map read.words <$> getLine
        matrix1 <- inputMatrix n
        matrix2 <- inputMatrix m
        return (matrix1, matrix2)

inputMatrix :: Int -> IO Matrix

inputMatrix n
    = map (map read.words) <$> replicateM n getLine

main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 12300
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    set<int> s;
    REP(i,3) {
        int x;
        cin >> x;
        s.emplace(x);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
1 7 6 4
*/
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d)
		cout<<"Right"<<endl;
	else if(a+b>c+d)
		cout<<"Left"<<endl;
	else 
		cout<<"Balanced\n";
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.rank=[0]*n
        self.size=[1]*n
        self.Ecnt=[0]*n
    def root(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.root(self.par[x])
            return self.par[x]
    def union(self,x,y):
        px=self.root(x); py=self.root(y)
        if px!=py:
            if self.rank[px]==self.rank[py]:
                self.rank[px]+=1
            elif self.rank[px]<self.rank[py]:
                px,py=py,px
            self.par[py]=px
            self.size[px]+=self.size[py]
            self.Ecnt[px]+=self.Ecnt[py]+1
        else:
            self.Ecnt[px]+=1
    def same_check(self,x,y):
        return self.root(x)==self.root(y)

n,h,w=map(int,input().split())
RCA=[]
for _ in range(n):
    r,c,a=map(int,input().split())
    r-=1
    c+=h-1
    RCA.append((r,c,a))
RCA.sort(lambda x:x[2],reverse=True)
uf=UnionFind(h+w)
ans=0
for r,c,a in RCA:
    if uf.same_check(r,c):
        if uf.size[uf.par[r]]>uf.Ecnt[uf.par[r]]:
            uf.union(r,c)
            ans+=a
    else:
        if (uf.size[uf.par[r]]+uf.size[uf.par[c]])>(uf.Ecnt[uf.par[r]]+uf.Ecnt[uf.par[c]]):
            uf.union(r,c)
            ans+=a
print(ans)

Measured memory_bytes: 107640
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    int q;std::cin>>q;
    int L=1,R=n;
    while(q--){
        int l,r;std::cin>>l>>r;
        if(L<l)L=l;
        if(r<R)R=r;
    }
    std::cout<<std::max(0,R-L+1)<<'\n';
}


Measured memory_bytes: 256
<?php
$inputSeconds = fgets(STDIN);
echo timeConversion($inputSeconds), PHP_EOL;

function timeConversion($inputSeconds){
    $hours = floor($inputSeconds / (60 * 60));
    $minutes = floor(($inputSeconds / 60) % 60);
    $seconds = $inputSeconds % 60;
    return sprintf("%d:%d:%d", $hours, $minutes, $seconds);
}

Measured memory_bytes: 15240
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll r, g, b;
  cin >> r >> g >> b;

  if((10*g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


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

typedef long long ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    int turn=0;
    int ans=0;
    for(auto ch:s){
        if (ch=='p') {
            if (turn==0) turn++,ans--;
            else turn--;
        }else {
            if (turn==0) turn++;
            else turn--,ans++;
        }
//        cout<<turn<<" "<<ans<<'\n';
    }
    cout<<ans;
}


Measured memory_bytes: 512
N, A, B = gets.split.map(&:to_i)
H = N.times.map { gets.to_i }

def ok?(count)
  b_damage = B * count
  diff = A - B
  rest_count = count
  H.each do |h|
    rest_h = h - b_damage
    next if rest_h <= 0
    c = (rest_h + diff - 1) / diff
    if c > rest_count
      return false
    end
    rest_count -= c
  end
  true
end

left = 1
right = H.max
ans = 1 << 60
while left <= right
  mid = (left + right) / 2
  if ok?(mid)
    right = mid - 1
    ans = mid if mid < ans
  else
    left = mid + 1
  end
end
puts ans

Measured memory_bytes: 3068
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h , w , x = 1e10;
    cin >> h >> w;
    if ( w % 3 == 0 ) x = min( x , 0ll );
    else x = min( x , h );
    if ( h % 3 == 0 ) x = min( x , 0ll );
    else x = min( x , w );
    for ( int i = 1 ; i < w ; i++ ) {
        ll a = i * h , b , c;
        if ( h % 2 == 1 ) {
            b = ( h / 2 ) * ( w - i );
            c = b + w - i;
        } else {
            b = ( h / 2 ) * ( w - i );
            c = b;
        }
        x = min( x , max( { a , b , c } ) - min( { a , b , c } ) );
    }
    for ( int i = 1 ; i < h ; i++ ) {
        ll a = i * w , b , c;
        if ( w % 2 == 1 ) {
            b = ( w / 2 ) * ( h - i );
            c = b + h - i;
        } else {
            b = ( w / 2 ) * ( h - i );
            c = b;
        }
        x = min( x , max( { a , b , c } ) - min( { a , b , c } ) );
    }
    cout << x;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;
long long INF = 1000000009;
int main()
{
	int n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
	}
	double sum = 0;
	for (int i = 0; i < n; i++) {
		if (u[i] == "JPY") {
			sum += x[i];
		}
		else {
			sum += x[i] * 380000.0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 998244353
ll n,a[300],dp[301][90000],ans,sum,s,b,two[301];
vector<ll> v[301];
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    two[0]=1;
    for(int i=1;i<=n;i++){
        two[i]=2*two[i-1];
        two[i]%=mod;
    }
    dp[0][0]=1;
    v[0].push_back(0);
    for(int i=0;i<n;i++){
        for(int j=i;j>=0;j--){
            for(int k=0,s=v[j].size();k<s;k++){
                if(dp[j+1][v[j][k]+a[i]]==0){
                    v[j+1].push_back(v[j][k]+a[i]);
                }
                dp[j+1][v[j][k]+a[i]]+=dp[j][v[j][k]];
                dp[j+1][v[j][k]+a[i]]%=mod;
            }
        }
    }
    ans=1;
    for(int i=0;i<n;i++){
        ans*=3;
        ans%=mod;
    }
    for(int i=1;i<=n;i++){
        for(int j=sum/2+sum%2;j<=sum;j++){
            b+=dp[i][j]*two[n-i];
            b%=mod;
        }
    }
    b*=3;
    b%=mod;
    ans+=mod-b;
    ans%=mod;
    if(sum%2==0){
        b=0;
        for(int i=1;i<=n;i++){
            b+=dp[i][sum/2];
        }
        ans+=b*3;
        ans%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 247132
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();
		int X = nextInt();

		long ans = 0;
		for(int i=0;i<=A;i++){
			for(int k=0;k<=B;k++){
				for(int n=0;n<=C;n++){
					if(500*i+100*k+50*n==X){
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main() {
  ll n,m;
  cin >> n >> m;
  map<ll,ll> a;
  for(ll i=0;i<m;i++) {
    ll x,y;
    cin >> x >> y;
    a[x]++;
    a[y]++;
  }
  for(auto p:a) {
    if(p.second%2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 5632