akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

struct node{
	int l , r;
}a[100];

int all , ll , rr;

bool vis[100] , map[200][200];

int pre[200] , other[200] , last[200];

void build(int x , int y)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}

void dfs(int x)
{
	vis[x] = 1;
	int ed = last[x];
	while(ed != -1){
		int dr = other[ed];
		if(vis[dr] == 0 && map[dr][x] == 0 && map[x][dr] == 0){
			dfs(dr);
		}
		ed = pre[ed];
	}
}

int main()
{
	int n , m;
	all = 0;
	scanf("%d %d",&n , &m);
	memset(last , -1 , sizeof(last));
	for(int i = 1 ; i <= m ; i++){
		int x , y;
		scanf("%d %d",&x , &y);
		build(x , y);
		build(y , x);
		a[i].l = x , a[i].r = y;
	}
	int ans = 0;
	memset(map , 0 , sizeof(map));
	for(int i = 1 ; i <= m ; i++){
		memset(vis , 0 , sizeof(vis));
		ll = a[i].l , rr = a[i].r;
		map[ll][rr] = 1 , map[rr][ll] = 1;
		dfs(1);
		map[ll][rr] = 0 , map[rr][ll] = 0;
		int flag = 0;
		for(int i = 1 ; i <= n ; i++) if(vis[i] == 0) flag = 1;
		if(flag) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,d,r;
	double f;
	
	scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(a+0.0)/(b+0.0);
	
	printf("%d %d %f\n",d,r,f);
return 0;
}

Measured memory_bytes: 636
n = int(input())
s = input()
res = n
w = 0
e = 0
for i in range(n):
    if s[i] == "W":
        w += 1
    else:
        e += 1

l_w = 0
l_e = 0
for i in range(n):
    if i == n - 1 and s[i] == "E":
        l_e += 1
    tmp = l_w + (e - l_e)
    res = min(tmp, res)
    if s[i] == "W":
        l_w += 1
    else:
        l_e += 1
print(res)


Measured memory_bytes: 9764
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()
    if t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1

print(taro, hanako)

Measured memory_bytes: 7636
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(2001,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.count(x)){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

long long comb(int a, int b){
    long long ret=fact[a]*inv_factorial(fact[a-b])%MOD;
    return ret*inv_factorial(fact[b])%MOD;
}

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

    factorial(2000);
    for(int i=1; i<=K; i++){
        if(N-K-i+1==0){
            cout << comb(K-1, i-1) << endl;
        }else if(N-K-i+1<0){
            cout << 0 << endl;
        }else{
            cout << comb(K-1, i-1) * comb(N-K+1, i) %MOD << endl;
        }
    }

}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main(string[] args) {
    int[] nm = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
    int n = nm[0], m = nm[1];

    if (n >= m) {
      Console.WriteLine(0);
      return;
    }

    int[] x = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
    Array.Sort(x);

    int[] range = new int[m - 1];
    for (int i = 0; i < m - 1; i++) {      
      range[i] = x[i + 1] - x[i];
    }

    Array.Sort(range);

    int ans = 0;
    for (int i = 0; i < range.Length - (n - 1); i++) {
      ans += range[i];
    }

    Console.WriteLine(ans);
  }
}


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

int main() {
	long N, A, B;
	cin >> N >> A >> B;
	
	long blue;
	blue = (N / (A + B)) * A;

	long amari = 0;
	amari = N % (A + B);

	if (A < amari) {
		blue += A;
	} else {
		blue += amari;
	}

	cout << blue << endl;

	return 0;
}


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

int A;
int a[6];

bool dp[6+1][100001];

int main() {
    cin >> A;
    a[0] = 100;
    a[1] = 101;
    a[2] = 102;
    a[3] = 103;
    a[4] = 104;
    a[5] = 105;
    
    memset(dp, 0, sizeof(dp));
    dp[0][0] = true;
    
    for (int i = 0; i < 6; ++i) {
        for (int j = 0; j <= A; ++j) {
            dp[i+1][j] |= dp[i][j];
            if (j >= a[i]){
                dp[i+1][j] |= dp[i][j-a[i]];
                //重複含む
                dp[i+1][j] |= dp[i+1][j-a[i]];
            }
        }
    }
    if (dp[6][A]) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 2;

int n, t, a[N];
int pre[N], suf[N];

int main()
{
	//File("");
	n = gi <int> (), t = gi <int> ();
	memset(pre, 0x3f, sizeof pre);
	memset(suf, 0, sizeof suf);
	for (int i = 1; i <= n; i+=1) a[i] = gi <int> ();
	for (int i = n; i >= 1; i-=1) suf[i] = max(suf[i + 1], a[i]);
	int mx = 0, cnt = 0;
	for (int i = 1; i <= n; i+=1) mx = max(mx, suf[i] - a[i]);
	for (int i = 1; i <= n; i+=1) if (mx == suf[i] - a[i]) ++cnt;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 4912
N = int(input())

if N < 10:#ok
    print(N)
elif 10<= N < 100:#ok
    print(9)
elif 100<= N < 1000:#ok
    add = N-100
    print(9+add+1)
elif 1000<= N < 10000:
    print(909)
elif 10000<= N < 100000:
    add = N-10000
    print(909+add+1)
elif N == 100000:
    print(90909)
    

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String t = S.substring(0, 2);
		String k = S.substring(2);
		int a = Integer.parseInt(t);
		int b = Integer.parseInt(k);
		String s;
		if ((1 <= a && a <= 12) && (1 <= b && b <= 12)) {
			s = "AMBIGUOUS";
		} else if ((1 <= a && a <= 12) && (13 <= b || b == 0)) {
			s = "MMYY";
		} else if ((a >= 13 || a == 0) && (1 <= b && b <= 12)) {
			s = "YYMM";
		} else {
			s = "NA";
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 23124
/*;

THE BEST IS YET TO COME

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define vi vector<int>
#define vip vector<pair<int,int> >
#define endl "\n"
#define ln length()
#define sz size()
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
signed main()
{

    int n;
    cin>>n;
    vector<int> arr(N);
	int i = 0;
	while (n) {
		arr[i] = n % 26;
		n = n / 26;
		i++;
	}


	for (int j = 0; j < i - 1; j++) {
		if (arr[j] <= 0) {
			arr[j] += 26;
			arr[j + 1] = arr[j + 1] - 1;
		}
	}

	for (int j = i; j >= 0; j--) {
		if (arr[j] > 0)
			cout << char('a' + arr[j] - 1);
	}


	return 0;
}




Measured memory_bytes: 18832
#include<stdio.h>

int main(){
  int N,i,ct = 0;
  long long int sum = 0,min = 2000000000,a;
  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%lld",&a);
    if(a < 0){
      a = -a;
      ct = 1-ct;
    }
    if(a == 0){
      ct = -1;
    }
    if(a < min){min = a;}
    sum += a;
  }
  if(ct == 1){sum -= min*2;}
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int n,h,a[100005],b[100005],t,ans;

int main()
{
	scanf("%d%d",&n,&h);
	for(int i=1; i<=n; i++)
		scanf("%d%d",&a[i],&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	for(int i=n; i>=1; i--){
		if(b[i]>a[n]){
			h-=b[i];
			ans++;
			if(h<=0) {
				printf("%d",ans);
				return 0; 
			} 
		} 
		else break;
	}
	t=(h-0.5)/a[n];
	ans+=t;
	printf("%d",ans+1);
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double a[n];
    for(int i=0;i<n;i++)
    cin >> a[i];
    multiset<float, greater <double> > s(a,a+n);
        while(s.size()>1)
        {
            double x = *prev(s.end());
            s.erase(prev(s.end()));
            double y = *prev(s.end());
            s.erase(prev(s.end()));
            s.insert((x+y)/2);
        }
        cout << *s.begin();
    return 0;
}

Measured memory_bytes: 256
//参考(http://algorithms.blog55.fc2.com/blog-category-6.html)
#include<cstdio>

using namespace std;

int ka[1001],wei[1001],data[1001][1001];
int main(void){
	int w,n,set=0,maxw;
	int i,j,z;

	while(1){
		scanf("%d",&w);
		if(w==0)	break;
		
		maxw=0;
		set++;
		//初期化
		for(i=0;i<1001;i++){
			ka[i]=0;
			wei[i]=0;
			for(j=0;j<1001;j++)	data[i][j];
		}

		//入力
		scanf("%d",&n);
		for(i=1;i<=n;i++){
			scanf("%d,%d",&ka[i],&wei[i]);
		}
		
		//処理
		for(i=1;i<=n;i++){
			for(j=1;j<=w;j++){
				if(j<wei[i])	data[i][j]=data[i-1][j];
				else{
					if(data[i-1][j] < data[i-1][j-wei[i]]+ka[i]){
						data[i][j]=data[i-1][j-wei[i]]+ka[i];
					}
					else{
						data[i][j]=data[i-1][j];
					}
				}
			}
		}
		i--;
		j--;
		for(z=j-1;z>0;z--){
			if(data[i][j]==data[i][z])	j=z;
		}
		while(1){
			if(data[i][j]==0)	break;
			if(data[i][j]==data[i-1][j])	i--;
			else{
				maxw+=wei[i];
				j=j-wei[i];
				i--;
			}
		}
		printf("Case %d:\n%d\n%d\n",set,data[n][w],maxw);
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  int ans = N % 10;
  if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9) {
    cout << "hon" << endl;
  } else if (ans == 0 || ans == 1 || ans == 6 || ans == 8) {
    cout << "pon" << endl;
  } else if (ans == 3) {
    cout << "bon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    string S, T;

    int flag = 0;

    cin >> S >> T;

    for(int i=0; i < S.size(); i++){
        if(S.at(i) != T.at(i)){
            cout << "No" << endl;
            flag++;
            break;
        }
    }

    if(flag==0){
        cout << "Yes" << endl;
    }

}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    char x,y;
    cin >>x >> y;
    if(x > y) cout << ">"<<endl;
    if(x < y) cout << "<"<<endl;
    if(x == y)cout << "="<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
#define eps 1e-15
#define f first
#define s second
typedef long long ll;
int main()
{
    fastIO

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a==0 && a<b)
        ++a;
    if (c==0 && c<d)
        c++;

    ll x=a*c;
    ll y=a*d;
    ll z=b*c;
    ll f=b*d;

    cout<<max(max(x,y),max(z,f));


}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

ll my_min(ll a, ll b) {
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

void solve(long long N, long long K) {
    if (N > K) {
        ll mod = N % K;
        cout << my_min(mod, abs(mod - K)) << endl;
        return;
    } else if (N == K) {
        cout << 0 << endl;
    } else {
        ll diff = K - N;
        ll add = diff / K;
        add++;
        N += K * add;
        ll mod = N % K;
        cout << my_min(mod, abs(mod - K)) << endl;
        return;
    }
}

int main() {
    long long N;
    std::cin >> N;
    long long K;
    std::cin >> K;
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int a,b,c,d,f[3005][3005];
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	f[a][b]=1;
	for(int i=b+1;i<=d;i++)
		f[a][i]=1ll*f[a][i-1]*a%mod;
	for(int i=a+1;i<=c;i++)
		f[i][b]=1ll*f[i-1][b]*b%mod;
	for(int i=a+1;i<=c;i++)
		for(int j=b+1;j<=d;j++)
			f[i][j]=(1ll*f[i][j-1]*i%mod+1ll*f[i-1][j]*j%mod-1ll*f[i-1][j-1]*(i-1)*(j-1)%mod+mod)%mod;
	printf("%d\n",f[c][d]);
	return 0;		
} 

Measured memory_bytes: 36836
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var max = a[0];
        var ans = 0L;
        for (int i = 1; i < n; i++)
        {
            if (a[i] > max) max = a[i];
            else if (a[i] < max) ans += max - a[i];
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 45848
using System;
using static System.Math;

class Program
{
  static void Main(string[] args)
  {
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int c = int.Parse(Console.ReadLine());
    int d = int.Parse(Console.ReadLine());
    
    int train = Min(a, b);
    int bus = Min(c, d);
    
    Console.WriteLine("{0}", train + bus);
  }
}

Measured memory_bytes: 13140
n = int(input())
if 0<= n <=1000:
    print(1000- n)
elif 1000< n <=2000:
    print(2000- n)
elif 2000< n <=3000:
    print(3000- n)
elif 3000< n <=4000:
    print(4000- n)
elif 4000< n <=5000:
    print(5000- n)
elif 5000< n <=6000:
    print(6000- n)
elif 6000< n <=7000:
    print(7000- n)
elif 7000< n <=8000:
    print(8000- n)
elif 8000< n <=9000:
    print(9000- n)
elif 1000< n <=10000:
    print(10000- n)

Measured memory_bytes: 61828
#include <iostream>

using namespace std;

int main()
{
	int val[101] = {};
	for (int i = 1; i <=9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			val[i*j] = 1;
		}
	}
	int N;
	cin >> N;
	if (val[N])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#line 1 "test/atcoder/practive2-a.cpp"
// @title AtCoder Libraryのサンプル
// @see https://atcoder.jp/contests/practice2/tasks/practice2_a

#include <iostream>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main() {
    int n, q; cin >> n >> q;
    dsu d(n);
    for (int i = 0; i < q; ++i) {
        int t, u, v; cin >> t >> u >> v;
        if (t == 0) { 
            d.merge(u, v);
        }
        else {
            cout << d.same(u, v) << endl;
        }
    }
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

struct event {
    int start, type, X;
};

signed main() {
    int N, Q;
    cin >> N >> Q;
    vector<event> construction;
    for (int i = 0; i < N; i++) {
        int S, T, X;
        cin >> S >> T >> X;
        construction.push_back({S - X, 0, X});
        construction.push_back({T - X, 1, X});
    }
    for (int i = 0; i < Q; i++) {
        int D;
        cin >> D;
        construction.push_back({D, 2, inf});
    }
    sort(construction.begin(), construction.end(), [](event a, event b){
        if (a.start == b.start) return a.type < b.type;
        return a.start < b.start;
    });
    multiset<int> underConstruction;
    for (auto one : construction) {
        if (one.type == 0) {
            underConstruction.insert(one.X);
        } else if (one.type == 1) {
            underConstruction.erase(underConstruction.find(one.X));
        } else {
            if (underConstruction.empty()) {
                cout << -1 << endl;
            } else {
                cout << *underConstruction.begin() << endl;
            }
        }
    }
}


Measured memory_bytes: 25832
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m, t; cin >> n >> m >> t;
    int a[111] = {}, dp[111] = {};
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) {
        if(i == 0) dp[i] = a[i] - m;
        else {
            if(a[i] - a[i-1] < 2*m) dp[i] = dp[i-1];
            else dp[i] = dp[i-1] + (a[i] - a[i-1] - 2 * m);
        }

        if(i == n-1) {
            if(t - a[i] >= m) dp[i] += (t - a[i] - m);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  string input;
  cin >> input;
  int len_input = input.size();
  
  int flag = 1;
  
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < len_input; j++){
      if(i == input[j] - 'a' ){
	flag = 0;
      } else {
	
      }
          
    }
    if(flag == 1){
      char output  = i + 'a';
      cout << output << endl;
      return 0;
    } else {
      flag = 1;
    }

  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
//#define int long long

const int N = (int)(1e7) + 322;
const int inf = (int)(2e18);
const int mod = (int)(1e9) + 7; // check modulo

int a[N], b[N], n, m, k, mx;

int lp[N+1];
vector<int> pr;

inline int getsum(int x) {
    int res = 1;
    int prev = 0;
    int cntprev = 0;
    while (x > 1) {
        if (lp[x] != prev) {
            res *= (cntprev + 1);
            prev = lp[x];
            cntprev = 1;
        }else {
            cntprev++;
        }
        x /= lp[x];
    }
    res *= (cntprev + 1);

    return res;
}

void solve() {
    for (int i = 2; i < N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
    int n; cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans += 1ll * getsum(i) * i;
    }
    cout << ans;

}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
//    int test; cin >> test;
//    for(int tt = 0; tt < test; ++tt) {
        solve();
//    }
    return 0;
}

Measured memory_bytes: 45848
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 1e6 + 7;

int a[N], L[N], R[N];

int32_t main() {
    speed;
    int k, n;
    cin >> k >> n;

    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i];
    } 
    int p = a[n];

    for ( int i = 1; i <= n; i++ ) {
        L[i] = (k + a[i]) - p + L[i - 1];
        p = k + a[i];

        // cout << L[i] << ' '; 
    }
    // cout << '\n';

    for ( int i = n - 1; i >= 1; i-- ) {
        R[i] = R[i + 1] + a[i + 1] - a[i];
        // cout << R[i] << ' ';
    }
    // cout << '\n';
    int mn = 1e9;
    for ( int i = 1; i <= n; i++ ) {
        mn = min( mn, R[i] + L[i - 1] );
    }
    cout << mn;
}   
  

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

int main() {
	int p[] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
	vector<int> pn(25), pnn(0);
	int n, num = 0;

	cin >> n;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < 25; j++) {
			int t = i;
			while (t%p[j] == 0) {
				pn.at(j)++;
				t /= p[j];
			}
		}
	}
	sort(pn.begin(), pn.end());
	reverse(pn.begin(), pn.end());
	for (int x : pn) {
		if (x < 2)
			break;
		pnn.push_back(x);
	}
	if (pnn.size() < 2) {
		cout << 0 << endl;
		return 0;
	}

	// 5*5*3
	if (pnn.size() > 2)
		for (int i = 0; i < pnn.size(); i++)
			for (int j = 0; j < pnn.size() - 1; j++)
				for (int k = j + 1; k < pnn.size(); k++)
					if (i != j && i != k && pnn[j] > 3 && pnn[k] > 3)
						num++;
	// 15*5
	for (int i = 0; i < pnn.size(); i++) {
		if (pnn[i] >= 14) {
			for (int j = 0; j < pnn.size(); j++) {
				if (i == j || pnn[j] < 4) continue;
				num++;
			}
		}
	}
	// 25*3
	for (int i = 0; i < pnn.size(); i++) {
		if (pnn[i] >= 24) {
			for (int j = 0; j < pnn.size(); j++) {
				if (i == j) continue;
				num++;
			}
		}
	}
	// 75
	if (pnn[0] >= 74)
		num++;
	cout << num << endl;
}

Measured memory_bytes: 256
# ABC055D - Menagerie (ARC069D)
def check(a: int, b: int) -> list:
    ret, cur, prev = [], a, b
    for i in S:
        ret += [cur]
        if cur ^ (i == "o"):
            prev, cur = cur, prev ^ 1  # both are different
        else:
            prev, cur = cur, prev  # both neighbors are the same
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else []


def main():
    global S
    N = int(input())
    S = input().rstrip()
    for a in range(2):
        for b in range(2):
            ans = check(a, b)
            if ans:
                print("".join("S" if i else "W" for i in ans), sep="")
                return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4852
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node{
  int key;
  struct node *parent, *left, *right;
};
typedef struct node * Node;
Node root;

void insert(int k){
  Node y = NIL; // x の親
  Node x = root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x != NIL){
    y = x; // 親を設定
    if( z->key < x->key) x = x->left; // 左の子へ移動
    else x = x->right; // 右の子へ移動
  }
  z->parent = y;
  if (y == NIL) // T が空の場合
    root = z;
  else if (z->key < y->key)
    y->left = z; // z を y の左の子にする
  else 
    y->right = z; // z を y の右の子にする
}
void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
  



Measured memory_bytes: 25152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

typedef long long ll;
#define fi first
#define se second

using namespace std;

int A[112345];
ll dp[112345];

int main(){
  
  int N;

  cin>>N;
  
  int i;
  
  for( i = 0; i < N; i++ ){
    scanf("%d", A+i);
  }
  
  sort( A, A+N );
  
  dp[0] = A[0];
  
  for( i = 1; i < N; i++ ){
    dp[i] = dp[i-1] + A[i];
  }
  
  int ans = N;
  int num = 0;
  
  
  for( i = 0; i < N-1; i++ ){
    if( dp[i]*2 < A[i+1] ) num = i+1;
  }
  
  ans -= num;
  
  cout<<ans<<endl; 
  
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define arr(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
    FAST;
    ll N,T,i,j,a,b,k=0;
    int A[100]={},B[100]={};
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>A[i];
        B[i]=A[i];
    }
    sort(A,A+N);
    for(i=0;i<N;i++)
    {
        if(A[i]==B[i]) k++;
    }
    if(k==N-2 || k==N) cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 3620
import sys
from itertools import product
N, M = map(int, sys.stdin.readline().rstrip().split())

cake = [tuple(map(int, sys.stdin.readline().rstrip().split())) for _ in range(N)]

ans = 0
for i, j, k in product([-1, 1], repeat=3):
    data = [i * x + j * y + k * z for x, y, z in cake]
    ans = max(ans, sum(sorted(data)[::-1][:M]))
print(ans)

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

const int maxn=2e5+7,p=1e9+7;
int c[maxn],n;
LL ans;

LL poww(int x,int y)
{
	LL ans=1,tmp=x;
	while(y) {
		if(y&1) ans=ans*tmp%p;
		tmp=tmp*tmp%p;
		y>>=1;
	}
	return ans;
}

bool cmp(int x,int y)
{
	return x>y;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",c+i);
	sort(c+1,c+n+1,cmp);
	for(int i=1;i<=n;++i) {
		ans+=1ll*c[i]*(i+1)%p;
		ans%=p;
	}
	ans*=poww(4,n-1);
	ans%=p;
	printf("%lld",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
// #define MOD 998244353
#define ll long long
#define db double
#define endl "\n"
#define INF 1000000000000000000
#define INF1 1000000000
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define debx cout<<" X "<<endl;
#define deby cout<<" Y "<<endl;
#define debz cout<<" Z "<<endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;
using namespace std;
 
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2)
        return (a*temp)%MOD;
    return temp;
}
ll _pow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp);
    if(b%2)
        return (a*temp);
    return temp;
}
ll mod_in(ll n){
    return mpow(n,MOD-2);
}
ll cl(ll a, ll b){
    if(a%b)
        return 1+a/b;
    return a/b;
}
ll dig(ll n){
    if(!n)
        return 0;
    return 1 + dig(n/10);
}
int main(){
    fastio
    ll h,w,n ;
    cin>>h>>w>>n ;
    h = max(h,w) ;
    ll ans = cl(n,h) ;
    cout<<ans ;
}

Measured memory_bytes: 764
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [[] for _ in range(M)]
for i in range(M):
  BC[i] = list(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

for i in BC:
  A.extend([i[1]]*i[0])
  if len(A) > 2*N:
    break
    
A = sorted(A,reverse=True)
print(sum(A[:N]))



Measured memory_bytes: 36780
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;

    
}
/*

*/


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc156/tasks/abc156_d
// math

import std.stdio: writeln, readf;

ulong binpow(ulong a, ulong b, ulong m) {
    a %= m;
    ulong res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
	}
    return res;
}

ulong binomial(ulong n, ulong k, ulong m) {
    ulong x = 1;
    ulong y = 1;
    foreach  (ulong i; 0..k) {
        x *= n-i;
        x %= m;
        y *= i+1;
        y %= m;
	}
    y = binpow(y, m-2, m);
    return (x*y)%m;
}

void main()
{

ulong mod = 10^^9+7;

ulong n, a, b;
"%s %s %s\n".readf(&n, &a, &b);

writeln((binpow(2, n, mod) - binomial(n,a, mod) - binomial(n,b, mod) - 1 + 3*mod)%mod);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll n,q,l,r;
	string s;
	cin >> n >> q >> s;
	ll a[n],ans[q];
	rep(i,n) a[i]=0;
	for(int i=0;i<n;i++){
		if(s[i]=='C' && s[i-1]=='A' && i!=0) a[i]++;
		if(i!=0) a[i]=a[i]+a[i-1];
	}
	cout << endl;
	rep(i,q){
		cin >> l >> r;
		ans[i]=a[r-1]-a[l-1];
	}
	rep(i,q) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b;
    cin >> a >> b;
    bool k = false;
    int x;
    if (b / 10==0) x = a*10+b;
    else if(b/100==0) x = a*100+b;
    else x = a*1000+b;
    for (int i = 1; i < 1000;i++){
        if (i*i==x) k = true;
    }
    if (k == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005;

struct node {
	long long a, b;
	bool operator < (node rhs) const {
		return b < rhs.b;
	}
} vec[N];

int n, perm[N], cir = 0;
long long veca[N];
bool vis[N], check = true, flag = false;


int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &vec[i].a);
	for (int i = 1; i <= n; i++) scanf("%lld", &vec[i].b);
	sort(vec + 1, vec + n + 1);
	for (int i = 1; i <= n; i++) veca[i] = vec[i].a;
	sort(veca + 1, veca + n + 1);
	
	for (int i = 1; i <= n; i++) {
		if (veca[i] > vec[i].b) check = false;
		if (i < n && veca[i + 1] <= vec[i].b) flag = true;
	}

	for (int i = 1; i <= n; i++) perm[i] = lower_bound(veca + 1, veca + n + 1, vec[i].a) - veca;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			cir++;
			for (int j = i; !vis[j]; j = perm[j]) vis[j] = true;
		}
	}

	if (cir > 1) flag = true;
	if (check && flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3072
def F(A,B,C):
  return A-C;
[A,B,C,K]=input().split();
A=int(A);
B=int(B);
C=int(C);
K=int(K);
a=min(A,K);
b=min(K-a,B);
c=K-a-b

print(F(a,b,c));

Measured memory_bytes: 9192
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int k = sc.nextInt();
        int n = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int d = i == 0 ? k - a[n - 1] + a[0] : a[i] - a[i - 1];
            ans = Math.min(ans, k - d);
        }
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
typedef long long ll;

int main() {
    int A,B,C; cin >> A >> B >> C;
    if (A < B) {
        if (B < C) {
            cout << "Yes" << endl; 
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define mem(x,y) for(int i=0;i<x.size()i++){ x[i]=y; }
#define fo(i, l, r)  for((i) = (l); (i) < (r); (i)++)
#define fok(i,r,k)  for((i) = 0; (i) < (r); (i)=i+(k))
#define mp make_pair
#define pb push_back
#define pi pair<int,int> 
#define pll pair<long long,long long>
#define vi vector<int> 
#define vl vector<long long>
#define vpl vector<pair<long long,long long>> 
#define vpi vector<pair<int,int>> 
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define br cout<<endl;
#define io { freopen("input.txt","r",stdin);  freopen("output.txt","w",stdout); }
ll modexpo(ll x,ll y,ll m){    x=x%m;if(y==0){return 1;}if(y%2==0){return modexpo(x*x,y/2,m); }else{    return  (x*modexpo(x*x,y/2,m))%m; }}
const int mod  = 1e9+7;
const int maxn = 1e5 + 10;

int a,b;
int main()
{
fastio; 

int i,j;
cin>>a>>b;
if(a>8 || b>8)
{
    cout<<":("<<endl;
}
else
cout<<"Yay!";

return 0;
}
//g++ -g a.cpp -o a.exe


Measured memory_bytes: 256
def wantp(n):

    q = []

    while n != lis[n]:
        q.append(n)
        n = lis[n]

    for i in q:
        lis[i] = n 

    return n


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

lis = [i for i in range(N)]
rank = [1] * N

for i in range(M):

    X,Y,Z = map(int,input().split())
    X -= 1
    Y -= 1

    px = wantp(X)
    py = wantp(Y)

    if px != py:

        if  rank[px] < rank[py]:
            lis[px] = py

        elif rank[px] == rank[py]:
            lis[px] = py
            rank[py] += 1

        else:
            lis[py] = px


ans = 0
for i in range(N):
    if lis[i] == i:
        ans += 1

print (ans)

Measured memory_bytes: 7860
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    if (b - a + 1 >= 2 * k) {
        rep(i, k) {
            cout << a + i << endl;
        }
        for (int i = k - 1; i >= 0; --i) {
            cout << b - i << endl;
        }
    } else {
        rrep(i, a, b + 1) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t x;
  cin>>x;
  int64_t ans=x/11L*2L;
  if(x%11L==0){}
  else if(x%11L<=6){
    ans++;
  }
  else ans+=2;
  cout<<ans;
}

Measured memory_bytes: 256
N_W=list(map(int,input().split()))
N=N_W[0]
W=N_W[1]
items=[]
for i in range(N):
	sets=list(map(int,input().split()))
	items.append(sets)
knapsack=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
	for w in range(1,W+1):
		if w-items[i][0]>=0:
			knapsack[i+1][w]=max(knapsack[i+1][w],knapsack[i][w],knapsack[i][w-items[i][0]]+items[i][1])
		else:
			knapsack[i+1][w]=max(knapsack[i+1][w],knapsack[i][w])
print(knapsack[-1][-1])

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

int main() {
  int N, sum=0;
  cin >> N;
  bool A[4]={false,false,false,false};
  char S[N];
  
  for(int i=0; i<N; i++){
    cin >> S[i];
    if(S[i] == 'P') A[0] = 1;
    else if(S[i] == 'W') A[1] = 1;
    else if(S[i] == 'G') A[2] = 1;
    else if(S[i] == 'Y') A[3] = 1;
  }
  
  sum = A[0]+A[1]+A[2]+A[3];
  
  if(sum == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2 >> b1 >> b2;
  ll p = (a1-b1) * t1;
  ll q = (a2-b2) * t2;
  if(p>0){
    p *= -1;
    q *= -1;
  }
  if(p+q==0) puts("infinity");
  else if(p+q<0) puts("0");
  else{
    ll s = (-1)*p/(p+q);
    ll t = (-1)*p%(p+q); 
    cout << s*2 + (t==0 ? 0 : 1) << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, K;
  std::cin >> N >> K;
  std::vector< ll > vl(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vl[i];
  }

  std::sort(vl.begin(), vl.end(), std::greater<>());
  ll sum = 0LL;
  for (ll i = 0; i < K; i++) {
    sum += vl[i];
  }

  print(sum);
  return 0;
}


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

int main(){
   int a,b;
   cin >> a >> b;
   if(a<b){
      cout << "a < b" <<endl;
   }
   if(a>b){
      cout << "a > b" <<endl;
   }
   if(a==b){
      cout << "a == b" <<endl;
   }
   return 0;
}

Measured memory_bytes: 3036
while True:
    N=int(input())
    if N==0:break
    t=[0]
    y=[0]
    lst=list(range(N))
    for k in lst[1:]:
        [x,d]=input().split()
        [x,d]=[int(x),int(d)]
        if d==0:
            t=t+[t[x]]
            y=y+[y[x]-1]
        if d==1:
            t=t+[t[x]-1]
            y=y+[y[x]]
        if d==2:
            t=t+[t[x]]
            y=y+[y[x]+1]
        if d==3:
            t=t+[t[x]+1]
            y=y+[y[x]]
    ht=0
    lt=0
    hy=0
    ly=0
    for f in range(N):
        if ht<t[f]:
            ht+=1
        if lt>t[f]:
            lt-=1
        if hy<y[f]:
            hy+=1
        if ly>y[f]:
            ly-=1
    print(hy-ly+1,ht-lt+1)

Measured memory_bytes: 7668