akhauriyash/Code-Regression huggingface dataset:
/*
AtCoder Grand Contest 026 A - Colorful Slimes 2
結果:
*/

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define max(x,y)(x<y?y:x)
#define int long long

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

//尺取法
//scanf("%d", &N);
//for (i; i < N; ++i) {
//	scanf("%d", &A[i]);
//	if (b[A[i]] == 1) {
//		ans = max(ans, i - j);
//		while (b[A[i]] == 1) {
//			b[A[j++]] = 0;
//		}
//	}
//	b[A[i]] = 1;
//}
//ans = max(ans, i - j);
//printf("%d\n", ans);

//文字列の最大出現
//static int N, i, j, ans;
//static int A, B;
//static char A[50][51];
//static int cnt, max;
//char *max_name;
//
//scanf("%d", &N);
//for (i = 0; i < N; i++) {
//	scanf("%s", A[i]);
//}
//max_name = A[0];
//for (i = 0; i < N; i++) {
//	cnt = 0;
//	for (j = 0; j < N; j++) {
//		if (strcmp(A[i], A[j]) == 0) {
//			cnt++;
//		}
//		if (cnt > max) {
//			max = cnt;
//			max_name = A[i];
//		}
//	}
//}
//printf("%s\n", max_name);

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int main() {
	static int N, i, j, ans = 0;
	//static int AN, BN, A[100] = {}, B[100] = {}, i, j, ans;
	static int A[100];
	//static int A, B, C;
	//static int a[31] = {}, b[31] = {}, cnt = 0;
	//static char A[50][51];
	static int cnt = 0;
	//char *max_name;
	//static int ans;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (i > 0 && A[i] != A[i - 1]) {
			cnt = 0;
		}
		else if (i > 0 && A[i] == A[i - 1])
		{
			cnt++;
			ans = ans + cnt % 2;
		}

	}

	//ans = cnt;
	//qsort(A, N, sizeof(int), compare);

	//ans = ;
	printf("%d\n", ans);
	//printf("%s\n", max_name);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


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

int main() {
    long long H, W;
    cin >> H >> W;
    if (W == 1 || H == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (W % 2 == 0) {
        cout << H * (W / 2) << endl;
    } else {
        cout << H * (W / 2) + (H + 1) / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

const int INDEFINITE = -1;

int dp(int N, int m[]) {
    if (m[N] != INDEFINITE) {
        return m[N];
    }

    if (m[N] == 0) {
        return m[N];
    }

    if (1 == N) {
        m[N] = 1;
    } else if (2 == N) {
        int before1 = dp(N - 1, m);
        m[N] = before1 + 1;
    } else {
        int before1 = dp(N - 1, m);
        int before2 = dp(N - 2, m);
        if (before1 == 0 && before2 == 0) {
            m[N] = 0;
        } else if (before1 == 0) {
            m[N] = before2;
        } else if (before2 == 0) {
            m[N] = before1;
        } else {
            m[N] = (before1 + before2) % 1000000007;
        }
    }

    return m[N];
}

int main() {
    int N, M; cin >> N >> M; // 1 <= N <= 10^5
    int a[M + 1];
    for (int i = 1; i <= M; ++i) {
        cin >> a[i];
    }

    int m[N + 1];
    for (int i = 1; i <= N; ++i) {
        m[i] = INDEFINITE;
    }

    for (int i = 1; i <= M; ++i) {
        m[a[i]] = 0;
    }

    cout << dp(N, m) << endl;

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



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

  int num,max = -INF;
  if(X == 1)cout<<1;
  else{
    for(int i = 1;i <= 33;i++){
         for(int t = 2;t < 11;t++){
            num = pow(i,t);
            if(num >= max && num <= X)max = num;
          }
    }
    cout<<max;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=1005;
typedef long double lb;
int vis[N],x[N],y[N],r[N],n;
lb dis[N];
lb Dis(int i,int j){
	lb res=sqrt((x[i]-x[j])*1.0*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j]));
	return std::max((lb)0,res-r[i]-r[j]);
}
void dij(int s){
	for (int i=1;i<=n+1;i++) dis[i]=10000000000000;
	for (int i=1;i<=n+2;i++){
		int t=-1;
		for (int j=0;j<=n+1;j++)
			if ((dis[j]<dis[t] || t==-1) && !vis[j]) t=j;
		vis[t]=1;
		if (t==1) break;
		for (int j=0;j<=n+1;j++)
			if (dis[j]>dis[t]+Dis(j,t)) dis[j]=dis[t]+Dis(j,t);
	}
}
int main(){
	scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
	scanf("%d",&n);
	for (int i=2;i<=n+1;i++)
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
	dij(0);
	printf("%.10Lf",dis[1]);
} 

Measured memory_bytes: 256
def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 0

    for i in range(1, n-1):
        if  (p[i-1] < p[i] and p[i] < p[i+1]) \
            or (p[i-1] > p[i] and p[i] > p[i+1]):
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,m,y;
string s;
vll par;
vll sz;
// <------------- Implement Functions Here ----------> //

ll find(ll x) {
	if(x == par[x]) return x;
	return par[x] = find(par[x]);
}

void merge(ll x, ll y) {
	if(sz[x] < sz[y]) swap(x,y);
	sz[x]+=sz[y];
	par[y] = x;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	vpll X,Y;
	for(ll i=0;i<n;i++) {
		cin >> x >> y;
		X.pb({x,i});
		Y.pb({y,i});
	}
	sort(all(X));
	sort(all(Y));

	vector<pair<ll,pll>> edge;
	for(ll i=1;i<n;i++) {
		edge.pb({X[i].f - X[i-1].f,{X[i-1].s,X[i].s}});
	}
	for(ll i=1;i<n;i++) {
		edge.pb({Y[i].f - Y[i-1].f,{Y[i-1].s,Y[i].s}});
	}
	sort(all(edge));
	par = vll(n);
	sz = vll(n);
	for(ll i=0;i<n;i++) par[i] = i,sz[i] = 1;
	
	/*for(auto itt : edge) {
		cout<<itt.f<<" "<<itt.s.f<<" "<<itt.s.f;newl;
	}*/
	
	ll sum = 0, cou = n-1;
	for(ll i=0;i<edge.size() && cou;i++) {
		ll x = edge[i].s.f;
		ll y = edge[i].s.s;

		ll u = find(x);
		ll v = find(y);
		//cout<<x<<" "<<y<<" "<<u<<" "<<v;newl;
		if(u!=v) {
			cou-- ;
			//cout<<edge[i].f<<" "<<edge[i].s.f<<" "<<edge[i].s.s;newl;
			sum+=edge[i].f;
			merge(u,v);
			//DISP(par);
		}
	}

	cout<<sum;
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 248456
def unhappy_hacking(s: str) -> str:
    display = ''

    for key in s:
        if key == '0':
            display += '0'
        elif key == '1':
            display += '1'
        else:  # Backspace
            display = display[:-1]

    return display


if __name__ == "__main__":
    s = input()
    ans = unhappy_hacking(s)
    print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;



int main() {
	int N; cin >> N;
	vector<int> dp(N+1, 1e9);
	dp[0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 1; j+i <= N; j *= 6)dp[i + j] = min(dp[i + j], dp[i] + 1);
		for (int j = 1; i+j <= N; j *= 9)dp[i + j] = min(dp[i + j], dp[i] + 1);
	}
	cout << dp[N] << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin >> n;
	map<int,int> mp;
	for(int i = 0;i<n;i++){
	    int temp;
	    cin >> temp;
	    mp[temp]++;
    }
	auto it=mp.end();
	int max = (--it)->first;
	vector<bool> dp(max+1,true);
	for(auto it=mp.begin();it!=mp.end();it++){
	    int num = it->first;
	    if(dp[num] == false)continue;
	    if(it->second != 1)dp[num] = false;
	    for(int i = 2*num;i<dp.size();i+=num)dp[i] = false;
	}
	int count = 0;
	for(auto it=mp.begin();it!=mp.end();it++){
	    if(dp[it->first])count++;
	}
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 13036
#include <stdio.h>
#include <string.h>

int main(void)
{
  int a, i, j;
  int len;
  char S[150], T[150];
  char tmp;

  scanf("%s", S);
  scanf("%s", T);

  len = strlen( S );

  for (i = 0;i < len; i++) {
    if (strcmp(S,T)==0) {
      printf("Yes");
      return 0;
    } else {
      tmp = S[0];
      for (j = 0; j < len - 1; j++) {
        S[j] = S[j+1];
      }
      S[len-1] = tmp;
    }
  }
  printf("No");
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i,n)cin >> x[i];

	ll ans = 0;
	for(int i = 0;i < n-1;i++)
	{
		int div = x[i+1]-x[i];
		ans += min(div*a,b);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int n,k,x,y;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>x>>y;
	if(k>=n)cout<<n*x;
	else cout<<(k*x)+((n-k)*y);
		return 0;
}

Measured memory_bytes: 256
function Main(input){
	input=input.trim().split("\n");
	let x;
	for (let i = 0; i < (input.length-1); i++){
		x = parseInt(input[i], 10);
		console.log("Case %d: %d", i+1, x);
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  REP(i, M)
  cin >> B[i];
  int A[N][M];
  REP(i, N)
  REP(j, M)
  cin >> A[i][j];
  int ans = 0;
  REP(i, N)
  {
    int val = 0;
    REP(j, M)
    val += A[i][j] * B[j];
    val += C;
    if (0 < val)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

int main(void) {
	int a=0;
	char s[3],rs[3];
	for (int i = 0; i < 3;i++) {
		scanf("%c",&s[i]);
	}
	getchar();
	for (int i = 0; i < 3; i++) {
		scanf("%c", &rs[i]);
	}
	for (int i = 0; i < 3; i++) {
		if (s[i]==rs[i]) {
			a += 1;
		}
	}
	printf("%d",a);

	//system("pause");
	return 0;
}

Measured memory_bytes: 384
import math
n, d = [int(i) for i in input().split()]

x = [[int(i) for i in input().split()] for _ in range(n)]
counter = 0
func = lambda x: x**2
func2 = lambda x,y:x-y

for i, j in enumerate(x[:-1]):
  for k in x[i+1:]:    
    
    norm = sum(list(map(func, list(map(func2, j, k)))))

    if math.sqrt(norm) % 1 == 0:
      counter += 1
      
print(counter)



Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define INFTY 999999999
unsigned long long  count;

void merge(int *A,int left,int mid,int right){
	int n1=(mid-left);
	int n2=(right-mid);
	int *L,*R;
	L=(int*)malloc(sizeof(int)*(n1+1));
	R=(int*)malloc(sizeof(int)*(n2+1));
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}

	L[n1]=INFTY;
	R[n2]=INFTY;
	int i=0,j=0;
	for(int k=left;k<(right);k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;

		}else{
			A[k]=R[j];
			j++;
			count+=(n1-i);
		}
		
	}
	free(L);
	free(R);
}

void mergeSort(int *A,int left,int right){
	int mid;
	if((left+1)<right){
		mid=((left+right)/2);
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

void calc(int *A,int N){	
	count=0;
	mergeSort(A,0,N);
	printf("%llu\n",count);
}

int main(){
	int N;
	int *A;
	
	scanf("%d",&N);
	A=(int*)malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}

	calc(A,N);
	//printf("%d\n",calc(A,N));

	return 0;
}


Measured memory_bytes: 3028
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
	int n;
	while(cin>>n,n){
		vector<vector<string> >in(n,vector<string>(6));
		rep(i,n)rep(j,6)cin>>in[i][j];
		int a[]={3,1,0,5,4,2};
		rep(i,n){
			if(in[i][1]!="Blue"&&in[i][4]!="Blue")
			while(in[i][0]!="Blue"){
				vector<string>tmp(6);
				rep(j,6)tmp[j]=in[i][a[j]];
				in[i]=tmp;
			}
			
		}
		int b[]={4,0,2,3,5,1};
		rep(i,n){
			while(in[i][0]!="Blue"){
				vector<string>tmp(6);
				rep(j,6)tmp[j]=in[i][b[j]];				
				in[i]=tmp;
			}
		}
		UnionFind uf(n);
		int co=0;
		rep(i,n)rep(j,n)if(i!=j&&in[i][5]==in[j][5]){
			int c[]={0,3,1,4,2,5};
			while(in[i][1]!=in[j][1]){
				vector<string>tmp(6);
				rep(k,6)tmp[k]=in[j][c[k]];
				in[j]=tmp;
			}
			bool h=true;
			rep(k,6)if(in[i][k]!=in[j][k])h=false;
			if(h){
				if(!uf.findSet(i,j))co++;
				uf.unionSet(i,j);
			}
		}
		cout<<co<<endl;
	}
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int store[n]; 
	int total = 0;
	int max = 0;
	forn(i, n){ scanf("%d", &store[i]);
	 total += store[i]; uax(max, store[i]);}
	int count[max + 1]{0};
	forn(i, n) {
		count[store[i]]++;
	}
	int breakq = -1;
	int break2 = -1;
	int sum = 0;
	for1(i, max) {
		sum += count[i];
		if(sum == n/2) {
			breakq = i;
			break;
		}
	}
	if(breakq != -1) {
		for(int i = breakq + 1; i <= max; i++) {
			if(count[i]) {
				break2 = i;
				break;
			}
		}
	}
	if(breakq != -1) {
		int x = break2 - breakq;
		printf("%d", x);
	} else {
		printf("%d", 0);
	}








	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
    int n;
    cin >> n;
    vector<string> v;
    string s;
    map<string,int> m;
    rep(i, n){
        cin >> s;
        v.push_back(s);
    }
    rep(i,n){
        sort(v[i].begin(),v[i].end());
    }
    rep(i,n){
        if(m.count(v[i])==1){
            m[v[i]]++;
        }
        else{
            m[v[i]] = 1;
        }
    }
    ll result = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr){
        if(itr->second>=2)
            result += combination(itr->second,2);
    }
    cout << result << endl;
}

Measured memory_bytes: 18164
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


Measured memory_bytes: 2048
def cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p *= n - i
        p %= mod
        q *= i + 1
        q %= mod
    # 1/q!の逆元をかける(= q! ^ (mod-2) % mod)
    return p * pow(q, mod - 2, mod)


N, a, b = map(int, input().split())
MOD = 10**9+7

print((pow(2, N, MOD) - cmb(N, a, MOD)-cmb(N, b, MOD)-1) % MOD)


Measured memory_bytes: 38512
#include <bits/stdc++.h> 
  
#define ll long long 
  
using namespace std; 
  
vector<ll> v; 
  
ll dp[10005][105][2],d,mod=1000000007; 

ll solve(ll n,ll sum,ll flag)
{
	if(n==v.size())
	{
		if(sum==0)
			return 1;
		else return 0;
	}
	if(dp[n][sum][flag]!=-1)
		return dp[n][sum][flag]%mod;
	
	 ll x=0,en=-1;
	 
	 if(flag==1)
		 en=v[n];
	 else
		 en=9;
	
	 for(ll i=0;i<en;i++)
		 x=(x%mod+solve(n+1,((sum%d)+i)%d,0)%mod)%mod;
	 x=(x%mod+solve(n+1,((sum%d)+en)%d,flag)%mod)%mod;
	return (dp[n][sum][flag]=x);
}


ll CountNum(string n) 
{ 
    v.clear();
    int sz=n.length();
	for(int i=0;i<sz;i++)
		v.push_back(n[i]-'0');    
      
    memset(dp, -1, sizeof(dp)); 
    return solve(0, 0, 1); 
} 
    
int main() 
{ 
    string k; 	
	cin>>k>>d;
	ll ans=CountNum(k)-1;
	if(ans==-1)
		ans=mod-1;
    cout << ans << endl; 
    return 0; 
} 

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int cntT = (C+B-1) / B, cntA = (A+D-1) / D;
  if(cntT<= cntA){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3528
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,K; cin >> N >> K;
    ll ans = 0;
    for(int b = 1; b <= N; b++) {
        ans += N/b * max(0,b-K);
        ans += max(0,N%b-K+1);
    }
    if(K == 0) ans -= N;
    cout << ans << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (((a * b) % 2) == 1)
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define N 800005
#define P 1000000007
#define ll long long
using namespace std;
int n,rd[N],vis[N],fa[N],s1[N],s2[N],a[N],cnt,rt[N],flag[N];
int fst[N],to[N*2],nxt[N*2],l;
int inv[N],fac[N],ifac[N];
vector<int>v[N];
struct T
{
	int x,y;
};
int C(int x,int y)
{
	return (ll)fac[y]*ifac[x]%P*ifac[y-x]%P;
}
T operator+(T a,T b)
{
	return (T){(a.x+b.x)%P,a.y};
}
T operator*(T a,T b)
{
	return (T){(ll)a.x*b.x%P*C(a.y,a.y+b.y)%P,a.y+b.y};
}
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
	rd[x]++;rd[y]++;
}
void dfs(int x)
{
	if (vis[x]) return;
	vis[x]=1;
	a[++cnt]=x;
	for (int i=fst[x];i;i=nxt[i])
		dfs(to[i]);
}
void Dfs(int x)
{
	rd[x]=-1;
	for (int i=fst[x];i;i=nxt[i])
		if (rd[to[i]]!=-1)
		{
			fa[x]=to[i];rd[to[i]]--;
			if (rd[to[i]]==1) Dfs(to[i]);
		}
}
T solve(int x)
{
	T ans=(T){1,0};
	for (int i=0;i<v[x].size();i++)
		ans=ans*solve(v[x][i]);
	ans.y++;
	return ans;
}
T work(int x)
{
	cnt=0;
	dfs(x);
	for (int i=1;i<=cnt;i++)
	{
		if (rd[a[i]]==1)
			Dfs(a[i]);
	}
	int tmp;
	for (int i=1;i<=cnt;i++)
	{
		if (rd[a[i]]!=-1)
		{
			tmp=a[i];
			for (int j=fst[a[i]];j;j=nxt[j])
				if (rd[to[j]]!=-1)
					if (s1[a[i]]) s2[a[i]]=to[j];
					else s1[a[i]]=to[j];
		}
	}
	//puts("ok");
	int lst=tmp;fa[tmp]=s2[tmp];
	for (int i=s1[tmp];i!=tmp;)
	{
		//cout<<i<<' '<<tmp<<endl;
		fa[i]=lst;
		lst=i;
		i=s1[i]+s2[i]-fa[i];
		//swap(lst,tmp);
		//tmp=s1[lst]+s2[lst]-tmp;
	}
	for (int i=1;i<=cnt;i++)
		flag[a[i]]=0;
	int ly=0;
	for (int i=1;i<=cnt;i++)
	{
		for (int j=fst[a[i]];j;j=nxt[j])
			if (fa[a[i]]>to[j])
			{
				//cout<<fa[a[i]]<<' '<<a[i]<<' '<<to[j]<<endl;
				v[a[i]].push_back(to[j]);flag[to[j]]=1;
			}
		//if (flag) rt[++ly]=i;
	}
	T A1=(T){1,0};
	for (int i=1;i<=cnt;i++)
	{
		if (!flag[a[i]])
			A1=A1*solve(a[i]);
	}
//	cout<<A1.x<<' '<<A1.y<<endl;
	
	for (int i=1;i<=cnt;i++)
		swap(s1[a[i]],s2[a[i]]);
	for (int i=1;i<=cnt;i++)
	{
		if (rd[a[i]]!=-1)fa[a[i]]=0;
		v[a[i]].clear();
	}
	for (int i=1;i<=cnt;i++)
		flag[a[i]]=0;
	lst=tmp;fa[tmp]=s2[tmp];ly=0;
	for (int i=s1[tmp];i!=tmp;)
	{
		fa[i]=lst;
		lst=i;
		i=s1[i]+s2[i]-fa[i];
	}
	ly=0;
	for (int i=1;i<=cnt;i++)
	{
		for (int j=fst[a[i]];j;j=nxt[j])
			if (fa[a[i]]>to[j]) v[a[i]].push_back(to[j]),flag[to[j]]=1;
	}
	T A2=(T){1,0};
	for (int i=1;i<=cnt;i++)
	{
		if (!flag[a[i]])
		A2=A2*solve(a[i]);
	}
	
	return A1+A2;
}
int main()
{
//	freopen("3.in","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n*2;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y+n);
	}
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	for (int i=2;i<=n*2;i++)
	{
		inv[i]=(ll)(P-P/i)*inv[P%i]%P;
		fac[i]=(ll)fac[i-1]*i%P;
		ifac[i]=(ll)ifac[i-1]*inv[i]%P;
	}
	//特判 
	for (int i=1;i<=n*2;i++)
		if (rd[i]==0)
		{
			puts("0");
			return 0;
		}
	T Ans=(T){1,0};
	for (int i=1;i<=n;i++)
	{
		if (!vis[i])
			Ans=Ans*work(i);
	}
	printf("%d\n",Ans.x);
}

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



int main() {
    long long int h;
    cin >> h;
    int count = 0;
    while(true){
        if (h == 1) break;
        h /= 2;
        count++;
    }
    long long int ans = 0;
    for(int i=0; i<count+1; i++){
        ans += (long long)std::pow(2,i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    string s;
    cin >> s;
    int n = s.size();
    stack<char> st;
    int cnt = 0;
    rep(i, n) {
        if (s[i] == 'S') st.push(s[i]);
        else if (!st.empty()) st.pop();
        else cnt++;
    }
    cout << st.size() + cnt << '\n';
}


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

int f(int n) {
  int ret = 0;
  while(n % 2 == 0) {
    n /= 2;
    ret++;
  }
  return ret;
}

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int now;
    cin >> now;
    now = f(now);
    a[i] = now;
  }
  sort(a.begin(), a.end());
  cout << a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    ll maxA = -1e18, minA = 1e18, maxB = -1e18, minB = 1e18;
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        ll a = x - y, b = x + y;
        maxA = max(maxA, a);
        minA = min(minA, a);
        maxB = max(maxB, b);
        minB = min(minB, b);
    }
    cout << max(maxA - minA, maxB - minB) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int saitekiapple(int taste[],int N){
    int saiteki=0;
    double jud;
    int i;

    for(i = 0;i < N;i++){
        jud=pow((double)taste[i],2.0);
        if(pow((double)taste[saiteki],2.0)>=jud){
            saiteki=i;
        }
    }

    return saiteki;
}

int main(void){
    //char input1[11],input2[11];
    int N;
    int L;

    //fgets(input1,10,stdin);
    //sscanf(input1,"%d",&N);
    //fgets(input2,10,stdin);
    //sscanf(input2,"%d",&L);

    scanf("%d",&N);
    scanf("%d",&L);

    int taste[N];

    int i;

    for(i = 0;i < N;i++){
        taste[i] = L + i + 1 - 1;
    }

    int saiteki;
    saiteki=saitekiapple(taste,N);

    int applepietaste=0;

    for(i = 0;i<N;i++){
        applepietaste +=taste[i];
    }
    
    applepietaste = applepietaste - taste[saiteki];

    printf("%d",applepietaste);

    return 0;
}



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

int main() {
	int N, X, T;
	cin >> N >> X >> T;

	int ans = N / X;
	if(N % X != 0) ans++;
	ans *= T;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
   int n;
   cin >> n;
   vi a(n),b(n);
   rep(i,n-1) cin >> a[i];

   rep(i,n-1){
       b[a.at(i) - 1] += 1; 
   }

   rep(i,n) cout << b[i] << endl; 

   return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll base = 0;
  base = n % b;
  ll res = 0;
  if(n < b){
    res = (a * n) / b;
    res -= a * (n / b);
  }
  else{
    ll now = 0;
    now = n - base - 1;
    res = (a * now) / b;
    res -= a * (now / b);
  }
  cout << res << endl;
  return 0;
}

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


int main()
{
	int a,b;
	cin >> a >> b;
	int maxn = a+b;
	if(a-b>maxn)maxn = a-b;
	if(a*b>maxn)maxn = a*b;
	printf("%d\n",maxn);
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    TreeSet<Integer> set;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'B') {
                if(sb.length() > 0) sb.delete(sb.length()-1, sb.length());
            }else{
                sb.append(S.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

}

Measured memory_bytes: 35504
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(range(1, K + 1)):
        n = pow(K // k, N, mod=P)
        for kk in range(2 * k, K + 1, k):
            n -= n_gcd[kk]
        n_gcd[k] = n % P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11060
#include<iostream>
#include<algorithm>
#include<string>
#define MAX 1001
using namespace std;
int lcs(string A,string B){
    int X = A.size();
    int Y = B.size();
    int count[MAX][MAX] = {0};
    for(int i=1;i<Y+1;i++){
        for(int j=1;j<X+1;j++){
            if(B[i-1]==A[j-1]){
                count[i][j] = count[i-1][j-1] + 1;
            }else{
                count[i][j] = max(count[i][j-1],count[i-1][j]);
            }
            //cout << count[i][j];
        }
        //cout << endl;
    }
    return count[Y][X];
}
int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string A,B;
        cin >> A >> B;
        cout << lcs(A,B) << endl;
    }
    return 0;
}


Measured memory_bytes: 7132
function Main(input) {
	var inputArr = input.split("\n");
	var n = parseInt(inputArr[0]);
	var v = inputArr[1].split(" ");
	var c = inputArr[2].split(" ");
  
    var sum = 0;
	for (var i = 0; i < n ; i++) {
      var vi = parseInt(v[i], 10);
      var ci = parseInt(c[i], 10);
      if ((vi - ci) > 0) {
        sum = sum + (vi - ci);
      }
    }
    console.log(sum) ;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

/*
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
*/

string S;

int main() {
	cin >> S;
	ll ans = 0;
	REP(i, (int)pow(2, S.length() - 1)) {
		//i >> nがiのnビットがたってるか調べる
		int j = 0;
		bool bitchk[10] = {};
		for (int n = S.length() - 1; n >= 1; n--) {
			 bitchk[j++] = (i >> n - 1) % 2 == 1;
//			 cout << (i >> n - 1) << endl;
			}
//		REP(k, j) {
//			cout << bitchk[k];
//		}
		bitchk[j] = true;
//		cout << "i:" << i;
//		cout << endl;
		ll tmp = 0;
		REP(i, S.length()) {
			tmp += S[i] - '0';
			if (bitchk[i]) {
				ans += tmp;
				tmp = 0;
			}
			else tmp *= 10;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split())

lmin = []
rmax = []
for i in range(M):
    L, R = (int(i) for i in input().split())
    lmin.append(L)
    rmax.append(R)

res = min(rmax) - max(lmin) + 1 
if res < 0:
    print(0)
else:
    print(res)







Measured memory_bytes: 57688
#include <stdio.h>

int linearSearch(int A[], int n, int key)  {
  int i = 0;
  A[n] = key;
  while (A[i] != key)
    i++;
  return i != n;
}
  
int main(void)  {
  int i, n, A[10000], q, key, sum=0;
 
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for (i = 0; i < q; i++)  {
    scanf("%d", &key);
    if (linearSearch(A, n, key))
      sum++;  
  }
  printf("%d\n", sum);

  return 0;
}
  

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
const int inf=1<<30;
int cnt[100010],middle=0;
vector<int> g[100010];
vector<int> nums;
int n;
void dfs(int now,int par){
	//cout<<now<<" "<<par<<endl;
	cnt[now]=1;
	nums.push_back(now);
	if(now==n){
		middle=nums[(nums.size()+1)/2];
	}
	for(int i=0;i<g[now].size();i++){
		if(g[now][i]==par)continue;
		dfs(g[now][i],now);
		cnt[now]+=cnt[g[now][i]];
	}
	nums.pop_back();
	return;
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a); 
	}
	dfs(1,0);
	//cout<<cnt[middle]<<endl;
	string ans=(cnt[middle]*2<n)?"Fennec":"Snuke";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

inline int getComponent(int n, vector<int> &comp) {
    while (n != comp[n]) n = comp[n];
    return n;
}

void work() {
    int N,M,K; cin>>N>>M>>K;
    vector<int> comp(N+1); for (int i = 0; i <= N; ++i) comp[i] = i;
    vector<int> sz(N+1); for (int i = 0; i <= N; ++i) sz[i] = 1;
    vector<vector<int>> friends(N+1);
    for (int i = 0; i < M; ++i) {
        int u,v; cin>>u>>v; friends[u].push_back(v); friends[v].push_back(u);
        int compu = getComponent(u, comp); int compv = getComponent(v, comp);
        comp[compu] = compv;
        sz[compv] += sz[compu];
        sz[compu] = sz[compv];
    }
    vector<vector<int>> block(N+1);
    for (int i = 0; i < K; ++i) {
        int u,v; cin>>u>>v;
        block[u].push_back(v); block[v].push_back(u);
    }
    for (int i = 1; i <= N; ++i) {
        int ans = sz[getComponent(i,comp)] - friends[i].size() - 1;
        for (int j : block[i]) {
            if (getComponent(j, comp) == getComponent(i, comp)) --ans;
        }
        cout << ans << " ";
    }
    cout << endl;
}

void dfs(int v, vector<vector<int>> &fr, set<int> &s, vector<bool> &done) {
    s.insert(v);
    done[v] = true;
    for (auto u : fr[v]) {
        if (done[u]) continue;
        dfs(u, fr, s, done);
    }
}

void work2() {
    int N,M,K; cin>>N>>M>>K;
    vector<vector<int>> fr(N+1);
    for (int i = 0; i < M; ++i) {
        int u,v; cin>>u>>v;
        fr[u].push_back(v); fr[v].push_back(u);
    }
    vector<vector<int>> bl(N+1);
    for (int i = 0; i < K; ++i) {
        int u,v; cin>>u>>v;
        bl[u].push_back(v); bl[v].push_back(u);
    }
    vector<bool> done(N+1, false);
    vector<int> ans(N+1);
    for (int i = 1; i <= N; ++i) {
        if (done[i]) continue;
        set<int> s;
        dfs(i, fr, s, done);
        for (auto v : s) {
            ans[v] = s.size() - 1 - fr[v].size();
            for (auto b : bl[v]) {
                if (s.count(b)) --(ans[v]);
            }
        }
    }
    for (int i = 1; i <= N; ++i) cout << ans[i] << " ";
    cout << endl;
}

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

    return 0;
}


Measured memory_bytes: 17280
#include<iostream>
#include<algorithm>
#include<iomanip>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	double ans=0;
	
	cin >> N;
	
	for(int i=0;i<N;i++)
	{
		double x;
		string u;
		cin >> x >> u;
		
		if(u[0]=='J')
			ans+=x;
		else
			ans+=(380000*x);
	}
	cout << fixed << setprecision(6);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cassert>
#include <list>

struct Proc{
	std::string name;
	int time;
};

typedef std::list<Proc> PList;

int input(PList& vec);
void output(const PList& vec);
PList calc(PList vec, int q);

///-------------------------------------------------
int main()
{
	PList ivec;
	int q = input(ivec);
	PList ovec = calc(ivec,q);
	output(ovec);
	return 0;
}
///--------------------------------------------
int input(PList& vec)
{
	int n;
	std::cin >> n;
	int q;
	std::cin >> q;
	for(int i = 0; i < n; i++){
		Proc proc;
		std::cin >> proc.name;
		std::cin >> proc.time;
		vec.push_back(proc);
	}
	return q;
}
///-------------------------------------------------
void output(const PList& vec)
{
	for(PList::const_iterator itr = vec.begin(); itr != vec.end(); itr++){
		std::cout << itr->name << " " << itr->time << std::endl;
	}
}
///-------------------------------------------------
PList calc(PList queue, int q)
{
	PList vec;
	int  time = 0;
	while(!queue.empty()){
		if(queue.front().time > q){
			time += q;
			queue.front().time -= q;
			queue.push_back(queue.front());
		}else{
			time += queue.front().time;
			queue.front().time = time;
			vec.push_back(queue.front());
		}
		queue.pop_front();
	}
	return vec;
}
///-------------------------------------------------

Measured memory_bytes: 10144
S = input()
H = [0]*len(S)
for i in range(len(S)-1):
    if S[i] == "R" and S[i+1] == "L":
        for j in range(i,-1,-1):
            if S[j] == "R" and (i-j)%2 ==0:
                H[i] +=1
            if S[j] == "R" and (i-j)%2 ==1:
                H[i+1] +=1
            if S[j] == "L":
                break
        for k in range(i+1,len(S)):
            if S[k] == "L" and (i-k)%2 ==1:
                H[i+1] +=1
            if S[k] == "L" and (i-k)%2 ==0:
                H[i] +=1
            if S[k] == "R":
                break

for i in range(len(S)):
    print(H[i], end =" ")


Measured memory_bytes: 53464
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K % 2 == 0)cout << A - B << endl;
    else cout << B - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

vector<Vec> tree;
Vec dist;

void print_vec(const Vec &vec){
	for(ll i : vec) cosp(i);
	cout << endl;
}

void print_tree(const vector<Vec> &tree){
	for(Vec vec : tree) print_vec(vec);
}

void dijkstra(ll node){
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(mp(0, node));
	while(!que.empty()){
		P o = que.top(); que.pop();
		if(o.fs >= dist[o.sc]) continue;
		dist[o.sc] = o.fs;
		for(ll i : tree[o.sc]) que.push(mp(o.fs+1, i));
	}
}

int main(void){
	ll n, m;
	cin >> n >> m;
	tree.resize(n*3);
	dist.resize(n*3);
	fill(all(dist), LINF);
	rep(i, m){
		ll a, b;
		cin >> a >> b;
		a--, b--;
		tree[a*3].pb(b*3+1);
		tree[a*3+1].pb(b*3+2);
		tree[a*3+2].pb(b*3);
	}
	ll s, t;
	cin >> s >> t;
	s--, t--;
	dijkstra(s*3);
	if(dist[t*3] == LINF || dist[t*3]%3) co(-1);
	else co(dist[t*3]/3);

	return 0;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PUTS(x) cout << (x) << endl;
using Int = long long;
using namespace std;
const Int MOD = 1000000007LL;
int main() {
    int n;
    cin >> n;
    auto a = multiset<int>();
    rep(i, n) {
        int x;
        cin >> x;
        a.insert(x);
    }
    auto correct = multiset<int>();
    if (n % 2 == 0) {
        for (int i = 1; i < n; i += 2) {
            correct.insert(i);
            correct.insert(i);
        }
    } else {
        correct.insert(0);
        for (int i = 2; i < n; i += 2) {
            correct.insert(i);
            correct.insert(i);
        }
    }
    if (correct != a) {
        PUTS("0");
        return 0;
    }
    Int ans = 1;
    rep(i, n / 2) {
        ans *= 2;
        ans %= MOD;
    }
    PUTS(ans);
}


Measured memory_bytes: 9600
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table
is_prime,table = sieve(55555)
N = int(input())
table1 = list(map(lambda x:x%5,table))
ans = []
append = ans.append
for i in range(len(table)):
  if table1[i]==1:
    append(table[i])
  if len(ans)==N:
    break
print(*ans)
      

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
	if(a+e==b+d&&b+f==c+e&&d+h==e+g&&e+i==f+h) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200010
#define INF   1000000000000
#define p     (1000000000 + 7)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll a[MAX_N];
ll ball[MAX_N];
vector<ll> vm[MAX_N];

auto enum_divisors(ll N) {
  vector<ll> res;
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      if (N/i != i) res.push_back(N/i);
    }
  }
  return res;
}

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

    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++) cin >> a[i];

    fill(ball, ball + MAX_N, 0);
    
    for(ll i = N; i > 0; i--) {
      vector<ll> v;
      v = enum_divisors(i);
      for(ll j = 0; j < v.size(); j++) {
	vm[ v[j] ].push_back(i);
      }
            
    }

    ll M = 0;
    for(ll i = N; i > 0; i--) {
      ll tmp = 0;
      for(ll j = 0; j < vm[i].size(); j++) {
	if(vm[i][j] != i) tmp += ball[ vm[i][j] ];
      }
      if (tmp % 2 == a[i]) ball[i] = 0;
      else { ball[i] = 1; M++; }
    }

    cout << M << endl;
    if (M == 0) return 0;
    for(ll i = 1; i <= N; i++) {
      if (ball[i] == 1) cout << i << " ";
    }
    cout << endl;
    
    return 0;
}
    


Measured memory_bytes: 40420
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
int INF = 1<<30;
int main(){
    int n;
    cin>>n;
    vector<int> in(n);
    int maxv=-INF;
    rep(i,n){
        cin>>in[i];
    }
    int minv=in[0];
    for(int i=1;i<n;i++){
        chmax(maxv,in[i]-minv);
        chmin(minv,in[i]);
    }
    cout<<maxv<<endl;
}





Measured memory_bytes: 3600