akhauriyash/Code-Regression huggingface dataset:
package main
import (
  "fmt"
  "math"
)
func main() {
  prime(2200)
  n := 0
  fmt.Scan(&n)
  s := make([]int64,n)
  a := make([]int64,n)
  b := make([]int64,n)
  num := map[int64]int{}
  used := make(map[int64]struct{})
  for i:=0;i<n;i++ {
    fmt.Scan(&s[i])
    a[i],b[i] = norm(s[i])
    num[a[i]]++
  }
  ans := 0
  for i:=0;i<n;i++ {
    if _,ok := used[a[i]];ok { continue }
    used[a[i]] = struct{}{}
    used[b[i]] = struct{}{}
    if a[i] == 1 {
      ans++
    } else {
      ans += max(num[a[i]],num[b[i]])
    }
  }
  fmt.Println(ans)
}
func max(x,y int) int {
  if x > y { return x }
  return y
}
var p []int64
func norm(s int64) (int64,int64) {
  a,b := int64(1),int64(1)
  for i:=0;i<len(p);i++ {
    if s < p[i] { break }
    x := 0
    for s%p[i] == 0 {
      s /= p[i]
      x++
    }
    x %= 3
    if x == 1 {
      a *= p[i]
      b *= p[i]*p[i]
    } else if x == 2 {
      a *= p[i]*p[i]
      b *= p[i]
    }
  }
  if s != 1 {
    a *= s
    t := int64(math.Sqrt(float64(s)+0.5))
    if t*t == s {
      b *= t
    } else {
      b *= s*s
    }
  }
  return a,b
}
func prime(n int) {
  x := make([]bool,n+1)
  x[0],x[1] = true,true
  for i:=0;i<n+1;i++ {
    if x[i] { continue }
    for j:=i;j<n+1;j+=i { x[j] = true }
    x[i] = false
  }
  for i:=0;i<n+1;i++ {
    if x[i] { continue }
    p = append(p,int64(i))
  }
}

Measured memory_bytes: 16128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

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

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int red[100000];
int write[100000];

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

    red[0] = 1;
    REP (i, 1, n) write[i] = 1;

    rep (i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (write[x] != 0) {
            write[x]--;
            if (red[x] != 0) red[y]++;
            else write[y]++;
        } else {
            red[x]--;
            red[y]++;
        }
    }

    int ans = 0;
    rep (i, n) if (red[i]) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int Partition(int *A, int f, int l){
  int i, j, x;
  i = f-1;
  for(j = f; j < l; j++){
    if(A[j] <= A[l]){
      i = i+1;
      x = A[j];
      A[j] = A[i];
      A[i] = x;
    }
  }
    x = A[i+1];
    A[i+1] = A[l];
    A[l] = x;
  return i+1;
}
int main(){
  int i, n, m, *A;
  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  m = Partition(A,0,n-1);
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    if(i == m){
      printf("[%d]",A[i]);
      continue;
    }
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

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

int main()
{
    int L;
    cin >> L;
    
    int a,b;
    a = L/3;
    b = L%3;
    
    
    
    double ans = pow((double)L,3)/27;
    
    
    
    
    cout << setprecision(20) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forp(a,b,c) for(int (a)=(b); (a)<(c); (a++))
#define form(a,b,c) for(int (a)=(b); (a)>(c); (a--))
#define fori(a,b) for(auto (a):(b))
#define pb(a) push_back(a)
#define INF ((unsigned) ~0)
#define endl "\n"
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
 
int main()
{
    fastIO
    vector<char> vec1;
    vector<char> vec2;
    char c;
    while((c=getchar()) != '\n')
    {
        vec1.push_back(c);
    }
    while((c=getchar()) != EOF)
    {
        vec2.push_back(c);
    }
    int res=0;
    forp(i,0,vec1.size())
    {
        if(vec1[i]!=vec2[i]) res++;
    }
    cout<<res;
}

Measured memory_bytes: 3832
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    Q = int(readline())

    hi = []
    lo = []
    hi_sum = lo_sum = 0
    b_sum = 0

    ans = []
    for _ in range(Q):
        A = list(map(int, readline().split()))
        if len(A) == 3:
            a, b = A[1], A[2]
            b_sum += b

            if not lo:
                lo.append(-a)
                lo_sum += a
            else:
                vec = [a]
                vec.append(-heappop(lo))
                lo_sum -= vec[1]
                if hi:
                    vec.append(heappop(hi))
                    hi_sum -= vec[2]
                    
                vec.sort()
                
                if len(vec) == 2:
                    heappush(lo, -vec[0])
                    heappush(hi, vec[1])
                    lo_sum += vec[0]
                    hi_sum += vec[1]
                elif len(lo) > len(hi):
                    heappush(lo, -vec[0])
                    heappush(hi, vec[1])
                    heappush(hi, vec[2])
                    lo_sum += vec[0]
                    hi_sum += vec[1]
                    hi_sum += vec[2]
                else:
                    heappush(lo, -vec[0])
                    heappush(lo, -vec[1])
                    heappush(hi, vec[2])
                    lo_sum += vec[0]
                    lo_sum += vec[1]
                    hi_sum += vec[2]
        else:
            x = -lo[0]
            val = x * (len(lo) - len(hi)) - lo_sum + hi_sum + b_sum
            ans.append((x, val))

    for x, val in ans:
        print(x, val)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 28120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int A, B, K;
    cin >> A >> B >> K;
    int v;
    if (A < B) v = A;
    else v = B;

    vector<int> res;
    for (int i = 1; i <= v; i++) {
        if (A % i == 0  && B % i ==0) {
            res.push_back(i);
        }
    }

    cout << res.at(res.size() - K) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
#define mod 1000000007
#define N 100009
using namespace std;

int n,cnt,sz,a[N],vis[N],bo[N],path[N],blg[N],bg[N],dgr[N];
set<int> S; set<pii > T; pq Q; vi ans[N],f,g,b[N];
int read(); ll readll();
void dfs(int x,int para){
	if (bo[x]==para) return; vis[x]=1; bo[x]=para; S.insert(x);
	for (int p:b[x]){
		//if (min(u,v)==min(x,p) && max(u,v)==max(x,p)) continue;
		dfs(p,para);	
	}
}
bool work(int k,int len,int last,int rst,int j){
	if (k>len){
		ans[cnt].clear();
		int i; for (i=1; i<=len; i++) ans[cnt].pb(path[i]);
		return 1;
	}
	if ((*T.rbegin()).fi==S.size()-1){
	//	cerr<<"!\n";
		int x=(*T.rbegin()).se;
	//	cerr<<x<<'\n';
		if (x==a[last]) return 0;
		path[k]=x; S.erase(x); T.erase(mpr(dgr[x],x));
		bool flag=0;
		if (S.find(a[x])!=S.end()){
			flag=1;
			T.erase(mpr(dgr[a[x]]--,a[x]));	
			T.insert(mpr(dgr[a[x]],a[x]));
		}
		if (work(k+1,len,x,0,j)) return 1;
		if (flag){
			T.erase(mpr(dgr[a[x]]++,a[x]));
			T.insert(mpr(dgr[a[x]],a[x]));	
		}
		S.insert(x); T.insert(mpr(dgr[x],x));
		return 0;	
	}
	for (auto it=S.begin(); it!=S.end(); ) if ((*it)!=a[last]){
		path[k]=*it; S.erase(it);
		int x=*it; T.erase(mpr(dgr[x],x));
		bool flag=0;
		if (S.find(a[x])!=S.end()){
			flag=1;
			T.erase(mpr(dgr[a[x]]--,a[x]));	
			T.insert(mpr(dgr[a[x]],a[x]));
		}
		if (work(k+1,len,*it,rst,j)) return 1;
		S.insert(path[k]); it=S.upper_bound(path[k]);
		x=path[k];
		T.insert(mpr(dgr[x],x));
		if (flag){
			T.erase(mpr(dgr[a[x]]++,a[x]));
			T.insert(mpr(dgr[a[x]],a[x]));	
		}
	} else it++;
	return 0;
}
int main(){
	scanf("%d",&n);
	if (n==2){ puts("-1"); return 0; }
	int i,j;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]); b[a[i]].pb(i);
	}
	cnt=1;
	for (i=1; i<=n; i++) S.insert(i);
	for (int p:S) dgr[a[p]]++;
	T.clear();
	for (int p:S) T.insert(mpr(dgr[p],p));
	work(1,S.size(),0,0,j);
	for (int p:ans[1]) printf("%d ",p); puts("");
	return 0;
}


int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
#define inf 0x7fffffff
#define X first
#define Y second
#define N 120010
typedef long long ll;
int dp[305][305][305];
char s[305];

int dfs(int l,int r,int k){
	if(l>r)return 0;
	if(l==r)return 1;

	if(dp[l][r][k]!=-1)return dp[l][r][k];
	dp[l][r][k]=max(dfs(l+1,r,k),dfs(l,r-1,k));
	if(s[l]==s[r])dp[l][r][k]=max(dfs(l+1,r-1,k)+2,dp[l][r][k]);
	else if(k>=1) dp[l][r][k]=max(dfs(l+1,r-1,k-1)+2,dp[l][r][k]);
	return dp[l][r][k];
}
int main()  {
	memset(dp,-1,sizeof(dp));
	int k;
	scanf("%s",&s);
	scanf("%d",&k);
	printf("%d\n",dfs(0,strlen(s)-1,k));
     return 0;
}


Measured memory_bytes: 111104
S=list(input())
T=list(input())
s=len(S)
def swap(X,i,j):
  x=X[i]
  X[i]=X[j]
  X[j]=x
def swaplist(S):
  for i in range(1,s):
    swap(S,s-i,s-i-1)
  return S
count=0
if S==T:
  count=count+1
else:
  for i in range(s):
    if T==swaplist(S):
      count=count+1
if count==0:
  print('No')
else:
  print('Yes')

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  
  rep(i, n-1){
  	int a = n - (i+1);
    int s = sqrt(a);
    int cnt = 0;
    //rep(j, (int)(sqrt(a) + 1e-9)+1){
    for(int j = 1; j < s + 1e-9; j++) if(a%j == 0) cnt += 2;
    if(s*s == a) cnt--;
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

K = attrs[0][0].to_i
A = attrs[1][0].to_i
B = attrs[1][1].to_i
puts (A%K==0 || B%K==0) ? 'OK' : ((A / K)==(B / K)) ? 'NG' : 'OK'

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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if(s == "SSS") cnt = 0;
    else cnt = 1;
    if(s[0] == 'R' && s[1] == 'R')cnt++;
    if(s[1] == 'R' && s[2] == 'R')cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	map<string,bool> m;
	char c = '\0';
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if(m[s]) {
			cout << "No" << endl;
			return 0;
		}
		m[s] = true;
		if(c!='\0'&&c!=s.at(0)) {
			cout << "No" << endl;
			return 0;
		}
		c = s.at(s.size()-1);
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 888
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 2e5+10;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , top;
int s[N];
struct node
{
	int v , c;
}sta[N];

void Add(int pos , int mid) // sta 这个栈是从s1 到 sn 是公用的，存的是当前的不是a的位置(a可以理解为0)。 
{
	while(sta[top].v > pos) top--;
	if(sta[top].v == pos) sta[top].c++; else sta[++top] = (node){pos , 1};
	while(top > 1 && sta[top].c == mid) Add(pos - 1 , mid); // 要进位了， 
}

bool check(int mid)
{
	sta[top = 1] = (node){ 0 , 0 };
	for(int i = 2 ; i <= n ; ++i)
		if(s[i] <= s[i-1]) Add(s[i] , mid);
	return sta[1].c == 0; // sta[1] 只能是 0下标对应的 
}

int main()
{
	n = read(); 
	for(int i = 1 ; i <= n ; ++i) s[i] = read();
	int flag = 1;
	for(int i = 2 ; i <= n ; ++i) flag &= s[i] > s[i - 1];
	if(flag) return puts("1") , 0; // 1 进制 ，
	int l = 2 , r = n , mid , ans = 0; // 最大是n进制， 
	while(l <= r)
	{
		mid = (l + r) >> 1;
		if(check(mid)) ans = mid , r = mid - 1; else l = mid + 1;
	} 
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int N = 55;
int n;
int arr[N];
int cnt[13];
int ans;
int tot[25];
void check(){
	int tmp = 24;
	for(int i = 0 ; i <= 24 ; ++i){
		for(int j = i + 1 ; j <= 24 ; ++j){
			if(tot[i] && tot[j]){
				int d = j - i;
				tmp = min(tmp , min(d , 24 - d));
			}
		}
		if(tot[i] > 1){
			tmp = 0;
		}
	}
	ans = max(ans , tmp);
}
void go(int pos){
	if(pos == 13){
		check();
		return;
	}
	if(cnt[pos] == 0){
		go(pos + 1);
	}
	if(cnt[pos] == 1){
		++tot[pos];
		go(pos + 1);
		--tot[pos];
		++tot[24 - pos];
		go(pos + 1);
		--tot[24 - pos];
	}
	if(cnt[pos] == 2){
		++tot[pos];
		++tot[24 - pos];
		go(pos + 1);
		--tot[24 - pos];
		--tot[pos];
	}
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
		++cnt[arr[i]];
	}
	++cnt[0];
	for(int i = 0 ; i <= 12 ; ++i){
		if(cnt[i] > 2){
			printf("0\n");
			return 0;
		}
	}
	go(0);
	printf("%d\n" , ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll N=100001;
const char o='0';

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a,b,c;
	ll l,n=0,m;
	cin>>a>>b;
	c=a+b;
	l=c.size();
	for(ll i=0;i<l;i++){
		n*=10;
		n+=(c[i]-o);
	}
	m=sqrt(n);
	if(m*m==n){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

x, y = [int(i) for i in input().split()]

tmp = 0
res = "No"

for i in range(x + 1):
    j = x - i
    if 2 * i + 4 * j == y:
        res = "Yes"

print(res)


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

int main(void){

    int N; cin>>N;
    int past_x=0,past_y=0, past_time=0;

    string ans = "Yes";
    for (int i = 0; i < N; ++i) {
        int t, x, y; cin>>t>>x>>y;

        if((t-past_time) < abs(x-past_x)+abs(y-past_y) || ((t-past_time)-abs(x-past_x)-abs(y-past_y) )% 2 != 0){
            ans = "No";
            break;
        }

        past_x = x; past_y=y; past_time = t;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){


    int n,m;
    cin >> n >> m;

    vector<pair<int,int> > dem(m);

    for(int i = 0;i < m;i++){
        cin >> dem[i].second >> dem[i].first;
    }

    sort(dem.begin(),dem.end());

    int now = -1;
    int ans = 0;

    for(int i = 0;i < m;i++){
        //cout << dem[i].first << " " << dem[i].second << endl;
        if(dem[i].second > now){
            //cout << "a" << endl;
            ans++;
            now = dem[i].first-1;
            //cout << dem[i].first << " " << dem[i].second << endl;
        }
    }
    cout << ans << endl;

   
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;

const int MOD = 1000000007;
const int INF = 1000000000;

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


class UnionFind{
    vector<int> par;
    vector<int> rank;

public:
    UnionFind(int n): par(n), rank(n){
        REP(i, n){
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unit(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) ++rank[x];
        }
    }

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

int main(){
    int n, k, l; cin >> n >> k >> l;
    UnionFind rd(n), tr(n);
    REP(i, k){
        int p, q; cin >> p >> q; --p; --q;
        rd.unit(p, q);
    }
    REP(i, l){
        int r, s; cin >> r >> s; --r; --s;
        tr.unit(r, s);
    }
    map<PII, int> mp;
    REP(i, n) ++mp[MP(rd.find(i), tr.find(i))];
    REP(i, n){
        if(i) cout << " ";
        cout << mp[MP(rd.find(i), tr.find(i))];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 15104
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];


void print( int u){
	
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	
	if( T[u].p == NIL ) cout << "root, ";
	else if ( T[u].l == NIL ) cout << "leaf, ";
	else cout << "internal node, ";
	
	cout << "[";
	
	for( i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
		if(i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

//再帰的に深さを求める
int rec(int u, int p){
	D[u] = p;
	if( T[u].r != NIL ) rec(T[u].r, p);     //右の兄弟は同じ高さを設定
	if( T[u].l	!= NIL ) rec(T[u].l, p+1);  //最も左の子に自分の深さ+1を設定
}

int main(){
	int i, j, d, v, c, l, r;
	cin >> n;
	for( i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
	
	for( i=0; i<n; i++){
		cin >> v >> d;
		for( j=0; j<d; j++){
			cin >> c;
			if( j==0 ) T[v].l =c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	
	for ( i=0; i<n; i++){
		if( T[i].p == NIL) r=i;
	}
	
	rec(r, 0);
	
	for( i=0; i<n; i++) print(i);
	
	return 0;
}


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

result = {}
max = 0
for i in range(n):
    a = str(input())
    if not a in result:
        result[a] = 0
    result[a] += 1
    if max < result[a]:
        max = result[a]

result = sorted(result.items(), key=lambda x: (x[1], x[0]))
for val in result:
    if max == val[1]:
        print(val[0])


Measured memory_bytes: 57436
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (S[h][w] == '.')
                continue;

            bool ok = false;
            if (h - 1 >= 0 && S[h - 1][w] == '#') {
                ok = true;
            }
            if (h + 1 < H && S[h + 1][w] == '#') {
                ok = true;
            }
            if (w - 1 >= 0 && S[h][w - 1] == '#') {
                ok = true;
            }
            if (w + 1 < W && S[h][w + 1] == '#') {
                ok = true;
            }

            if (!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


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

int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;

  int64_t ans = 0;
  if (a == 0) {
    ans = b / x;
    ans++;
  } else {
    ans = b / x - (a - 1) / x;
  }

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

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[99][99];
int q[9999],qcnt=0,qpnt=0;
int d[5]={1,0,-1,0,1};
int main(){
	int h,w;
	scanf("%d%d\n",&h,&w);
	rep(i,1,h+1)gets(s[i]+1);
	s[1][1]=0;
	qcnt=1;
	qpnt=0;
	q[0]=10101;
	while(qpnt<qcnt){
		int x=q[qpnt]/100%100,y=q[qpnt]%100;
		if(x==h&&y==w)break;
		rep(i,0,4)if(s[x+d[i]][y+d[i+1]]=='.'){
			s[x+d[i]][y+d[i+1]]=0;
			q[qcnt++]=(q[qpnt]/10000+1)*10000+(x+d[i])*100+(y+d[i+1]);
		}
		qpnt++;
	}
	if(qpnt==qcnt){
		puts("-1");
		return 0;
	}
	int ans=h*w-q[qpnt]/10000;
	rep(i,1,h+1)rep(j,1,w+1)if(s[i][j]=='#')ans--;
	printf("%d\n",ans);
	return 0;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 200010;
const int MOD = 1000000007;

int to[MAXN];
int n, rgt[MAXN], lft[MAXN], all[MAXN], f[MAXN], sum[MAXN];

struct Takahashi {
	int pos, v;
} tak[MAXN];

bool cmp(const Takahashi &x, const Takahashi &y)
{
	return x.pos < y.pos;
}

bool cmp2(const int &x, const int &y) {return lft[x] < lft[y] || lft[x] == lft[y] && rgt[x] < rgt[y];}

int main()
{
	in(n);
	FOR(i, 1, n) in(tak[i].pos), in(tak[i].v), all[++all[0]] = tak[i].v;

	std::sort(tak + 1, tak + n + 1, cmp);
	std::sort(all + 1, all + all[0] + 1);
	all[0] = std::unique(all + 1, all + all[0] + 1) - all - 1;

	FOR(i, 1, n) tak[i].v = std::lower_bound(all + 1, all + all[0] + 1, tak[i].v) - all;

	int maxx = 0;
	FOR(i, 1, n) {
		chkmax(maxx, tak[i].v); rgt[i] = maxx;
	}

	int minx = 0x3f3f3f3f;
	DNF(i, n, 1) {
		chkmin(minx, tak[i].v); lft[i] = minx;
	}

	FOR(i, 1, n) to[i] = i; std::sort(to + 1, to + n + 1, cmp2);

	int lst = 0;

	lft[n + 1] = rgt[n + 1] = all[0] + 1;

	sum[0] = 1;
	to[n + 1] = n + 1;
	
	FOR(i, 1, n + 1) {
		int now = to[i];
		while (rgt[to[lst]] < lft[now] - 1) lst++;
		f[i] = (sum[i - 1] - sum[lst - 1] + MOD) % MOD;
		sum[i] = (sum[i - 1] + f[i]) % MOD;
	}

	printf("%d\n", f[n + 1]);

	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;


int main(){
    int taro[100], hanako[100];
    
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0 && m==0) break;

        int total=0, total_taro=0;
        for(int i=0; i<n; i++){
            cin >> taro[i];
            total += taro[i];
        }
        total_taro = total;
        for(int i=0; i<m; i++){
            cin >> hanako[i];
            total += hanako[i];
        }

        if(total%2 !=0){
            cout << -1 << endl;
            continue;
        }

        int diff = total_taro - total/2;
        int min=INT_MAX, a,b;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(taro[i]-hanako[j] == diff){
                    if(taro[i]+hanako[j] < min){
                        a = taro[i];
                        b = hanako[j];
                        min = a+b;
                    }
                }
            }
        }

        if(min!=INT_MAX){
            cout << a << " " << b << endl;
        }else{
            cout << -1 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define of(i,a,b) for(register int (i)=(a);(i)>=(b);--(i))
#define rd read()
#define maxn 500001
#define ll long long
#define fre(a) freopen("a.in","r",stdin);freopen("a.out","w",stdout);
const int p=998244353;
int read() {int x=0,f=1;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;}
void print(int x) { if(x<0){putchar('-');x=-x;}if(x>9)print(x/10);putchar(x%10+'0');}
int qp(int a, int  b) {int ans = 1;for(; b; b >>= 1, a *= a, a %= p) if(b & 1) ans *= a, ans %= p;return ans % p;}
int main() {
    int a=rd,b=rd,c=rd,d=rd,ok=0;
    if(abs(c-a)<=d||abs(b-a)<=d&&abs(b-c)<=d)ok=1;
    puts(ok?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9;
int main(){
  string s;cin>>s;
  int x=s.size(),count=0;
  bool ok=true;
  if(s[0]!='A'){ok=false;}
  rep(i,2,x-1){
    if(s[i]=='C'){count++;}
  }
  if(count!=1){ok=false;}
  if(ok){
    count=0;
    rep(i,1,x){
      rep(k,0,26){
        if(s[i]=='a'+k){count++;break;}
      }
    }
    if(count!=x-2){ok=false;}
  }
  if(ok){cout<<"AC"<<endl;}
  else{cout<<"WA"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

using ll = long long;

int H[10000];
int N;
int ans = 0;
int maxh = 0;

int main() {
	cin >> N;
	H[0] = 0;
	for (int i = 1; i < N + 1; i++) {
		cin >> H[i];
		if (H[i] >= maxh) {
			ans++;
			maxh = H[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n,m,p,x;
    scanf("%lli",&n);
    ll t[n];
    ll sum=0;
    fr(i,1,n+1){
        scanf("%lli",&t[i]);
        sum += t[i];
    }
    scanf("%lli",&m);
    fr(i,1,m+1){   
        scanf("%lli %lli",&p,&x);
        printf("%lli\n",sum - t[p] + x);
    }
    return 0;
}

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

int main() 
{ 
    int n;
    cin>>n;
    vector<int> arr(n);
    vector<int> dp(n);
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(int i = 2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1];
    return 0; 
} 

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 110, MAXH = 110;

char tile[MAXW][MAXH];

int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};
int ss;
int solve(int x, int y, char c)
{
    if(tile[x][y] == 0) return 0;
    
    tile[x][y] = 0;
    REP(4)if(tile[x+dx[i]][y+dy[i]] == c) {solve(x+dx[i], y+dy[i] , c);}
    
    return 1;
}

int main()
{
    int w,h;
    while(cin >> h >> w && h)
    {
        memset(tile, 0, sizeof(tile));
        rep(j,h)rep(i,w)cin >> tile[i+1][j+1];

        int ans = 0;
        rep(j,h)rep(i,w) ans += solve(i+1, j+1, tile[i+1][j+1]);

        cout << ans << endl;
    }

    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

struct edge {
  int to, cap, rev;
};

const int N = 200 + 10;
vector<int> g[N];

void add_edge(int src, int dst)
{
  g[src].push_back(dst);
  g[dst].push_back(src);
  return ;
}

int match[N];
int vis[N], x;
bool rec(int curr)
{
  vis[curr] = x;
  each (next, g[curr]) {
    int w = match[next];
    if (w < 0 || (vis[w] != x && rec(w))) {
      match[curr] = next;
      match[next] = curr;
      return true;
    }
  }
  return false;
}

int matching(int n = N)
{
  int res = 0;
  fill(match, match + N, -1);
  x = 1;
  fill(vis, vis + N, 0);
  for (int i = 0; i < n; ++i) {
    if (match[i] < 0) {
      res += rec(i);
      ++x;
    }
  }
  return res;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    fill(g, g + N, vector<int>());

    pair<int, int> b[n];
    pair<int, int> r[n];
    for (int i = 0; i < n; ++i) {
      cin >> r[i].first >> r[i].second;
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i].first >> b[i].second;
    }

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (r[i].first < b[j].first && r[i].second < b[j].second) {
          add_edge(i, j + n);
        }
      }
    }
    cout << matching() << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define gc(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define ms(a,b) memset(a,b,sizeof(a));
char _;
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f;

ll dp[400][400];
ll pfsum[401];
int arr[400];

ll mincost(int l, int r){
    if(dp[l][r]>=INF){
            if(l>r){
                dp[l][r]=INF;
            }
            else if(l==r){
                dp[l][r]=0;
            }
            else{
             for(int i = l; i < r; ++i){
                        dp[l][r]=min(dp[l][r],mincost(l,i)+mincost(i+1,r)+pfsum[r+1]-pfsum[l]);
            }
        }
    }
    return dp[l][r];
}



int main()
{
    ms(dp,INF);
    pfsum[0]=0;
    int n; gc(n);
    for(int i = 0; i < n; ++i){
        int a; gc(a);
        pfsum[i+1]=pfsum[i]+a;
        arr[i]=a;
    }
    for(int l = n-1; l >=0; --l){
        for(int r = l; r < n; ++r){
                if(l==r){
                    dp[l][r]=0;
                }
                else{
                 for(int i = l; i < r; ++i){
                        dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+pfsum[r+1]-pfsum[l]);
                }
            }
        }
    }
    printf("%llu\n",dp[0][n-1]);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

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

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint modpow(mint a,ll n){
    mint res = 1;
    while(n > 0){
        if(n & 1) res = res * a ;
        a = a * a;
        n >>= 1;//nを２のベキに分解している
    }
    return res;
}
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
mint ans,mp=1,np=1;
int n,m;cin>>n>>m;
  if(abs(n-m)>=2){
    cout<<0<<endl;
    return 0;
  }
  else{

    for (int i = 1; i <=n; i++)
    {
      np*=i;
    }
    for (int i = 1; i <=m; i++)
    {
      mp*=i;
    }
    //cout<<np<<mp<<endl;
    mint ans;
    if(abs(n-m)==1){
      ans = np*mp;
    }
    else {ans = mp*np;ans *=2;}
  cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
M=1000000
n,m=map(int,raw_input().split())
if m==1:
    a=1
    for i in range(n):a=(a*2)%M
    print a;sys.exit()
dp=[[0]*3 for _ in range(n+2)]
dp[0]=[1,0,0]
dp[1]=[1,1,1]
for i in range(1,n+2):
    dp[i][1]=sum(dp[i-1])%M
    dp[i][0]=(sum(dp[i-1])+sum([dp[j][2] for j in range(i-1)]))%M
    dp[i][2]=(sum(dp[i-1])+sum([dp[j][0] for j in range(i-1)]))%M
print dp[n+1][2]

Measured memory_bytes: 6480
#include<iostream>
#include<stdio.h>
using namespace std;
#define MAX 500000
#define banhei 2000000000

struct card{
    char C;
    int I;
};


struct card L[MAX/2+2];
struct card R[MAX/2+2];
 
void merge(struct card A[],int n,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    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].I=R[n2].I=banhei;
    int i=0;
    int j=0;
    for(int k=left;k<right;k++){
        if(L[i].I<=R[j].I){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
        }
    }
}
 
void mergesort(struct card A[],int n,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
    }
}
 
int partition(struct card A[],int n,int p,int r){
    int i,j;
    struct card x;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j].I<=x.I){
            i++;
            swap(A[j],A[i]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

void quicksort(struct card A[],int n,int p,int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quicksort(A,n,p,q-1);
        quicksort(A,n,q+1,r);
    }
}
 
int main(){
    int n,i,M;
    struct card A[MAX],B[MAX];
    char S[5];
    int stable=1;
    cin>>n;
    
    for(i=0;i<n;i++){
    scanf("%s %d",S,&M);
    A[i].C=B[i].C=S[0];
    A[i].I=B[i].I=M;
    }
 
    mergesort(A,n,0,n);
    quicksort(B,n,0,n-1);
    
    for(i=0;i<n;i++){
        if(A[i].C!=B[i].C)stable=0;
    }
    
    if(stable)printf("Stable\n");
    else printf("Not stable\n");
    
    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].C,B[i].I);
    }
    return 0;
}


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

using namespace std;

const long long m = 1000000000;

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

	long long x1, y1;
	long long x2, y2;

	long long d = (m - s % m) % m;			

	x2 = 1;
	y1 = d;
	
	s += d;

	x1 = m;
	y2 = s / m;

	cout << 0 << ' ' << 0 << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  vector<int> v;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    v.push_back(x);
  }
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(binary_search(v.begin(),v.end(),x)) cout<<"1"<<endl;
    else cout<<"0"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3488
K, S = gets.split.map{|i|i.to_i}
c = 0
(0..K).each{|x|
    next if x + K * 2 < S
    (0..K).each{|y|
        z = S - x - y
        next if z > K
        next if z < 0
        c += 1
    }
}
puts c


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define RED 1
#define WHITE 0

int main()
{
    lol result{0};
    lol n; cin >> n;
    vector<int> a(n);
    REP(i, n)
    {
        char ch;
        cin >> ch;
        if(ch == 'W')
            a[i] = WHITE;
        else
        {
            a[i] = RED;
        }
        
    }
    int i = 0;
    int j = n - 1;
    while(i < j)
    {
        if(a[i] == RED)
        {
            i++;
        }
        if(a[j] == WHITE)
        {
            j--;
        }
        if(a[i] == WHITE && a[j] == RED)
        {
            result++;
            i++;
            j--;
        }
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_N 100
#define MAX_W 100000

ll dp[MAX_N + 1][MAX_W + 1];

signed main(){
	int N,W;
	cin >> N >> W;
	int w[N];
	ll v[N];
	REP(i,N){
		cin >> w[i] >> v[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= W; j++){
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if(j - w[i] < 0){
				continue;
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b)
{
    return a < b ? b : a;
}

int main(void)
{
    int n;
    int sum;
    int x[1024], y[1024];
    int i;

    scanf("%*d %*d %d", &n);
    scanf("%d %d", x, y);
    sum = 0;
    for (i = 1; i < n; ++i){
        int dx, dy;
        scanf("%d %d", x + i, y + i);
        dx = x[i] - x[i - 1];
        dy = y[i] - y[i - 1];
        if (0 <= dx * dy){
            sum += max(abs(dx), abs(dy));
        }
        else {
            sum += abs(dx) + abs(dy);
        }
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map<string,int> ma;
string s;
int main() {
	int n,maxx=0;
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>s;
		ma[s]++;
		maxx=max(maxx,ma[s]);
	}
	for(auto it:ma) {
		if(it.second==maxx) cout<<it.first<<'\n';
	}
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int dh[] = {1,0,-1,0};
int dw[] = {0,1,0,-1};

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> g(h, vector<char> (w));

    rep(i,h)rep(j,w) cin >> g[i][j];

    ll ans = -1002003004;

    rep(i,h){
        rep(j,w){
            if(g[i][j] == '#') continue;

            //以下BFS
            queue<P> q;
            Graph dist(h, vector<int> (w,1002003004));
            auto push = [&](int vh, int vw, int d){
            if(dist[vh][vw] != 1002003004) return;
            dist[vh][vw] = d;
            q.push(P(vh,vw));
            };

            push(i,j,0);

            while(!q.empty()){
                P p = q.front(); q.pop();
                int vh = p.first, vw = p.second;
                int d = dist[vh][vw];

                rep(dimention,4){
                    int nh = vh+dh[dimention], nw = vw + dw[dimention];
                    if(nh<= -1 || nh >= h || nw <= -1 || nw >= w) continue;
                    if(g[nh][nw] == '#') continue;
            
                    push(nh, nw, d+1);
                }
            }

            rep(k,h) rep(l,w) if(g[k][l] != '#') ans = max(ans,ll(dist[k][l]));

        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}

Int check(vector<vector<Int> > G, Int root,Int d){

  function<Int(Int,Int,Int)>  dfs = [&](Int pos,Int pre,Int dis){
    Int res = dis;
    for(Int to:G[pos]){
      if(to == pre) continue;
      res += dfs(to, pos, dis+1);
    }
    return res;
  };
  return dfs(root, -1, 0) == d;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  cin>>n;
  vector<P> D(n);
  map<Int,Int> num;
  for(Int i=0;i<n;i++){
    Int d;
    cin>>d;
    D[i] = P(d, i);
    num[d] = i;
  }
  sort(D.begin(), D.end(), greater<P>());

  vector<Int> sz(n, 1);
  vector<vector<Int> > G(n);

  auto add_edge = [&](Int a,Int b){
    G[a].push_back(b);
    G[b].push_back(a);
  };

  
  for(Int i=0;i<n-1;i++){
    Int d, pos; tie(d, pos) = D[i];
    Int x  = sz[pos];
    Int nd = d + x - (n - x);

    if(!num.count(nd)){
      cout<<-1<<endl;
      return 0;
    }
    Int to = num[nd];
    if(d <= nd){
      cout<<-1<<endl;
      return 0;
    }

    add_edge(pos, to);
    sz[to] += sz[pos];
  }

  
  if(!check(G, D[n-1].second, D[n-1].first)){
    cout<<-1<<endl;
    return 0;
  }

  
  for(Int i=0;i<n;i++)
    for(Int to:G[i]){
      if(i > to) continue;
      cout<<i+1<<" "<<to+1<<endl;
    }
  return 0;
}


Measured memory_bytes: 25216
n = int(input())
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1: continue
    for j in range(10):
        b = s.find(str(j), a + 1)
        if b == -1: continue
        for k in range(10):
            if s.find(str(k), b + 1) != -1:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

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

  cout << (A-B)%C << endl;
   
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,a,b;
  cin >> x >> a >> b;
  if(b<=a)
  cout <<"delicious"<< endl;
  else if(b<=x+a)
  cout <<"safe"<<endl;
  else
  cout << "dangerous" << endl;
}


Measured memory_bytes: 256