akhauriyash/Code-Regression huggingface dataset:
//problem:arc093_d
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;

namespace Fread{
	const int MAXN=1<<20;
	char buffer[MAXN],*S,*T;
	inline char getchar(){
		if(S==T){
			T=(S=buffer)+fread(buffer,1,MAXN,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
}
#ifdef ONLINE_JUDGE
	#define getchar Fread::getchar
#endif
inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MOD=1e9+7;
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
inline void add(int &x,int y){x=mod1(x+y);}
inline void sub(int &x,int y){x=mod2(x-y);}
int n,m,fac[(1<<16)+5],invf[(1<<16)+5],a[17],dp[17][1<<16];
inline int comb(int n,int k){
	if(n<k)return 0;
	return (ll)fac[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main() {
	fac[0]=1;
	for(int i=1;i<=(1<<16);++i)fac[i]=(ll)fac[i-1]*i%MOD;
	invf[1<<16]=pow_mod(fac[1<<16],MOD-2);
	for(int i=(1<<16)-1;i>=0;--i)invf[i]=(ll)invf[i+1]*(i+1)%MOD;
	assert(invf[0]==1);
	n=read(),m=read();
	for(int i=1;i<=m;++i)a[i]=read();
	if(m)reverse(a+1,a+m+1);
	dp[0][0]=1;
	for(int i=0;i<m;++i){
		for(int j=0;j<(1<<n);++j)if(dp[i][j]){
			add(dp[i+1][j],dp[i][j]);
			int t=(1<<n)-j-a[i+1];
			for(int k=0;k<n;++k)if(!((j>>k)&1)){
				add(dp[i+1][j|(1<<k)],(ll)dp[i][j]*fac[1<<k]%MOD*comb(t,(1<<k)-1)%MOD);
			}
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);++i){
		if(__builtin_popcount(i)&1)sub(ans,(ll)dp[m][i]*fac[(1<<n)-1-i]%MOD);
		else add(ans,(ll)dp[m][i]*fac[(1<<n)-1-i]%MOD);
	}
	ans=(ll)ans*(1<<n)%MOD;
	cout<<ans<<endl;
	return 0;
}

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

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);

#define LL long long

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

#define int long long

int n,k;
int per[5005];
int inp[5005];

vector<int> getCycle(int i) {
	vector<int> ret;
	int start = i;

	ret.push_back(start);
	
	int curr = per[i];
	while(curr != start) {
		ret.push_back(curr);
		curr = per[curr];
	}
	return ret;
}

#undef int
int main() {
	#define int long long
	cin >> n >> k;
	for(int i=1;i<=n;i++) {
		cin >> per[i];
	}
	LL maxV = -INF;
	for(int i=1;i<=n;i++) {
		cin >> inp[i];
		maxV = max(maxV, 1ll*inp[i]);
	}
	LL ans = maxV;

	for(int i=1;i<=n;i++) {
		vector<int> cy = getCycle(i);

		int cySz = cy.size();
		LL totSum = 0;
		for(int j=0;j<cy.size();j++) {
			totSum += 1ll * inp[cy[j]];
		}

		//cycle block
		LL calc = 0;
		int rem = k;
		if(totSum > 0) {
			int numCy = k/cySz;
			calc = 1ll * numCy * totSum;
			rem = k%cySz;
			ans = max(ans, calc);
		} 

		if(rem == 0) {
			//complete cycle
			//remove last
			calc = calc - totSum;
			rem = cySz;
			ans = max(ans, calc);
		}

		LL maxVal = -INF;
		LL preSum = 0;
		for(int j=1;j<cy.size() && rem > 0;j++) {
			//make move
			preSum += 1ll * inp[cy[j]];
			rem--;
			maxVal = max(maxVal, preSum);
		}
		if(rem > 0) {
			preSum += 1ll * inp[i];
			maxVal = max(maxVal, preSum);
		}

		ans = max(ans, calc + maxVal);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<map>
const int MAXN=1e7;
using namespace std;

int sum[MAXN],vis[MAXN];

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	int now=0;
	for(int i=1;i<=999;i++)
	{
		now+=i; 
		if((now-x) == (now+i+1-y))
		{
			printf("%d",now-x);
			return 0;
		}
	}
	return 0;
}

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

int n_query = 0;

int ask(int y1, int x1, int y2, int x2)
{
	++n_query;
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int score(int q)
{
	if (q > 2500) return 0;
	if (q >= 930) return max((int)(1e-8 + 125 - 3.2 * sqrt(q - 920)), 40);
	if (q >= 880) return (int)(1e-8 + 288 - 22 * sqrt(q - 870));
	return min(2860 - 3 * q, 300);
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if ((y2 - y1) * (x2 - x1) == cnt) {
		for (int i = y1; i < y2; ++i) {
			for (int j = x1; j < x2; ++j) {
				C[i][j] = 1;
			}
		}
		return;
	}

	bool y_first = false;
	if ((y2 - y1) % 2 == (x2 - x1) % 2) {
		if (y2 - y1 > x2 - x1) y_first = true;
	} else if ((y2 - y1) % 2 == 0) y_first = true;

	if (y_first) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}

//	if (aa != 69 && aa != 76 && aa != 78 && aa != 59 && aa != 63) return 0;

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


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    vector<int> abc(3);
    REPinit(i, 0, 3) {
        cin >> abc[i];
    }

    sort(CONTAINER_ALL(abc));

    cout << (abc[0] + (abc[1] + 10 * abc[2])) << endl;
    
    return 0;
}


Measured memory_bytes: 3540
n,y = map(int,input().split())
for i in range(n+1):
    if y//1000 - n - 9*i >= 0 and (y//1000 - n - 9*i)%4 == 0:
        if n - i - (y//1000 - n - 9*i)//4 >= 0:
            print(str(i)+" "+str((y//1000 - n - 9*i)//4)+" "+str(n - i - (y//1000 - n - 9*i)//4))
            break
    elif i == n:
        print("-1 -1 -1")

Measured memory_bytes: 3064
u = input().split()
c = int(u[0])
d = int(u[1])
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
print(lcm(c,d))

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	
	int h, w, x, y;
	
	while ((h != 0)||(w != 0)){
		scanf("%d %d", &h, &w);
		
		if ((h != 0)||(w != 0)){
			
			for (x = 0; x < h; ++x){
				
				for (y = 0; y < w; ++y){
					
					printf("#");
				}
				
				printf("\n");
			}
			
			printf("\n");
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1816
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Factorization
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_P = 35000;
const int MAX_N = 100000;
const int MAX_B = 29;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

bool primes[MAX_P + 1];
int cs[2][MAX_B + 1];

/* subroutines */

int gen_primes(int maxp, vi &pnums) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p]) {
      pnums.push_back(p);
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
    }
  for (; p <= maxp; p++)
    if (primes[p]) pnums.push_back(p);
  return (int)pnums.size();
}

bool prime_decomp(int n, vi &pnums, vpii& pds) {
  pds.clear();

  int pn = pnums.size();
  for (int i = 0; i < pn; i++) {
    int pi = pnums[i];
    if (pi * pi > n) {
      if (n > 1) pds.push_back(pii(n, 1));
      return true;
    }

    if (n % pi == 0) {
      int fi = 0;
      while (n % pi == 0) n /= pi, fi++;
      pds.push_back(pii(pi, fi));
    }
  }
  return false;
}

inline void addmod(int &a, int b) { a += b; a %= MOD; }
inline void mulmod(int &a, int b) { a = (int)((ll)a * b % MOD); }

/* main */

int main() {
  vi pnums;
  gen_primes(MAX_P, pnums);
  
  int n, m;
  scanf("%d%d", &n, &m);

  vpii pds;
  prime_decomp(m, pnums, pds);

  cs[0][0] = 1;
  int cur = 0, nxt = 1;
  for (int i = 0; i < n; i++) {
    memset(cs[nxt], 0, sizeof(cs[nxt]));

    for (int j = 0; j <= MAX_B; j++)
      if (cs[cur][j] > 0)
	for (int k = 0; j + k <= MAX_B; k++)
	  addmod(cs[nxt][j + k], cs[cur][j]);

    cur ^= 1, nxt ^= 1;
  }

  int ans = 1;
  for (int i = 0; i < pds.size(); i++)
    mulmod(ans, cs[cur][pds[i].second]);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> p(11);

int main()
{
    int n, ans = 0;
    cin>>n;

    REP(i,n) {
        cin>>p[i];
        ans += p[i];
    }
    ans -= *MAX_ELEMENT(p) / 2;

    cout<<ans<<endl;

    return 0;
}


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



void solve(){
  string s;
  cin >> s;
  int c=s.length();
  int count1=0; //010101...
  int count2=0; //101010...
  for(int i=0; i<c; i++){
     if (i%2==1) {
       if(s[i]!='0') count1++; 
     }
    else{
      if(s[i]!='1') count1++; 
    }
  }
  
    for(int i=0; i<c; i++){
     if (i%2==1) {
       if(s[i]!='1') count2++; 
     }
    else{
      if(s[i]!='0') count2++; 
    }
  }
  
  cout << min(count1, count2) << endl;
}

int main(){
  solve();
  return 0;
}
  


Measured memory_bytes: 512
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int a, b,c,k;
  cin>>a>>b>>c>>k;
  int cnt = 0;
  while(b<=a){
    cnt++;
    b*=2;
  }
  while(c<=b){
    cnt++;
    c*=2;
  }
  cout<<(cnt<=k?"Yes":"No")<<endl;
  return 0;
}

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

int main(){
int a, b, c;
cin >> a >> b >> c;
if (a == b && b == c){
    cout << '1' << endl;
}
else if (a == b || b == c || c == a) {
    cout << '2' << endl;
}
else {
    cout << '3' << endl;
}
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);
    REP(i, m) cin >> l[i] >> r[i];
    int ans = max(*min_element(r.begin(), r.end()) - *max_element(l.begin(), l.end()) + 1, 0);
    cout << ans << endl;
}


Measured memory_bytes: 1024
//gcc -std=gnu11 -O2 -o a.out main.c -lm

#include <stdio.h>

int main(void)
{
    int res;

    int w, h, n;
    int x[100];
    int y[100];
    int a[100];
    int i;

    int wL, hL;
    int wH, hH;

    // input
    res = scanf("%d%d%d", &w, &h, &n);
    for (i = 0; i < n; i++) {
        res = scanf("%d%d%d", &x[i], &y[i], &a[i]);
    }

    wL = 0;
    hL = 0;
    wH = w;
    hH = h;

    for (i = 0; i < n; i++) {
        switch (a[i]) {
        case 1: // x<xi
            if (wL < x[i]) {
                wL = x[i];
            }
            break;
        case 2: // x>xi
            if (wH > x[i]) {
                wH = x[i];
            }
            break;
        case 3: // y<yi
            if (hL < y[i]) {
                hL = y[i];
            }
            break;
        case 4: // y>yi
            if (hH > y[i]) {
                hH = y[i];
            }
            break;
        default:
            break;
        }
    }

    if (wL > wH) wL = wH;
    if (hL > hH) hL = hH;

    // output
    printf("%d\n", (wH - wL) * (hH - hL));

	return 0;
}



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

static const int INF = 2000000000;
int H, A[2000001];

void max_heapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;

    int largest = 0;
    if (l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if (r <= H && A[r] > A[largest])
        largest = r;

    if (largest != i) {
        swap(A[largest], A[i]);
        max_heapify(largest);
    }
}

int extract() {
    if (H < 1)
        return -INF;
    int maxv = A[1];
    A[1] = A[H--];
    max_heapify(1);
    return maxv;
}

void increase_key(int i, int key) {
    if (key < A[i])
        return;
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        swap(A[i], A[i / 2]);
        i /= 2;
    }
}

void insert(int key) {
    H++;
    A[H] = -INF;
    increase_key(H, key);
}

int main() {
    while (true) {
        string s;
        cin >> s;
        if (s == "insert") {
            int key;
            cin >> key;
            insert(key);
        } else if (s == "extract") {
            cout << extract() << endl;
        } else {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 6960
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;

int main() {
  string str;
  const char *p;
  int res = 0;
  
  while(cin >> str) {
    p = &str[0];
    for(; p-&str[0]<(int)str.size(); p++) {
      if(isdigit(*p)) {
	char *e;
	int a;
	a = strtol( p, &e, 10 );
	p = e;
	res += a;
      }
    }
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>

int main(void){
  long a,b,data;

  scanf("%ld %ld",&a,&b);

  //aのほうを大きくする
  if(a<b){
    data=a;
    a=b;
    b=data;
  }

  data=a;
  while(b!=0){
    data=b;
    b=a%b;
    a=data;
  }

  printf("%ld\n",data);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
const int maxn=2e5+10;
int f[maxn],a[maxn];
int find(int x){
    if(x==f[x])return x;
    return f[x]=find(f[x]);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)f[i]=i;
    for(int i=1; i<=m; i++){
        int a,b;
        cin>>a>>b;
        int A=find(a),B=find(b);
        if(A!=B)f[A]=B;
    }
    for(int i=1; i<=n; i++)a[find(i)]++;
    int ans=0;
    for(int i=1; i<=n; i++)ans=max(a[i],ans);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int a, b, ans = 0, socket = 1;
  cin >> a >> b;
  
  while(b - socket > 0)
  {
    socket += a - 1;
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    if(c[0] == c[1] || c[1] == c[2] || c[2] == c[3]) {
      System.out.println("Bad");
    } else {
      System.out.println("Good");
    }

  }

}


Measured memory_bytes: 21844
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  whilwee(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組fみ合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes";
    }else cout << "No";
}

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

int main()
{
    string s;
    cin>>s;

    int i;

    for(i=0; i<3; i++)
    {
        if(s[i] == '1')
            cout<<"9";
        else if(s[i] == '9')
            cout<<"1";
        else
            cout<<s[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,T;
    cin >> n >> T;
    int cost = INF;
    repi(i,n,0){
        int c,t;
        cin >> c >> t;
        if(t <= T){
            cost = min(cost,c);
        }
    }
    if(cost == INF){
        cout << "TLE" << endl;
    }else{
        cout << cost << endl;
    }
    return 0;
}

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


int main (){
    int N;
    string Z="Yes";
    cin >> N;
    vector<int> t(N+1);
    vector<int> x(N+1);
    vector<int> y(N+1);
    for(int i=0;i<N;i++){
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }
    t.at(N)=0;
    x.at(N)=0;
    y.at(N)=0;
    for(int i=0;i<N;i++){
        int T=t[i+1]-t[i];
        int X=x[i+1]-x[i];
        int Y=y[i+1]-y[i];
        if(T<0){
            T*=-1;
        }
        if(X<0){
            X*=-1;
        }
        if(Y<0){
            Y*=-1;
        }
        int z=T-X-Y;
        if(z%2!=0 || z<0){
            Z="No";
            break;
        }
        
    }
    cout << Z << endl;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}
const ll inf = 1LL<<60;



int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  string s;cin>>s;
  const ll mod =pow(10,9)+7;
  vector<vector<ll>> dp(s.size()+1,vector<ll>(13,0));

  dp[0][0]=1;
  for(ll i=0; i<s.size();i++){
    if(s[i]=='?'){
      for(int j=0;j<13;j++){
        for(int k=0;k<10;k++){
          dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
        }
      }
    }else{
      for(int j=0;j<13;j++){
        int k=s[i]-'0';
        dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
      }
    }
  }
  cout<<dp[s.size()][5]<<endl;
}


Measured memory_bytes: 16616
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define F first
#define S second
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define fast  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define E cout << '\n'
const int N = 1e5 + 5;
int dp[4][N], a[4];
signed main(){
   fast;
   int n, k;
   cin >> n;

   for(int i = 1; i <= n; ++i) {
    cin >> a[1] >> a[2] >> a[3];
    for(int j = 1; j <= 3; ++j) {
        for(int k = 1; k <= 3; ++k) {
            if(k == j)
                continue;
            dp[j][i] = max(dp[j][i], dp[k][i-1] + a[j]);
        }
    }
   }
  /* fo(i, 3)
    fo(j, n)
        cout << dp[i][j] << " \n"[j == n];*/
   cout << max(max(dp[1][n], dp[2][n]), dp[3][n]);






   return 0;
}


Measured memory_bytes: 2560
S = input()

if S == ('SUN'):
    print(7)
elif S == ('MON'):
    print(6)
elif S == ('TUE'):
    print(5)
elif S == ('WED'):
    print(4)
elif S == ('THU'):
    print(3)
elif S == ('FRI'):
    print(2)
elif S == ('SAT'):
    print(1)
else:
    print('入力に誤りがあります。SUN,MON,TUE,WED,THU,FRI,SATのいずれかを入力してください。')


Measured memory_bytes: 9144
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True


n,k=MI()
a=LI()
ans=sum([1 for i in a if i>=k])
for i in range(n):
    0
    
print(ans)

Measured memory_bytes: 51952
s = input()
t = input()

dp = [[0] * (len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

ans = ''
i, j = len(s), len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])

Measured memory_bytes: 113628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;
vector<vector<ll>> g(100010, vector<ll>());
ll n;
int main()
{
    cin >> n;

    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    vector<ll> dist1(n, -1);
    vector<ll> dist2(n, -1);
    queue<ll> que1;
    queue<ll> que2;
    dist1[0] = 0;
    dist2[n - 1] = 0;
    que1.push(0);
    que2.push(n - 1);
    while (!que1.empty())
    {
        ll v = que1.front();
        que1.pop();
        for (auto f : g[v])
        {
            if (dist1[f] != -1)
            {
                continue;
            }
            dist1[f] = dist1[v] + 1;
            que1.push(f);
        }
    }
    while (!que2.empty())
    {
        ll v = que2.front();
        que2.pop();
        for (auto f : g[v])
        {
            if (dist2[f] != -1)
            {
                continue;
            }
            dist2[f] = dist2[v] + 1;
            que2.push(f);
        }
    }
    ll cnt1 = 0;
    ll cnt2 = 0;

    for (ll i = 0; i < n; i++)
    {
        if (dist1[i] <= dist2[i])
        {
            cnt1++;
        }
        else
        {
            cnt2++;
        }
    }
    if (cnt1 > cnt2)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 11060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b;
  cin>>a>>b;
  cout << ((a*b)%2==0?"Even":"Odd")<<endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main() {
	int n;
	cin >> n;
	map<int, int> a;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}

	int cnt = 0;
	for (pair<int,int> p : a) {
		if (p.second > p.first) {
			cnt += p.second - p.first;
		} else if (p.second < p.first) {
			cnt += p.second;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}
//for (int j = 0; j < M; j++){}

int main() {
    string S;
    string moji;
    cin >> S;
    int mins = 100000;
    for (int i = 0; i < S.size()-2; i++){
        moji = S.substr(i,3);
        mins = min(mins, abs(stoi(moji) - 753));
    }
    cout << mins << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
   int N;
   int x[1000][3];
   int i;
   int xx;
   int tmp;
   scanf("%d", &N);
   for (i = 0; i<N; ++i) {
      scanf("%d %d %d", &x[i][0], &x[i][1], &x[i][2]);
      if (x[i][0] > x[i][1]) {
         tmp = x[i][1];
         x[i][1] = x[i][0];
         x[i][0] = tmp;
      }
      if (x[i][1] > x[i][2]) {
         tmp = x[i][2];
         x[i][2] = x[i][1];
         x[i][1] = tmp;
      }
      xx = x[i][0]*x[i][0] + x[i][1]*x[i][1];
      if (xx == x[i][2]*x[i][2]) {
         printf("YES\n");
      }
      else {
         printf("NO\n");
      }
   }
   return 0;
}

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

using namespace std;

int a[100000];

int main()
{
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int tmp = 0, cnt;
	for (int i = 1; i < n; i++)
		if (tmp < a[i] + a[i - 1])
		{
			tmp = a[i] + a[i - 1];
			cnt = i;
		}
	if (tmp < l)
		cout << "Impossible" << endl;
	else
	{
		cout << "Possible" << endl;
		for (int i = 1; i < cnt; i++)
			cout << i << endl;
		for (int i = n - 1; i > cnt; i--)
			cout << i << endl;
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll x; cin >> x;

  int const m = 130;

  rep2(a, -m, m) rep2(b, -m, m) {
    ll y = a*a*a*a*a;
    ll z = b*b*b*b*b;
    if (y - z == x) {
      cout << a << " " << b << "\n";
      return 0;
    }
  } 
  return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		int k = Integer.parseInt(str[2]);

		String matrix[][] = new String[h][w];
		ArrayList<Integer> list = new ArrayList<>();

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			boolean flag = false;

			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
				if (str[j].equals("#")) {
					flag = true;
				}
			}

			if (!flag) {
				list.add(i);
			}
		}

		int cur = 1;
		int ans[][] = new int[h][w];

		for (int i = 0; i < h; i++) {
			if (list.contains(i)) {
				continue;
			}

			boolean first = true;
			for (int j = 0; j < w; j++) {
				if (matrix[i][j].equals("#")) {
					if (first)
						first = false;
					else
						cur++;
				}
				ans[i][j] = cur;
			}
			cur++;
		}

		for (int i = 0; i < list.size(); i++) {
			for (int j = 0; j < w; j++) {
				if (list.get(i) == 0)
					ans[list.get(i)][j] = ans[list.get(i) + 1][j];
				else if (list.get(i) == h - 1)
					ans[list.get(i)][j] = ans[list.get(i) - 1][j];
				else {
					if (ans[list.get(i) - 1][0] != 0) {
						ans[list.get(i)][j] = ans[list.get(i) - 1][j];
					} else if (ans[list.get(i) + 1][0] != 0) {
						ans[list.get(i)][j] = ans[list.get(i) + 1][j];
					}
				}
			}
		}

		for (int i = list.size() - 1; i >= 0; i--) {
			if (ans[list.get(i)][0] != 0)
				continue;

			for (int j = 0; j < w; j++) {
				if (list.get(i) == 0)
					ans[list.get(i)][j] = ans[list.get(i) + 1][j];
				else if (list.get(i) == h - 1)
					ans[list.get(i)][j] = ans[list.get(i) - 1][j];
				else {
					if (ans[list.get(i) - 1][0] != 0) {
						ans[list.get(i)][j] = ans[list.get(i) - 1][j];
					} else if (ans[list.get(i) + 1][0] != 0) {
						ans[list.get(i)][j] = ans[list.get(i) + 1][j];
					}
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(ans[i][j] + " ");
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 57644
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    a=max(a,b);
    cout<<(c+a-1)/a;
}


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int K;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		K = Integer.parseInt(strArr[1]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		A = new int[N];
		String[] strArr = str.split(" ");
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(strArr[i]);
		}
		cnt++;
	}

	int[] A;

	public void solve() {
		// for (int i = 0; i < N; i++) {
		// System.out.println(A[i]);
		// }
		int ans = 0;
		for (int n = N; n > 0;) {
			ans++;
			if (n > K)
				n -= (K - 1);
			else
				n -= K;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 37724
#include <iostream>
using namespace std;
#define ll long long
#define SIZE 100000

ll Alst[SIZE];

int main(){
    int N;
    ll a;
    int cnt = 0;
    ll min_abs = 1145148101919;
    ll abs_sum = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        Alst[i] = a;
        if(a < 0) cnt++;
        min_abs = min(min_abs, abs(a));
        abs_sum += abs(a);
    }
    if(cnt%2 == 0){
        cout << abs_sum;
    }else{
        cout << (abs_sum - 2*min_abs);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[200005][3];
struct s{ll a,b,c;};
ll solve(ll index, ll n, ll state, s arr[])
{
if(index==n)
return 0;
if(dp[index][state]!=-1)
    return dp[index][state];
if(state == 0)
dp[index][state]=max(solve(index+1,n,1, arr)+arr[index].b, solve(index+1, n, 2, arr)+arr[index].c);
if(state == 1)
dp[index][state]=max(solve(index+1,n,0, arr)+arr[index].a, solve(index+1, n, 2, arr)+arr[index].c);
if(state == 2)
dp[index][state]=max(solve(index+1,n,1, arr)+arr[index].b, solve(index+1, n, 0, arr)+arr[index].a);
return dp[index][state];
}
int main() {
	// your code goes here
ll n, i;
memset(dp,-1,sizeof dp);
cin>>n;
s arr[n];
for(i=0;i<n;i++)
cin>>arr[i].a>>arr[i].b>>arr[i].c;
cout<<max(solve(0,n, 0,arr), max(solve(0,n,1,arr), solve(0,n,2,arr)))<<endl;
	return 0;
}

Measured memory_bytes: 15104
#include <cstdio>

const int maxn = 5e5 + 10;

int n, m, fnt, rar, s, x[maxn];
double ans, y[maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		int t, v;
		scanf("%d%d", &t, &v);
		while(fnt < rar && s - x[fnt] >= m - v) {
			ans -= y[fnt];
			s -= x[fnt++];
		}
		if(s > m - v) {
			ans -= y[fnt];
			y[fnt] -= (s - m + v) * y[fnt] / x[fnt];
			ans += y[fnt];
			x[fnt] -= (s - m + v);
		}
		s = m;
		double k = 1. * t * v;
		ans += k;
		while(fnt < rar && y[rar - 1] * v >= k * x[rar - 1]) {
			v += x[--rar];
			k += y[rar];
		}
		x[rar] = v;
		y[rar++] = k;
		printf("%.12f\n", ans / m);
	}
	return 0;
}

Measured memory_bytes: 17280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define NIL -1

struct Tree{
	int left,right,parent;
};

Tree *T;
int *S,*D;
int n;
int max = -1;

void depth(int n,int d){
	if(n == NIL) return;
	D[n] = d;
	depth(T[n].left,d+1);
	depth(T[n].right,d+1);
}

int height(int n){
	int h1 = 0,h2 = 0;
	if(T[n].left != NIL) 
		h1 = height(T[n].left) + 1;
	if(T[n].right != NIL) 
		h2 = height(T[n].right) + 1;
	return (h1 > h2 ? h1 : h2); 
}

void print(int h,int r){
	int deg;
	for(int i = 0;i < n;i++){
		deg = 0;
		cout << "node " << i << ": ";
		cout << "parent = " << T[i].parent << ", ";
		if(i != r){
			if(T[T[i].parent].left == i){
				cout << "sibling = " << T[T[i].parent].right << ", ";
			}else{
				cout << "sibling = " << T[T[i].parent].left << ", ";
			}
		}else{
			cout << "sibling = -1, ";
		}
		if(T[i].left != NIL) deg++;
		if(T[i].right != NIL) deg++;
		cout << "degree = " << deg << ", ";
		cout << "depth = " << D[i] << ", ";
		cout << "height = " << height(i) << ", ";
		if(T[i].parent == NIL){
			cout << "root" << endl;
		}else if(T[i].left != NIL || T[i].right != NIL){
			cout << "internal node" << endl;
		}else{
			cout << "leaf" << endl;
		}
	}	
}

int main(){
	cin >> n;
	T = new Tree[n];
	D = new int[n];
	int a,l,r;

	for(int i = 0;i < n;i++){
		T[i].left = T[i].right = T[i].parent = NIL;
	}

	for(int i = 0;i < n;i++){
		cin >> a >> l >> r;
		if(l != -1){
			T[a].left = l;
			T[T[a].left].parent = a;
		}
		if(r != -1){
			T[a].right = r;	
			T[T[a].right].parent = a;
		}
	}

	int root;
	int max = -1;
	for(int i = 0;i < n;i++){
		if(T[i].parent == NIL) root = i;
	}
	depth(root,0);
	for(int i = 0;i < n;i++){
		if(D[i] >= max) max = D[i];
	}
	print(max,root);
	return 0;
}

Measured memory_bytes: 1192
import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();

      int a = 1;
      int b = 2;
      int c = 3;

      if (A==a) {
        a = 0;
      } else if (A==b) {
        b = 0;
      } else if (A==c) {
        c = 0;
      }
      if (B==a) {
        a = 0;
      } else if (B==b) {
        b = 0;
      } else if (B==c) {
        c = 0;
      }
      System.out.println(a+b+c);

    }      
}

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

int main()
{
  double a, b, c, d, e, f, x, y;
  while(cin >> a >> b >> c >> d >> e >> f){
    x = (c * e - b * f) / (a * e - b * d);
    y = (a * f - c * d) / (a * e - b * d);
    x = ((c * e - b * f) == 0 && (a * e - b * d) < 0) ? -x : x;
    y = ((a * f - c * d) == 0 && (a * e - b * d) < 0) ? -y : y;      
    cout << fixed << setprecision(3) << x << ' ' << y << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <list>
#include <cmath>
 
using namespace std;
 
const double pi = 3.14159265358979323846;
const int mod = 1000000007;
 
int main(){
  int N;
 
  cin >> N;
  cout << (int)pow(floor(sqrt(N)),2) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sz 100100
ll a[sz];
ll ans[sz];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n, k; cin >> n >> k;
	for (ll i = 0; i < n; ++i)
		cin >> a[i];
	ans[0] = 0;
	for (ll i = 1; i < n; i++)
	{
		ans[i] = ans[i - 1] + abs(a[i - 1] - a[i]);
		for (ll j = i - 2; j >= i - k && j > -1; j--)
			ans[i] = min(ans[i], ans[j] + abs(a[j] - a[i]));
	}
	cout << ans[n - 1];
	return 0;
}

Measured memory_bytes: 5172
#!/usr/bin/env python3
s = input()[::-1]
n = len(s)
cs = [0] * (n + 1)
ten = 1
for i in range(n):
    cs[i + 1] = int(s[i]) * ten % 2019
    ten = ten * 10 % 2019
for i in range(n):
    cs[i + 1] = (cs[i + 1] + cs[i]) % 2019
cnt = [0] * 2019
for i, x in enumerate(cs):
    cnt[x] += 1
ans = sum(x * (x - 1) // 2 for x in cnt)
print(ans)


Measured memory_bytes: 16200
c_500 = int(input())
c_100 = int(input())
c_050 = int(input())
x = int(input())

ans = 0
for u_500 in range(0, c_500+1):
    for u_100 in range(0, c_100+1):
        for u_050 in range(0, c_050+1):
            if (u_500 * 500 + u_100 * 100 + u_050 * 50) == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int a,b;
  char s[11],t[11];
  char u[11];
  
  scanf("%s %s\n%d %d\n%s",s,t,&a,&b,u);
  
  int x=1;
  int i;
  
  for(i=0;i<=10;i++){
    if(u[i]==NULL){
      if(s[i]!=NULL){
        x=0;
      }
      break;
    }
    if(s[i]!=u[i]){
      x=0;
    }
  }
  
  if(x==1){
    a=a-1;
  }else{
    b=b-1;
  }
  
  printf("%d %d",a,b);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int x, a;
    cin >> x >> a;
    int ans;
    if(x < a) ans = 0;
    else ans = 10;
    cout << ans << endl;

    return 0;
}

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

int main(){
    int a, b, c, d=1 , k, ans;
    cin >> a >> b >> c >> k;
    for(int i=0 ; i<k ; i++){
        d *= 2;
    }
    if(max({a,b,c})==a){
        ans = a*d + b + c;
    }else if(max({a,b,c})==b){
        ans = a + b*d + c;
    }else{
        ans = a + b + c*d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
p, q = 0, 0

s = list(range(1, N+1))
for i in range(N):
    p += s.index(P[i]) * math.factorial(N-i-1)
    s.remove(P[i])

s = list(range(1, N+1))
for i in range(N):
    q += s.index(Q[i]) * math.factorial(N-i-1)
    s.remove(Q[i])

print(abs(p-q))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}
ll w[300050], cnt[300050];
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n = next<ll>();
	ll sum = 0;
	for(int i = 0; i < n; i++) cin>>w[i], cnt[w[i]]++;
	for(int i = 1; i < 200050; i++) sum += cnt[i]*(cnt[i]-1)/2;
	for(int i = 0; i < n; i++) cout<<sum-cnt[w[i]]+1<<endl;
	return ~~(0-0);
}


Measured memory_bytes: 5248