akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using namespace std;

int main(){
	string s; cin>>s;
	int ans=0;
	int start=0, end=0;

	for(; start<s.size(); start++){
		end=start;
		if(s[start]!='A'&&s[start]!='T'&&s[start]!='G'&&s[start]!='C') continue;
		for(; end<s.size(); end++)if(s[end]!='A'&&s[end]!='T'&&s[end]!='G'&&s[end]!='C')break;
		ans = max(ans, end-start);
	}

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



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,Ans,a[100005];
int main ()
{
	scanf ("%d",&n);
	for (int i=1;i<=n;++i) scanf ("%d",&a[i]);
	sort (a+1,a+n+1);
	for (int i=1;i<=n;++i)
		if (a[i]==a[i+1]) ++i;
		else ++Ans;
	return !printf ("%d\n",Ans);
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto counts = map<array<int, 26>, int>();
	for (auto i=0; i<n; ++i) {
		auto count = array<int, 26>{};
		auto text = load<string>();
		for (auto chr : text)
			++count[chr-'a'];
		++counts[count];
	}
	auto answer = 0ll;
	for (auto&& entry : counts)
		answer += (long long)entry.second * (entry.second - 1) / 2;
	cout << answer << '\n';
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int k = fs.nextInt();
		int a = fs.nextInt();
		int b = fs.nextInt();
		if ((Math.ceil((double) a / k)) * k <= b) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 32572
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))


k,x = LI()


ans = [x-k+1+i for i in range(2*k-1)]
for i in range(len(ans)):
    print(ans[i],end=" ")

print("")


Measured memory_bytes: 6476
s=input()
#><となるところを見つける<<となるところを見つける>>となるところを見つける<>となるところについて考える
n=len(s)
ans=[0]*(n+1)

#左から>>となる部分を探す
for i in range(n):
    if s[i]=='<':
        ans[i+1]=max(ans[i+1],ans[i]+1)

for i in reversed(range(n)):
    if s[i]=='>':
        ans[i]=max(ans[i],ans[i+1]+1)
print(sum(ans))
#rangeの挙動に注意しよう

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

xs = []
ys = []
hs = []

for i in range(n):
    x, y, h = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)
    hs.append(h)

count = 0
for h in hs:
    if h != 0:
        count += 1

if count == 1:
    for x, y, h in zip(xs, ys, hs):
        if h != 0:
            print(x, y, h)
            exit(0)

if count == 0:
    pairs = list([(x, y) for x, y in zip(xs, ys)])
    for x1 in range(101):
        for y1 in range(101):
            if (x1, y1) not in pairs:
                print(x1, y1, 1)
                exit(0)

x_cands = []
y_cands = []
for x1 in range(101):
    for y1 in range(101):
        h0 = None
        for x, y, h in zip(xs, ys, hs):
            if h == 0:
                continue
            if h0 is None:
                h0 = abs(x1 - x) + abs(y1 - y) + h
            elif abs(x1 - x) + abs(y1 - y) + h != h0:
                break
        else:
            x_cands.append(x1)
            y_cands.append(y1)

h_cands = []
for xc, yc in zip(x_cands, y_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != 0:
            h_cands.append(h + abs(xc - x) + abs(yc - y))
            break

for xc, yc, hc in zip(x_cands, y_cands, h_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != max(hc - abs(xc - x) - abs(yc - y), 0):
            break
    else:
        print(x_cands[0], y_cands[0], h_cands[0])
        exit(0)


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

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    int N = inputValue();
    char S[10001];
    cin >> S;
    REP(i, strlen(S)){
        S[i] += N;
        if(S[i] > 'Z'){
            S[i] -= 26;
        }
    }


    cout << S << endl;
}


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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S[2];
    cin >> S[0];
    cin >> S[1];

    ll ans = 1;
    int before = -1;
    for(int i=0; i<N; i++){
        if(before == -1){
            if(S[0][i+1] == S[0][i]){
                ans = ans * 6;
                before = 0;
                i++;
            }else{
                ans = ans * 3;
                before = 1;
            }
            continue;
        }
        if(i == N-1){
            if(before == 1) ans = (ans*2)%MOD;
            continue;
        }
        if(before == 0){
            if(S[0][i] == S[0][i+1]){
                ans = (ans * 3)%MOD;
                i++;
                before = 0;
            }else{
                ans = ans;
                before = 1;
            }
        }else{
            if(S[0][i] == S[0][i+1]){
                ans = (ans * 2)%MOD;
                i++;
                before = 0;
            }else{
                ans = (ans * 2)%MOD;
                before = 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//Created Time:2019骞?2鏈?8鏃?鏄熸湡鍏?19鏃?7鍒?0绉?
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 100005
#define mod 998244353
#define G 3
#define iG 332748118
#define add(x,y) ((x) + (y)) % mod
#define mul(x,y) 1ll * (x) * (y) % mod

using namespace std;

int n, m, len;
int f[2][N], fac[N], ifac[N], R[N], a[N], b[N], c[N];

int quick_pow(int ,int);
int C(int ,int);
void NTT(int *,int);
void init();

int main(){
	cin >> n >> m; init();
	int cur = 0, pre = 1;
	for(int i = 1; i <= n; ++i) b[i] = ifac[i + 2];
	NTT(b, 1); f[cur][0] = 1;
	for(int u = 1; u <= m; ++u){
		swap(cur, pre);
		for(int i = 0; i <= n; ++i) a[i] = mul(f[pre][i], ifac[i]);
		for(int i = n + 1; i < len; ++i) a[i] = 0;
		NTT(a, 1);
		for(int i = 0; i < len; ++i) a[i] = mul(a[i], b[i]);
		NTT(a, -1);
		for(int i = 0; i <= n; ++i){
			f[cur][i] = mul(a[i], fac[i + 2]);
			f[cur][i] = add(f[cur][i], mul(f[pre][i], C(i, 2) + i + 1));
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; ++i)
		ans = add(ans, mul(f[cur][i], C(n, i)));
	cout << ans << endl;
	return 0;
}

void init(){
	ifac[0] = fac[0] = 1;
	for(int i = 1; i <= n + 10; ++i)
		fac[i] = mul(fac[i - 1], i), ifac[i] = quick_pow(fac[i], mod - 2);
	len = 1; int l = 0;
	while(len <= n * 2) len <<= 1, ++l;
	for(int i = 0; i < len; ++i)
		R[i] = (R[i >> 1] >> 1) | ((i & 1) << (l - 1));
	return ;
}

int C(int x, int y){
	if(x < y) return 0;
	return mul(fac[x], mul(ifac[y], ifac[x - y]));
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = mul(x, x))
		if(y & 1) sum = mul(sum, x);
	return sum;
}

void NTT(int *x, int flag){
	for(int i = 0; i < len; ++i)
		if(i < R[i]) swap(x[i], x[R[i]]);
	for(int i = 1; i < len; i <<= 1){
		int wn = quick_pow(flag == 1 ? G : iG, (mod - 1) / (i << 1));
		for(int j = 0; j < len; j += i << 1){
			int w = 1;
			for(int k = j; k < i + j; ++k, w = mul(w, wn)){
				int p = x[k], q = mul(w, x[i + k]);
				x[k] = add(p, q); x[i + k] = add(p, mod - q);
			}
		}
	}
	if(flag == 1) return ;
	int inv = quick_pow(len, mod - 2);
	for(int i = 0; i < len; ++i)
		x[i] = mul(x[i], inv);
	return ;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

#define MOD 1e+9;

using namespace std;

auto f=[](){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
};

int main()
{
	f();
	int N, R;
	cin>>N>>R;
	cout<<(N>=10?R:(R+(100*(10-N))))<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,a;
  cin>>n>>a;
  int x[n+1]={};
  int y[n+1]={};
  int m=a;
  for(int i=1;i<=n;i++){
    cin>>x[i];
    y[i]=x[i]-a;
    m=max(m,x[i]);
  }
  ll dp[n+1][2*n*m+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=2*n*m;j++){
      dp[i][j]=0;
    }
  }

  dp[0][n*m]=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=i;j++){
      for(int k=0;k<=2*n*m;k++){
        if(k-y[j]<0||k-y[j]>2*n*m){
          dp[j][k]=dp[j-1][k];
        }else if(0<=k-y[j]&&k-y[j]<=2*n*m){
          dp[j][k]=dp[j-1][k]+dp[j-1][k-y[j]];
        }
      }
    }
  }
  cout<<dp[n][n*m]-1<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
int isprime(int n) {
	int i;
	for(i = 2; i * i <= n; i++) {
		if(n % i == 0) return 0;
	}
	return 1;
}

int main(){
	int n,i,k;
	int max = 2;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i = n;i > 2;i--){
			if(isprime(i)==1 && isprime(i-2)==1){
				max = i;
				break;
			}
		}
		
		printf("%d %d\n",max-2,max);
		max = 2;
	}
	
	return 0;
}

Measured memory_bytes: 596
from collections import defaultdict

N = int(input())
nums = {}

for _ in range(N):
    a = int(input())
    if a in nums:
        nums[a] = (nums[a] + 1) % 2
    else:
        nums[a] = 0

cnt = 0

for key,value in nums.items():
    if value == 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 15456
#include<stdio.h>
#include<string.h>
int main(void){
  int n,k;
  scanf("%d",&n);
  char s[n + 1];
  scanf("%s %d",&s,&k);
  for(int i = 0;i < n;i++){
    if(s[i] == s[k - 1]){
      printf("%c",s[i]);
    }else{
      printf("*");
    }
  }
  return 0;
}
//scanf("%d",&);
//printf("%d\n",);

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
  int a,b;
  char op;
  while(1){
    cin>>a>>op>>b;
    if(op=='+')printf("%d\n",a+b);
    else if(op=='-')printf("%d\n",a-b);
    else if(op=='/')printf("%d\n",a/b);
    else if(op=='*')printf("%d\n",a*b);
    else break;
  }
  return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstring>
#include<iomanip>
#include<list>
#include<algorithm>
using namespace std;

int main()
{
	int a[12];
	for(int i=0;i<12;i++)
	{
		cin>>a[i];
	}
	sort(a,a+12);
	int f=0;
	for(int i=0;i<3;i++)
	{
		if(a[i*4]==a[i*4+1]&&a[i*4+1]==a[i*4+2]&&a[i*4+2]==a[i*4+3])
		{
			f+=1;
		}
	}
	if(f==3)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>

int main()
{
int x,n,cou;
cou=0;
while(1)
{
	cou=0;
scanf("%d",&n);scanf("%d",&x);
if(x==0&&n==0)break;
for(int i=1;i<=n-2;i++){
for(int j=i+1;j<=n-1;j++){
for(int k=j+1;k<=n;k++)
{
if(i+j+k==x)cou++;
}}}
printf("%d\n",cou);
}
return 0;
}

Measured memory_bytes: 1028
q, h, s, d = gets.split.map(&:to_i)
n = gets.to_i

h = 2 * q <= h ? 2 * q : h
s = 2 * h <= s ? 2 * h : s

if n == 1
  puts s
elsif n == 2
  puts [s, d].min
else
  d = 2 * s <= d ? 2 * s : d

  div, mod = n.divmod(2)
  puts d * div + s * mod
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#ifndef MAX
#define MAX 400000
#endif

//Range Update Query+Range Sum Query
template<class T>
class RUQ_RSQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO, DEFAULT;
	void init(int n_, T d = LLONG_MAX, T t = 0) {
		DEFAULT = d;
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = t; lazy[i] = DEFAULT;
		}
	}
	inline void push(int k, int s) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k] * s%MOD;
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		dat[k] = (dat[k * 2 + 1] + dat[k * 2 + 2])%MOD;
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k, r - l); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return ZERO;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		return (lb+rb)%MOD;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};

RUQ_RSQ<ll>seg;

ll s[200000];

int main(){
	int n;ll a,b;scanf("%d%lld%lld",&n,&a,&b);
	if(a<b)swap(a,b);
	s[0]=LLONG_MIN/2;
	rep(i,n)scanf("%lld",&s[i+1]);
	rep(i,n-1){
		if(s[i+2]-s[i]<b){
			puts("0");return 0;
		}
	}
	n++;
	seg.init(n);
	seg.update(0,1);
	for(int i=1;i<n;i++){
		int id=upper_bound(s,s+n,s[i]-a)-s;
		seg.update(i,seg.query(0,id));
		if(s[i]-s[i-1]<b){
			seg.update(0,i-1,0);
		}
	}
	cout<<seg.query(0,n+1)<<endl;
}

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

using namespace std;

int main(){
  long n,p;
  cin >> n>>p;
  
  int a,even=0;
  long pow=1;
  for(int i=0;i<n;i++){
    cin >> a;
     pow*=2;
    if(a%2==0) even++;
  }
  
  if(even==n&&p==0) cout << pow << endl;
  else if(even==n&&p==1) cout << 0 << endl;
  else cout << pow/2 << endl;

}

Measured memory_bytes: 256
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i < (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i < (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()

//	cinからvectorへ入力
template<typename T>
istream& operator >> ( istream& is, vector<T>& vec ) {
    for( T& x: vec ) {
        is >> x;
    }
    return is;
}

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

	vector<int> D(K);
	cin >> D;

	vector<char> hatedChar(K);
	transform( ALL(D), hatedChar.begin(), [](int d){ return '0' + d; } );

	for( lint n=N; true; n++ ) {
		string s = to_string(n);
		bool flg = true;
		REP( k, K ) {
			if( s.find(hatedChar[k]) != string::npos ) {
				flg = false;
			}
		}
		if( flg ) {
			cout << s << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define mod 1000000007
#define mod 998244353
#define N 1000001
#define ll long long int
#define pr pair<ll,ll>
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define line cout<<'\n'
#define all(v) v.begin(),v.end()
#define rev(s) reverse(all(s))
using namespace std;

const ll INF = LLONG_MAX;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tt = 1;
    //cin>>tt;
    f(tc,1,tt){
        string s; cin>>s;
        ll n = s.size();
        f(i,0,n-1){
            if(s[i]=='?') s[i] = 'D';
        }
        cout<<s;
    }
    return 0;
}

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

ll move(ll i, ll j, ll sum, ll N, vector<vector<ll>>& A){
    if((i==1)&&(j==N-1)) return sum + A[i][j];
    else if(i==1) return move(i, j+1, sum+A[i][j], N, A);
    else if(j==N-1) return move(i+1, j, sum+A[i][j], N, A);
    else return max(move(i+1, j, sum+A[i][j], N, A), move(i, j+1, sum+A[i][j], N, A));
}

int main(){
    ll N;
    vector<vector<ll>> A(2);
    cin>>N;
    rep(i,2)rep(j,N){
        ll a;
        cin >> a;
        A[i].push_back(a);
    }
    ll r = move(0, 0, 0, N, A);
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

inline ll mod_pow(ll a, ll x, ll m)
{
	if (x == 0) return 1;

	ll res = mod_pow(a, x / 2, m);

	res *= res;
	res %= m;

	if (x % 2) {
		res *= a;
		res %= m;
	}

	return res;
}


int N, K;

signed main()
{
	cin >> N >> K;

	int mx = 0, mn = 0;
	int cur = 0;

	for (int i = 0; i < K; ++i) {
		mx += N - cur;
		mn += cur;
		cur++;
	}
	int ans = 0;
	while (cur <= N + 1) {
		ans += mx - mn + mod + 1;
		ans %= mod;
		mx += N - cur;
		mx %= mod;
		mn += cur;
		mn %= mod;
		ans %= mod;
		cur++;
	}

	cout<<ans<<endl;
}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  if(n%10==3)
    cout<<"bon";
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon";
  else
    cout<<"hon";
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<math.h>
#include<string.h>
#include<queue>

using namespace std;

#define M  100000+100
#define mod 998244353
typedef long long ll;

double dis[10][10];
struct node
{
    int x,y;
} state[10];
double cul(int x1,int y1,int x2,int y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)*1.0);
}
int a[10];
int main()
{
    int n,k=0;
    cin>>n;
    double ans=0;
    for(int i=1; i<=n; i++)
    {
        cin>>state[i].x>>state[i].y;
        a[i]=i;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dis[i][j]=cul(state[i].x,state[i].y,state[j].x,state[j].y);
            //cout<<"i"<<i<<" j="<<j<<" "<<dis[i][j]<<endl;
        }
    }
    do
    {
        double sum=0;
         for(int i=1; i<n; i++)
         {
             sum+=dis[a[i]][a[i+1]];
         }
         //cout<<sum<<" ";
         ans+=sum;
         k++;
    }while(next_permutation(a+1,a+n+1));
    //cout<<k<<endl;
    printf("%.10f",ans/k);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(i%2 == 0) {
            ans += a[i];
        }
        else {
            ans -= a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n,k;
  cin>>n>>k;
  vec p(n);
  dvec r(n);
  rep(i,n) {
    cin>>p[i];
    r[i]=(p[i]+1.0)/2.0;
  }
  double sum=0.0,ans=0.0;
  queue<double>q;
  rep(i,n){
    sum+=r[i];
    q.push(r[i]);
    if(q.size()>k){
      sum-=q.front();
      q.pop();
    }
    if(q.size()==k){
      ans=max(sum,ans);
    }
  }
  cout<<fixed<<setprecision(6)<<ans<<endl;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		String s = sc.next();
		sc.close();

		if(a < 3200) {
			System.out.println("red");
		}else {
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <utility>
#include <vector>
#include <deque>
#include <climits>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

struct T {
	struct N {
		int p, m;
	};
	vector<N> t;
	T (int n) {
		t.resize(n);
		t[0] = {0, 0};
		for (int i: range(1, n))
			t[i] = {(int) in - 1, INT_MAX};
	}
	int Q (int v, int i) {
		if (t[v].m < i)
			return v;
		else
			return t[v].p = Q(t[v].p, i);
	}
	void M (int v, int i) {
		if (t[v].m == INT_MAX)
			t[v].m = i;
	}
};


struct Q {
	int v, i;
};

int main() {
	for (int N, M; N = in, M = in;) {
		T t(N);
		deque<Q> q;
		for(int i: range(1, M + 1)) {
			char c {in};
			int v {in};
			if (c == 'Q')
				q.push_front({v - 1, i});
			else
				t.M(v - 1, i);
		}
		long r {};
		for (auto i: q)
			r += t.Q(i.v, i.i) + 1;
		outl(r);
	}
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

//void file(){

//	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt" , "r" , stdin);
//	freopen("output.txt" , "w" , stdout);
//	#endif
//}

//int fact(int n){
//	if(n==0 || n==1)
//		return 1;
//	else return n*fact(n-1);
//}

//int comb(int n , int r){
//	return (fact(n)/(fact(r)*fact(n-r)));
//}

int32_t main(){	
	//file();
	int n,m;
	cin >> n >> m;
	int ans = 0;
	if(n >= 2){
		ans +=(n*(n-1)/2);
	}
	if(m>=2){
		ans+=(m*(m-1)/2);
	}
	cout << ans << endl;

}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = 3;
  if (a - b == 0) {
    x--;
  }
  if (b - c == 0) {
    x--;
  }
  if (c - a == 0) {
    x--;
  }
  if (x == 0) {
    x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
// cnt + 1, cnt - 1
ll beki[2][200010];
ll ans[200010];
ll f(ll X, int cnt = 1){
    if(X == 0)return cnt;
    ll M = __builtin_popcount(X);
    return f(X%M, cnt+1);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    string X;
    cin >> N >> X;
    reverse(all(X));
    int cnt = 0;
    rep(i,N)cnt += X[i] == '1';
    ll tmp = 1;
    rep(i,N){
        beki[0][i] = tmp % (cnt+1);
        tmp *= 2;
        tmp %= (cnt+1);
    }
    tmp = 1;
    rep(i,N){
        if(cnt - 1 == 0){
            beki[1][i] = -1;
            continue;
        }
        beki[1][i] = tmp % (cnt - 1);
        tmp *= 2;
        tmp %= (cnt - 1);
    }
    ll X0[2] = {0,0};
    rep(j,2){
        ll M = cnt;
        if(j == 0)M++;
        else M--;
        rep(i,N){
            if(M == 0)break;
            if(X[i] == '1')X0[j] += beki[j][i];
            X0[j] %= M;
        }
    }
    rep(i,N){
        ll M = cnt;
        ll tmpX;
        if(X[i] == '1'){
            M--;
            if(M == 0){
                ans[i] = 0;
                continue;
            }
            tmpX = X0[1];
            tmpX -= beki[1][i];
            tmpX += M;
            tmpX %= M;
        }
        else{
            M++;
            tmpX = X0[0];
            tmpX += beki[0][i];
            tmpX %= M;
        }
        ans[i] = f(tmpX);
    }
    rep(i,N){
        cout << ans[N-1-i] << endl;
    }
}



Measured memory_bytes: 8440
#include<stdio.h>
void print_array(int a[], int n){
int i = 0;
    for(i = 0; i<n-1; i++)
        printf("%d\n",a[i]);
    printf("%d\n",a[i]);
}
int insertion_sort(int a[], int n, int g){
	int cnt =0;
	for(int i = g; i<n; i++){
		int v = a[i];
		int j = i-g;
		while(j>=0 && a[j]>v){
			a[j+g] = a[j];
			j = j-g;
			cnt++;
		}
		a[j+g] = v;
	}
	return cnt;
}
//shell sort: th gap: 3*i+1: 1,4,13
void shell_sort(int a[], int n){
	int cnt = 0;
	int m = 1;
	int g[n+1];
	int k[n+1];
	k[0] = 1;
	for(int i = 1; i<n; i++){
		if(3*k[i-1]+1>n) break;
		k[i] = k[i-1]*3+1;
		m++;
	}
	for(int i = 0; i<m; i++){
		g[i] = k[m-1-i];
	}
	for(int i = 0; i<m; i++)
		cnt+=insertion_sort(a, n,g[i]);
	printf("%d\n",m);
	for(int i = 0;i < m-1; i++) printf("%d ",g[i]);
	printf("%d\n",g[m-1]);
	printf("%d\n",cnt);
	print_array(a,n);
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n+1];
	for(int i = 0; i<n; i++) scanf("%d",&a[i]); 
	shell_sort(a,n);
	
	return 0;
}


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

int main() {
  ll N;
  ll D;
  cin >> N >> D;
  
  ll count=0;
  for(int i=0;i<N;i++){
    ll X,Y;
    cin >> X >>Y;
    
    if((X*X+Y*Y)<=(D*D)){
      count++;
    }
  }
  cout << count << endl;   
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	var N int
	fmt.Scanf("%d", &N)
	count := make(map[string]int, 0)

	for _, s := range []string{"AC", "WA", "TLE", "RE"} {
		count[s] = 0
	}

	for i := 0; i < N; i++ {
		S := readline()
		count[S] += 1
	}
	for _, s := range []string{"AC", "WA", "TLE", "RE"} {
		fmt.Println(s, "x", count[s])
	}
}

func readline() string {
	buf := make([]byte, 0, 16)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }


Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3],k,ans;
    cin>>a[0]>>a[1]>>a[2]>>k;
    sort(a,a+3);
    for(int i=0;i<k;i++){
        a[2]=a[2]*2;
    }
    ans=a[0]+a[1]+a[2];
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e4+10;
int n,a[N],d[N],ans[N],flag[N];
vector<int>e[N];

int main(){
	n=read();
	FOR(i,1,n){
		int x=read(),y=read();
		e[x].pb(y),e[y].pb(x);
	}
	poly vec;
	For(i,1,n){
		d[i]=siz(e[i]);
		if (d[i]==1) vec.pb(i);
	}
	For(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	ll sum=0;
	FOR(i,1,n){
		int u=vec.back();vec.pop_back();
		flag[u]=1,ans[u]=a[i];
		for (auto v:e[u]) if (!flag[v]){
			--d[v],sum+=a[i];
			if (d[v]==1) vec.pb(v);
		}
	}
	For(i,1,n) if (!flag[i]) ans[i]=a[n];
	printf("%lld\n",sum);
	For(i,1,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 4444
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#endif

#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;

int main(){
	fastIO;
	int n;
	cin >> n;
	int cm = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i & 1) cm++;
	}
	cout << (double)cm / n;
	return 0;
}



Measured memory_bytes: 3792
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a,&b);
    if((a+b)%2 == 0){
        printf("%d\n", (a+b)/2);
    }
    else{
        printf("%s\n", "IMPOSSIBLE");
    }
    return 0; 
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int a, b;
	cin >> a >> b;
	if (abs(a - b) % 2 == 1)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<string,ll> m;
    for(int i=0;i<n;i++){
        sort(s[i].begin(),s[i].end());
        m[s[i]]++;
    }
    ll ans=0;
    for(auto it = m.begin();it != m.end();it++){
        ans += (it->second)*(it->second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18176
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var n = next();
  if(n === 1)return 1;
  var x1 = n;
  var x2 = 2;
  while(x1 % 2 === 0)x1 /= 2, x2 *= 2;
  var n2 = n*2, ans = n2-1;
  for(var i = 1; i*i <= x1; i+=2){
    if(x1 % i)continue;
    var u = x1 / i;
    var f1 = f(u,i*x2), f2 = f(u*x2,i);
    ans = Math.min(ans, f1, f2);
  }
  return ans;
}
function f(u,v){
  var [a,b,c] = exgcd(u,v);
  if(c > 1)return 9e15;
  if(a < 0)return -a*u;
  if(b < 0)return -b*v;
  return 9e15;
}
function exgcd(x,y){
  var a0 = 1n, a1 = 0n, b0 = 0n, b1 = 1n;
  x = BigInt(x), y = BigInt(y);
  while(y){
    var q1 = x / y;
    var r2 = x % y;
    var a2 = a0 - q1*a1;
    var b2 = b0 - q1*b1
    x = y, y = r2;
    a0 = a1, a1 = a2;
    b0 = b1, b1 = b2;
  }
  return [Number(a0),Number(b0),x];
}

Measured memory_bytes: 35808
x, y = map(int, input().split())

ans = int(1e20)

# yを作る
if y >= x:
    ans = min(ans, y - x)
if y >= -x:
    ans = min(ans, y - (-x) + 1)

# -yを作る
if -y >= x:
    ans = min(ans, (-y) - x + 1)

if -y >= -x:
    ans = min(ans, (-y) - (-x) + 2)

print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

int n;

int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	cin >> n;
	bool ans = false;
	int acu = 0;
	while(n--) {
		int x, y;
		cin >> x >> y;
		if(x == y) acu++;
		else acu = 0;
		if(acu == 3) ans = true;
	}
	cout << (ans ? "Yes" : "No") << '\n';

	return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long

int main()
{
    LL d[4];
    LL  n;
    while(~scanf("%lld%lld%lld%lld%lld",&d[0],&d[1],&d[2],&d[3],&n))
    {
        LL t = n/2;
        LL x = n-(2*t);
        d[0]*=4;
        d[1]*=2;
        sort(d,d+3);
        LL ans=0;
        ans+=d[0]*x;
        for(int i = 0;i < 3; i++)
        {
            d[i]*=2;
        }
        sort(d,d+4);
        ans+=t*d[0];
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 256
a, b = (int(x) for x in input().split())

c_list = []
b_list = []


def f(n, tax, list):
    limit = n + 1
    while(n < limit):
        list.append(int(n / tax))
        n += tax / 2

f(b, 0.1, b_list)

for i in b_list:
    tmp = int(i * 0.08)
    if(tmp == a):
        c_list.append(i)



if(len(c_list) == 0):
    print(-1)
else:
    print(int(min(c_list)))


Measured memory_bytes: 3064
'use strict'

const main = (arg) => {
  const input = arg.split('\n')
  const tmp = input.shift()
  const A = Number(tmp[0])
  const B = Number(tmp[1])
  const M = Number(tmp[2])

  const aAry = input.shift().split(' ').map(n => Number(n))
  const bAry = input.shift().split(' ').map(n => Number(n))
  let ans = Math.min(...aAry) + Math.min(...bAry)

  for (let i = 0; i < input.length; i++) {
    const tmp = input[i].split(' ')

    if (ans > aAry[tmp[0] - 1] + bAry[tmp[1] - 1] - tmp[2]) {
      ans = aAry[tmp[0] - 1] + bAry[tmp[1] - 1] - tmp[2]
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 54552
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
ans = 0
for i in range(1, n+1):
    if i%5 != 0 and i%3 != 0:
        ans += i
print(ans)

Measured memory_bytes: 9192
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++)
        os << v[i] << (i+1<v.size()?", ":"");
    os << "}";
    return os;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
//}}}

const int BASE = 10000;
typedef vector<int> Num;
Num normalize(Num c) {
    int carry = 0;
    for(int i = 0; i < c.size(); i++) {
        c[i] += carry;
        carry = c[i] / BASE;
        c[i] %= BASE;
    }
    if(carry > 0) c.push_back(carry);
    return c;
}
Num mul(const Num& a, const Num& b) {
    int n = a.size();
    int m = b.size();
    Num c(n-1 + m-1 + 1);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            c[i+j] += a[i] * b[j];
        }
    }
    return normalize(c);
}
Num add(const Num& a, const Num& b) {
    Num c(max(a.size(), b.size()));
    for(int i = 0; i < c.size(); i++) {
        if(i < a.size()) c[i] += a[i];
        if(i < b.size()) c[i] += b[i];
    }
    return normalize(c);
}
Num pow(Num a, int b) {
    Num res = {1};
    while(b > 0) {
        if(b & 1) res = mul(res, a);
        a = mul(a, a);
        b /= 2;
    }
    return res;
}
void output(Num a) {
    const vector<string> unit = {
        "",
        "Man",
        "Oku",
        "Cho",
        "Kei",
        "Gai",
        "Jo",
        "Jou",
        "Ko",
        "Kan",
        "Sei",
        "Sai",
        "Gok",
        "Ggs",
        "Asg",
        "Nyt",
        "Fks",
        "Mts"
    };
    for(int i = a.size() - 1; i >= 0; i--) {
        if(a[i] != 0) {
            cout << a[i] << unit[i];
        }
    }
    cout << endl;
}

int main(){
    iostream_init();
    int A, B;
    while(cin >> A >> B && A > 0) {
        Num C = {A};
        output(pow(C, B));
    }
    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1224