akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(void) {
	int n,v[50],c,sum=0;
	cin >> n;
	rep(i, n)cin >> v[i];
	rep(i, n) {
		cin >> c;
		if (v[i] - c > 0)sum += v[i] - c;
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const ll inf = 5e15;

ll solve() {
    ll t1, t2;
    cin >> t1 >> t2;
    ll a1, b1, a2, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    ll alen = a1 * t1 + a2 * t2;
    ll blen = b1 * t1 + b2 * t2;
    if(alen == blen) return -inf;
    if(alen < blen) {
        swap(a1, b1);
        swap(a2, b2);
        swap(alen, blen);
    }
    ll diff = alen - blen;
    ll ans = 0;

    DEBUG(diff);

    do {
        if(b1 * t1 < a1 * t1) break;
        ll ok = 0, ng = inf;
        while(abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll a = a1 * t1;
            ll b = b1 * t1 - mid;
            (a <= b ? ok : ng) = mid;
        }
        ans += 2 * (ok / diff) + !!(ok % diff);
    } while(false);

    return ans;
}

int main() {
    ll ans = solve();
    if(ans == -inf) cout << "infinity" << endl;
    else cout << ans << endl;
    return 0;
}


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


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

    map<int, int> A;
    int c;
    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> c;
        if (A.count(c))
            A.at(c) += 1;
        else
        {
            A[c] = 1;
        }
    }


    int cnt = 0;
    vector<int> B;
    for (auto i = A.begin(); i != A.end(); i++)
    {
        // cout << i->second << endl;
        B.push_back(i->second);
    }
    sort(B.begin(), B.end());

    if (B.size() <= K)
        cout << 0 << endl;
    else {
        for (int i = 0; i < B.size() - K; i++)
        {
            cnt += B[i];
        }
        cout << cnt << endl;
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Edge { int src,dst,weight; };
const int MAX_V = 100100;
const int mod = 10007;
vector<Edge> G[MAX_V];
int V;
int group[MAX_V];
int maxi[MAX_V];

void dfs(int cur,int index){
  rep(i,(int)G[cur].size()) {
    int next = G[cur][i].dst;
    if( group[next] == -1 ) {
      group[next] = index;
      dfs(next,index);
    }
  }
}

int main(){
  while( cin >> V, V ){
    rep(i,V) G[i].clear();
    rep(i,V) {
      rep(_,2){
        int dst,weight;
        cin >> dst >> weight;
        G[i].push_back((Edge){i,dst,weight});
      }
    }
    memset(group,-1,sizeof(group));
    memset(maxi,0,sizeof(maxi));
    int size_ = 0;
    rep(i,V) if( group[i] == -1 ) {
      group[i] = size_;
      dfs(i,size_);
      ++size_;
    }

    rep(i,V) rep(j,(int)G[i].size()) maxi[group[i]] = max(maxi[group[i]],G[i][j].weight);
    vector<int> counter(size_,0);
    rep(i,V) rep(j,(int)G[i].size()) if( maxi[group[i]] == G[i][j].weight ) ++counter[group[i]];
    int answer = 1;
    rep(i,size_) ( answer *= int(counter[i]/2) ) %= mod;
    cout << answer << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<pair<ll, ll>> vp1, vp2, vp3, vp4;
void solve(){
    ll N, W; cin >> N >>W;
    
    ll w1, v1; 
    cin >> w1 >> v1;
    vp1.pb({w1, v1});
    REP(i, N-1){
        ll w, v;
        cin >> w >> v;
        if(w == w1) vp1.pb({w, v});
        if(w == w1 + 1) vp2.pb({w, v});
        if(w == w1 + 2) vp3.pb({w, v});
        if(w == w1 + 3) vp4.pb({w, v});
    }
    ll a = vp1.size();
    ll b = vp2.size();
    ll c = vp3.size();
    ll d = vp4.size();
    sort(RALL(vp1));
    sort(RALL(vp2));
    sort(RALL(vp3));
    sort(RALL(vp4));
    //cout << vp2 << endl;

    ll res = 0;
    REP(i, a+1){
        REP(j, b+1){
            REP(k, c+1){
                REP(l, d+1){
                    ll wsum = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
                    //cout << wsum << endl;
                    if(wsum > W) continue;
                    ll vsum = 0;
                    REP(x, i) vsum += vp1[x].se;
                    REP(x, j) vsum += vp2[x].se;
                    REP(x, k) vsum += vp3[x].se;
                    REP(x, l) vsum += vp4[x].se;
                    //cout << vsum << endl;
                    res = max(res, vsum);
                }
            }
        }
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _0571
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine(); int len = s.Length;
			s += '?';
			List<Tuple<char, int>> dic = new List<Tuple<char, int>>();
			for (int i = 0; i < len;)
			{
				char c = s[i]; int count = 0;
				while (s[i + count] == c) count++;
				dic.Add(new Tuple<char, int>(c, count));
				i += count;
			}
			int ret = 0;
			for (int i = 0; i < dic.Count - 2; i++)
			{
				if (dic[i].Item1 == 'J')
				{
					int min = dic[i].Item2;
					if (dic[i + 1].Item1 == 'O')
					{
						i++;
						min = Math.Min(min, dic[i].Item2); int o = dic[i].Item2;
						if (dic[i + 1].Item1 == 'I')
						{
							i++;
							min = Math.Min(min, dic[i].Item2);
							if (min == o)
							{
								ret = Math.Max(ret, o);
							}
						}
					}
				}
			}
			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 54956
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    int x = 0;
    for(int i=0;i<N;i++){
        if(S[i] == 'I') x++;
        else x--;
        if(x>ans) ans = x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=collections.Counter(a)
B=collections.Counter(b)

inf=10e18
cc,cd=0,0
R=0
for i in range(n+1):
    if(A[i]+B[i]>n):
        R=inf
    else:
        cc+=A[i]
        R=max(R,cc-cd)
        cd+=B[i]
if(R==inf):
    print("No")
else:
    print("Yes")
    ans=" ".join(map(str,b[-R:]+b[:-R]))
    print(ans)

Measured memory_bytes: 69032
#lines = <<'EOS'
#2 3 4
#EOS

lines = $stdin.read
array = lines.split("\n")
r = array[0].split(" ")[0]
g = array[0].split(" ")[1]
b = array[0].split(" ")[2]

S = r + g + b

#puts S.to_i

if S.to_i % 4 == 0
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
#include<iostream>

using namespace std;

int main() {
	
	char first, second, ch;
	
	int cup[3] = {1, 0, 0};
	
	while( cin >> first >> ch >> second ) {
		
		if( ( first == 'A' && second == 'B' ) || ( first == 'B' && second == 'A' ) )
			swap(cup[0], cup[1]);
			
		else if( ( first == 'A' && second == 'C' ) || ( first == 'C' && second == 'A' ) )
			swap(cup[0], cup[2]);
			
		else
			swap(cup[1], cup[2]);
			
	}
		if(cup[0])
		cout << "A\n";
		
		if(cup[1])
		cout << "B\n";
		
		if(cup[2])
		cout << "C\n";	
		
	return 0;
}



Measured memory_bytes: 2976
N=int(input())
A=[int(i) for i in input().split()]

A.sort(reverse=True)

x=0
y=0
for i in range(N-1):
      if A[0]==A[1]:
          x=A[0]
          A.remove(x)
          A.remove(x)
          break
      else:
          A.remove(A[0])
if len(A)>=2:
    for i in range(len(A)-1):
        if A[0]==A[1]:
            y=A[0]
            break
        else:
            A.remove(A[0])

print(x*y)

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

int main(){
    int a, b, c, d;
    cin >> a >> b >>c;
    d = c - (a - b);
    if (d > 0){
        cout << d << endl;
    }
    else if(d <= 0){
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=gets.to_i
b=a.times.map{gets.chomp.to_s}
d=1
stock="aa"
for c in b do
  if d!=1 && c[0]!=stock[-1] then
    puts "No"
    exit
  end
  stock=c
  d += 1
end    
  
if b.length==b.uniq.length then
  puts "Yes"
else
  puts "No"
end  

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int n,ma,mb;
int dp[401][401];
int a[40],b[40],c[40];


int main(){
  scanf("%d %d %d",&n,&ma,&mb);
  REP(i,n){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
  }
  REP(i,401)REP(j,401) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i,n)for(int k = 400;k>=0;k--)for(int l = 400;l>=0;l--){
    if(k-a[i]<0 || l-b[i]<0) continue;
    if(dp[k-a[i]][l-b[i]] == INF) continue;
    //if(k+a[i]>400 || l+b[i]>400) break;
    dp[k][l] = min(dp[k][l],dp[k-a[i]][l-b[i]]+c[i]);
  }
  int mi = INF;
  for(int i = 1;i<=400;i++){
    if(ma*i>400 || mb*i>400) break;
    if(dp[ma*i][mb*i] == INF) continue;
    mi = min(mi,dp[ma*i][mb*i]);
  }
  if(mi==INF) printf("-1\n");
  else printf("%d\n",mi);
}


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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll ans = 0;
    rep(i, N) {
        if (A[i] >= B[i]) {
            ans += B[i];
        } else {
            ans += A[i];
            if (B[i] - A[i] > A[i + 1]) {
                ans += A[i + 1];
                A[i + 1] = 0;
            } else {
                ans += B[i] - A[i];
                A[i + 1] -= B[i] - A[i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    long long a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    ans = max(a*c,b*c);
    ans = max(ans,a*d);
    ans = max(ans,b*d);
    cout << ans << endl;
    return 0;
}

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

int main() {
 int n,m,a,b;
 cin >> n >> m;
 vector<int> vec1(0);
 vector<int> vec2(n);
 for(int i = 0 ; i < m*2 ; i++){
   cin >> a;
   vec1.push_back(a);
 }
 for(int i = 0 ; i < m*2 ; i++){
   b = vec1.at(i);
   vec2.at(b-1) = vec2.at(b-1) + 1;
 }
 for(int i = 0 ; i < n ; i++){
   cout << vec2.at(i) << endl;
 }
}


Measured memory_bytes: 3596
from math import factorial
from functools import reduce 

MOD = 10**9 + 7

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

X,Y = map(int,input().split())

factorial = [1]
for n in range(1, X+Y):
    factorial.append(factorial[n-1]*n%MOD)

ans = 0
prv_m, prv_n = None, None
done = set([])
for m in range(X):
  if (X-m)%2 == 1:continue
  n = (X-m)//2
  if 2*m+n != Y: continue
 
  ans += factorial[m+n]*power_func(factorial[m],MOD-2,MOD)*power_func(factorial[n],MOD-2,MOD)
  ans %= MOD
  done.add((m,n))

for m in range(Y):
  if (Y-m)%2 == 1:continue
  n = (Y-m)//2
  if 2*m+n != X or (n,m) in done: continue
  ans += factorial[m+n]*power_func(factorial[m],MOD-2,MOD)*power_func(factorial[n],MOD-2,MOD)
  ans %= MOD

print(ans%MOD)

Measured memory_bytes: 107272
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll MOD = 998244353;
const int MAX = 200002;

vector<ll> fac(MAX);

void COMinit()
{
  fac[0]=1;
  for (ll i=1;i<=MAX;i++)
  {
    fac[i]=(fac[i-1]*i) % MOD; 
  }
}

ll fast(ll a, ll n)
{
  ll ret=1;
  while (n>0)
  {
    if (n & 1)
    {
      ret = (ret * a) % MOD;
    }
    n = (n>>1);
    a = a * a % MOD;
  }
  return (ret);
}
 
ll comb(ll n, ll r)
{
  ll top=1;
  ll bot=1;
  ll ans;
  
  if (n<r || n<0 || r<0) return (0);
  
  top = fac[n];
  bot = fac[r]*fac[n-r] % MOD;
  ans = top * fast(bot,MOD-2) % MOD;
  return (ans);
}

int main()
{
  int N,M,K;
  cin>>N>>M>>K;
  
  COMinit();
  
  ll ans=0;
  for (int i=0;i<=K;i++)
  {
    ll sum = M*fast(M-1,N-i-1) % MOD;
    sum *= comb(N-1,i);
    sum %= MOD;
    ans += sum;
    ans %= MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4660
// ABC_163_B

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

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

	int sum = 0;
	vector<int> vec(m);
	for(int i = 0; i < m; ++i) {
		cin >>vec[i];
		sum += vec[i];
	}

	if(n >=sum) cout << n - sum << "\n";
	else cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int n;
	int x, y, z, w;
	int size;
	int pay;
	int i;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		pay = 0;
		
		for (i = 0; i < n; i++){
			
			scanf("%d %d %d %d", &x, &y, &z, &w);
			
			size = x + y + z;
			
			if ((size <= 60) && (w <= 2)){
				pay += 600;
			}
			else if ((size <= 80) && (w <= 5)){
				pay += 800;
			}
			else if ((size <= 100) && (w <= 10)){
				pay += 1000;
			}
			else if ((size <= 120) && (w <= 15)){
				pay += 1200;
			}
			else if ((size <= 140) && (w <= 20)){
				pay += 1400;
			}
			else if ((size <= 160) && (w <= 25)){
				pay += 1600;
			}
		}
		printf("%d\n", pay);
	}
	return (0);
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===



bool dp[85][85][13000];



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

	int H, W; cin >> H >> W;
	vector<Vi> A(H, Vi(W)), B(H, Vi(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> B[i][j];
		}
	}

	memset(dp, 0, sizeof(dp));

	int d = A[0][0] - B[0][0];
	dp[1][1][abs(d)] = true;

	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			d = abs(A[i - 1][j - 1] - B[i - 1][j - 1]);
			for (int k = 0; k <= 12800; ++k) {
				dp[i][j][k] |= dp[i - 1][j][abs(k - d)] | dp[i][j - 1][abs(k - d)]
					| dp[i - 1][j][k + d] | dp[i][j - 1][k + d];
			}
		}
	}

	int ans = I_INF;

	for (int i = 0; i <= 12800; ++i) {
		if (dp[H][W][i]) {
			ans = min(ans, i);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 92032
a, b = map(int, input().split())
s = input()
ok = True
for i in range(a):
    if s[i] not in [str(j) for j in range(10)]:
        ok = False
if s[a] != '-':
    ok = False
for i in range(a+1, a+b+1):
    if s[i] not in [str(j) for j in range(10)]:
        ok = False
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n = gets.chomp.to_i
as = gets.chomp.split.map(&:to_i)

l = []
1.upto(n).with_index(0) do |x, i|
  l << as[i] if as[i] != x
end

if l.length == 0 || l.length == 2
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1788
def main():
    x, n = [int(v) for v in input().split(' ')]
    if n == 0:
        print(int(x))
        return

    lst_p = [int(v) for v in input().split(' ')]
    lst_p.sort()

    if lst_p[-1] < x:
        print(int(0))
        return

    # add dummy value
    lst_p.append(lst_p[-1] + 2)

    d = x
    ans = 0
    continueous_n = 1
    for p in lst_p:
        if p == continueous_n:
            continueous_n = p + 1
            continue
        for i in range(p - continueous_n):
            tmp = abs(x - (continueous_n + i))
            if tmp < d:
                d = tmp
                ans = continueous_n + i
            else:
                print(int(ans))
                return
        continueous_n = p + 1
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n;

int main()
{
    cin >> n;
    string s;
    while(true) {
        LL md = n % 26;
        s += ('a' + (md - 1 + 26)%26);
        if(md == 0) n-=26;
        n = n / 26;
        if(n == 0) break;
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

class Disjointset {

private:
	vector<int> p, rank;

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

public:
	Disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; ++i)
			makeset(i);
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

int main() {

	int n, q;
	scanf("%d %d", &n, &q);

	Disjointset disjointset(n);

	for (int i = 0; i < q; ++i) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) {
			disjointset.unite(x, y);
		} else {
			if (disjointset.same(x, y)) {
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3284
N=10**5+3
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
    fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
    inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
    if n<0 or r<0 or r>n:
        return 0
    return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod
n=int(input())
A=list(map(int,input().split()))
used=[0]*n
for i in range(n+1):
    a=A[i]
    if used[a-1]==0:
        used[a-1]=[1,i]
    else:
        x=a
        y=used[a-1][1]
        z=i
        break
print(n)
for i in range(2,n+2):
    ans=nCr(n+1,i)-nCr(n-z+y,i-1)
    print(ans%mod)

Measured memory_bytes: 32428
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void)
{
   char S[6]={'\0'};
   scanf("%s",&S);
   if (S[2]==S[3] && S[4]==S[5])
    printf("Yes");
   else printf("No");
    return EXIT_SUCCESS;
}



Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く

            int n = cin.ReadInt;
            int m = cin.ReadInt;
            int k = cin.ReadInt;
            int[] A = cin.ReadIntArray(n);
            int[] B = cin.ReadIntArray(m);
            long[] a = new long[n + 1];
            long[] b = new long[m + 1];
            int ans = 0;
            int j = m;

            for (int i = 1; i < a.Length; i++) {
                a[i] = a[i-1] + A[i - 1];
            }

            for (int i = 1; i < b.Length; i++) {
                b[i] = b[i - 1] + B[i - 1];
            }

            for (int i = 0; i < n + 1; i++) {
                if (a[i] > k) {
                    break;
                }

                while (b[j] > k - a[i]) {
                    j--;                    
                }
                ans = Math.Max(ans, i+j);
            }


            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 75220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s,t;cin>>s>>t;
  cout<<t+s<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

int main() {
	int h,n;
	cin>>h>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	int sum=0,i=0;
	while(i<n && sum<=h){
	    sum+=a[i];
	    i++;
	}
	if(sum>=h){
	    cout<<"Yes";
	}
	else{
	    cout<<"No";
	}
	return 0;
}

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

int main() {
	int n, m, a[100][100], b[100];
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++) {
		int c = 0;
		for (int j = 0; j < m; j++)
			c += a[i][j] * b[j];
		cout << c << endl;
	}
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, K;
int H[MAX_N];

int dp[MAX_N];

signed main()
{
  cin >> N >> K;
  REP(n,N) {
    cin >> H[n];
  }

  fill(dp,dp+N,INF_LL_MAX);
  dp[0] = 0;

  REP(n,N) {
    FOR(k,1,K+1) {
      int next = min(n+k, N-1);
      dp[next] = min(dp[next], dp[n]+abs(H[n] - H[next]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N;
  long long K;
  cin>>N>>K;
  int P[5001];
  for(int i=1;i<=N;i++) cin>>P[i];
  long long C[5001];
  for(int i=1;i<=N;i++) cin>>C[i];
  long long answer=C[1];
  for(int i=1;i<=N;i++){
    int num=P[i];
    long long roop[5000];
    roop[0]=C[P[i]];
    long long key=roop[0];
    answer=max(answer,roop[0]);
    int j=1;
    while(j<K&&num!=i){
      num=P[num];
      key+=C[num];
      roop[j]=key;
      answer=max(answer,key);
      j++;
    }
    if(K>j&&roop[j-1]>0){
      long long a=roop[j-1]*((K/j)-1);
      for(int k=0;k<j;k++) answer=max(answer,a+roop[k]);
      for(int k=0;k<K%j;k++) answer=max(answer,a+roop[j-1]+roop[k]);
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

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

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

signed main() {
  cout << fixed << setprecision(14);
  string s;
  cin >> s;
  int l= s.size();
  
  rep(i,0,l-1){
    if(s[i]==s[i+1]) {
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  
  
  rep(i,0,l-2){
    if(s[i]==s[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	ll N,A,B,Ans=0;
	cin>>N>>A>>B;
	vector<ll> X(N);
	for(int i=0;i<N;i++) cin>>X[i];
	for(int i=0;i<N-1;i++){
		if((X[i+1]-X[i])*A>=B) Ans+=B;
		else Ans+=(X[i+1]-X[i])*A;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner


object Main {

  case class RR(representative: Long) extends AnyVal {
    def +(that: RR): RR = RR((this.representative + that.representative) % RR.mod)

    def -(that: RR): RR = RR((this.representative - that.representative + RR.mod) % RR.mod)

    def *(that: RR): RR = RR((this.representative * that.representative) % RR.mod)

    def unary_- : RR = RR((-this.representative + RR.mod) % RR.mod)
  }


  object RR {
    val mod: Long = (1e9 + 7).toLong

    val _0: RR = RR(0)
    val _1: RR = RR(1)
  }

  def read() = {
    val sc = new Scanner(System.in)
    val n, m, k = sc.nextInt()
    (n, m, k)
  }

  def comb(a: Int, b: Int): Int = {
    if (a < b) 0
    else if (b == 0) 1
    else comb(a - 1, b - 1) + comb(a - 1, b)
  }

  def fracRR(n: Int): RR = (1 to n).map(RR(_)).foldLeft(RR(1))(_ * _)


  def combRR(n: Int, r: Int): RR = {
    // comb(n,r) = n!/(r! (n-r)!)
    val x = fracRR(n) // n!
    val y = fracRR(r) // r!
    val z = fracRR(n - r) // (n-r)!

    val yz = y * z
    x * rrInv(yz)
  }

  def mypow(x: Long, t: Long): Long = {
    if (t == 0) {
      return 1
    }
    val y = mypow(x, t / 2)
    if (t % 2 == 0) {
      y * y
    } else {
      x * y * y
    }
  }

  def mypowRR(x: RR, t: Long): RR = {
    if (t == 0) {
      return RR(1)
    }
    val y = mypowRR(x, t / 2)
    if (t % 2 == 0) {
      y * y
    } else {
      x * y * y
    }
  }

  def rrInv(x: RR): RR = mypowRR(x, RR.mod - 2)

  def solve(h: Int, w: Int, k: Int): Int = {
    // 1 + 2 + ... + tを求める
    def sum(t: Int) = t * (t + 1) / 2

    def sumDist(x: Int, y: Int): Int = {
      // 0-origin
      // xより左側: [0,x) (xマス)
      // xより右側: [x+1,w) (w-x-1マス)
      // yより上側: [0,y) (yマス)
      // yより下側: [y+1, h) (h-y-1マス)
      (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w
    }

    comb(w * h - 2, k - 2) * (for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum
  }

  def solve2(h: Int, w: Int, k: Int): Long = {
    // 1 + 2 + ... + tを求める
    def sum(t: Long) = t * (t + 1) / 2

    def sumDist(x: Long, y: Long): RR = {
      // 0-origin
      // xより左側: [0,x) (xマス)
      // xより右側: [x+1,w) (w-x-1マス)
      // yより上側: [0,y) (yマス)
      // yより下側: [y+1, h) (h-y-1マス)
      RR(sum(x) + sum(w - x - 1)) * RR(h) + RR(sum(y) + sum(h - y - 1)) * RR(w)
    }

    val nComb = combRR(w * h - 2, k - 2)
    val distAll = (for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) * rrInv(RR(2))).foldLeft(RR(0))(_ + _)
    val result = nComb * distAll
    result.representative
  }

  def main(args: Array[String]): Unit = {
    val (n, m, k) = read()
    println(solve2(n, m, k))
  }
}

Measured memory_bytes: 80624
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量，a为初始值，n为界限值，递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量， a为初始值，n为界限值，递减。
#define mes(a,b) memset((a),(b),sizeof((a)))
#define syio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lson l, mid, rt << 1
#define rson mid+1, r, rt << 1 | 1
#define lowbit(a) ((a)&-(a))
#define pb(a) push_back((a))
#define mkp(x, y) make_pair((x), (y))
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%I64d",&x)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;
typedef long double real;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mxn = 100033;
const int mod = 1e9 + 7;//998244353
inline int read(){
    int x = 0,f = 1;char c = getchar();
    while(!isdigit(c))f = c == '-' ? -1 : 1,c = getchar();
    while(isdigit(c))x = x * 10 + c - '0',c = getchar();
    return x * f;
}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
int dx[] = {0 , 1, 0 , -1};
int dy[] = {1 , 0, -1 , 0};
int main()
{
    syio;
    double d, t, s;
    cin>>d>>t>>s;
    if (d / s <= t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";
#define int long long
int32_t main()
{
    const ll mod = 1000000007;

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    sort(all(a));
    if (a[n - 1] == 0 && k & 1)
        return cout << "0", 0;
    if (a[n - 1] < 0 && (k & 1))
    {
        ll prod = 1;
        for (ll i = n - 1; i >= n - k; i--)
        {
            prod *= a[i];
            prod %= mod;
        }
        prod = ((prod + mod) % mod + mod) % mod;

        return cout << prod, 0;
    }
    ll prod = 1;
    ll i = 0, j = n - 1;
    if (k & 1)
    {
        prod *= a[j];
        prod%=mod;
        j--;
        k--;
    }

    k /= 2;
    for (int itr = 0; itr < k; itr++)
    {

        ll l = a[i] * a[i + 1];
        ll r = a[j] * a[j - 1];
        if (l > r)
        {
            l%=mod;
            prod *= l;
            prod %= mod;
            i += 2;
        }
        else
        {
            r%=mod;
            prod *= r;
            prod %= mod;
            j -= 2;
        }
    }

    prod = ((prod + mod) % mod + mod) % mod;
    cout << prod;
}


Measured memory_bytes: 4836
#include <cstdio>

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	a += 12, b += 12;
	a %= 14, b %= 14;

	if(a > b){
		puts("Alice\n");
	}
	else if(a < b){
		puts("Bob\n");
	}
	else{
		puts("Draw");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    int test;
    int flag=0;
    cin>>n>>k;
    int x,y,z;
    if(k>n*10000){
        x=y=z=-1;
    }else{
        for(int i=0;i<n+1;i++){
            for(int j=0;j<i+1;j++){
                test = 10000*(n-i) + 5000*(i-j) + 1000*j;
                    if(test==k){
                        flag=1;
                        x=n-i;
                        y=i-j;
                        z=j;
                        goto label;
                    }
                }
            }
        label:
        if(flag==0){
            x=y=z=-1;
        }
    }
    printf("%d %d %d\n",x,y,z);
}

Measured memory_bytes: 256
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __repr__(self):
        return f"({self.x},{self.y})"


class Segment:
    def __init__(self, x: Point, y: Point):
        self.pt1 = x
        self.pt2 = y
        self.vector = self.pt2 - self.pt1

    def dot(self, other):
        return self.vector.x * other.vector.x + self.vector.y * other.vector.y

    def cross(self, other):
        return self.vector.x * other.vector.y - self.vector.y * other.vector.x

    def __repr__(self):
        return f"{self.pt1},{self.pt2},{self.vector}"


def main():
        n = int(input())
        for i in range(n):
            p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y = map(int, input().split())
            seg_1 = Segment(Point(p0_x, p0_y), Point(p1_x, p1_y))
            seg_2 = Segment(Point(p2_x, p2_y), Point(p3_x, p3_y))

            if seg_1.dot(seg_2) == 0:
                print('1')
            elif seg_1.cross(seg_2) == 0:
                print('2')
            else:
                print('0')
        return

main()


Measured memory_bytes: 5648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int N, M;
bool broken[100005];
ll ans;
const ll MOD = 1000000007LL;
ll memo[100005];

ll Solve(int pos)
{
    if (broken[pos]) return 0;
    if (pos > N) return 0;
    if (pos == N)
    {
        return 1;
    }
    if (memo[pos] >= 0) return memo[pos];
    ll res = 0;
    res += Solve(pos + 1);
    res %= MOD;
    res += Solve(pos + 2);
    res %= MOD;
    return memo[pos] = res;
}

void _main()
{
    cin >> N >> M;
    rep(i, 0, M)
    {
        int a;
        cin >> a;
        broken[a] = true;
    }
    rep(i, 0, 100005) memo[i] = -1;
    cout << Solve(0) << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    cin>>n;
    x=0;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
    	x=x^arr[i];
	}
	for (i=0;i<n;i++)
	{
		y=x^arr[i];
		cout<<y<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 5188
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, T;
	cin >> N >> T;
	int am = 100000000;
	int bm = 10000;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (b <= T) {
			if (a < am) {
				am = a;
			}
		}
	}
	if (am == 100000000) {
		cout << "TLE";
	}
	else {
		cout << am;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=1;i<n+1;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int main(){
  int n; cin>>n;
  unordered_map<string, int>mp;
  rep(i,0,n){
    string a; cin>>a;
    mp[a]++;
  }
  cout<<"AC"<<' '<<'x'<<' '<<mp["AC"]<<endl;
  cout<<"WA"<<' '<<'x'<<' '<<mp["WA"]<<endl;
  cout<<"TLE"<<' '<<'x'<<' '<<mp["TLE"]<<endl;
  cout<<"RE"<<' '<<'x'<<' '<<mp["RE"]<<endl;
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
info = [list(map(int, input().split())) for _ in range(n)]
info.sort()
ans = 0
for i in range(n):
    if m >= info[i][1]:
        m -= info[i][1]
        ans += info[i][0]*info[i][1]
    else:
        ans += info[i][0]*m
        break

print(ans)

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

int main() {
  string S,T,U;
  int A,B;
  cin >> S;
  A=S.length()-1;
  T="x";
  while(A!=0){
    T+='x';
    A--;
  }
  cout <<T<< endl;
}


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

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

  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double w = W, h = H;

  cout << fixed << setprecision(10) << (w * h) / 2 << " ";
  if (W == x + x && H == y + y)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3804
rdx = list(map(lambda x: int(x), input().split()))
r = rdx[0]
d = rdx[1]
x = rdx[2]

memo = [0 for i in range(11)]

memo[0] = x
for i in range(10):
  memo[i+1] = memo[i] * r - d
  print(memo[i+1])

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

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String input = reader.readLine();
			String[] array = input.split(" ");
			int n = Integer.parseInt(array[0]);
			int m = Integer.parseInt(array[1]);
			int l = Integer.parseInt(array[2]);

			long a[][] = new long[n][m];
			for (int i = 0; i < n; i++) {
				input = reader.readLine();
				array = input.split(" ");
				for (int j = 0; j < m; j++) {
					a[i][j] = Long.parseLong(array[j]);
				}
			}

			long b[][] = new long[m][l];
			for (int i = 0; i < m; i++) {
				input = reader.readLine();
				array = input.split(" ");
				for (int j = 0; j < l; j++) {
					b[i][j] = Long.parseLong(array[j]);
				}
			}
			long[][] c = new long[n][l];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					for (int k = 0; k < m; k++) {
						c[i][j] += a[i][k] * b[k][j];
					}
					System.out.print(c[i][j]);
					if (j != (l - 1)) {
						System.out.print(" ");
					}
					
				}
				System.out.println();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

const ll MOD = 1000000007;

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

    vector<string> sv;
    rep(i, n) {
        string s;
        cin >> s;
//        cout << s << endl;
        if ( i == 0 ) {
            sv.push_back(s);
        }
        else if ( s[0] != sv[sv.size()-1][sv[sv.size()-1].length()-1] ) {
            cout << "No" << endl;
            return 0;
        }
        else {
//            cout << "test" << endl;
            rep(j, sv.size()) {
//                cout << sv[j] << endl;
                if ( s == sv[j] ) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            sv.push_back(s);
        }
    }

//    rep(i, sv.size()) {
//        cout << sv[i] << endl;
//    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int N, K, T, U, V, L;
	double D[201];
	while(cin >> N >> K >> T >> U >> V >> L){
		for(int i=0;i<N;i++) cin >> D[i];
		D[N] = L;
		double res = (double)D[0]/U;
		double lest = T;
		for(int i=1;i<=N;i++){
			double len = D[i]-D[i-1];
			if(len > lest*V){
				res += lest + (len-lest*V)/U;
				lest = 0;
			} else {
				res += len/V;
				lest -= len/V;
			}
			lest = min(lest+T, T*(K+1.0));
		}
		printf("%.8lf\n", res);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define INF 1e12
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int power(int b,int p)
{
	if(p==0) return 1;
	if(p==1) return b;
	int tmp=power(b,p/2);
	if(p%2) return tmp*tmp*b;
	return tmp*tmp;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c; cin>>a>>b>>c;
	int tmp=gcd(a,b);
	int cnt=0;
	for(int i=tmp;i>=1;i--)
	{
		if(tmp%i==0) cnt++;
		if(cnt==c)
		{
			cout<<i<<"\n";
			return 0;
		}
	}
}











Measured memory_bytes: 256
##### 解けた #####

A,B=list(map(int,input().split(" ")))
c=0 # 個数

for n in range(A,B+1):
    ns=list(str(n)) # 順に読んだ文字列
    nsr=list(reversed(ns)) # 逆順に読んだ文字列

    if ns==nsr: # もし順に読んでも逆順に読んでも同じなら
        c+=1 # 個数をインクリメント

print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long

int n;
int cnt[30];
string ans="000000000000000000000000000000000000000000000000000000000000";
int num;

signed main(){
    for(int i=0;i<30;i++)cnt[i]=100;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        int c[30]={};
        for(int j=0;j<s.length();j++){
            for(int k='a';k<='z';k++){
                if(s[j]==k)c[k-'a']++;
            }
        }
        for(int j='a';j<='z';j++)cnt[j-'a']=min(cnt[j-'a'],c[j-'a']);
    }
    for(int i='a';i<='z';i++){
        for(int j=0;j<cnt[i-'a'];j++){
            ans[num]=i;
            num++;
        }
    }
    for(int i=0;i<num;i++)cout<<ans[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;
main(){
    ll n=in();
    cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256