akhauriyash/Code-Regression huggingface dataset:
#include <stdint.h>
#include <utility>
#include <vector>
#include <numeric>
#include <string>
#include <iostream>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

int minv(int n) {
	int res = 1;
	for (int i = MOD - 2; i; i >>= 1) {
		if (i & 1) res = (int64_t) res * n % MOD;
		n = (int64_t) n * n % MOD;
	}
	return res;
}
struct RollingHash {
	int base;
	std::vector<int> accumulated, beki, inv;
	RollingHash () = default;
	RollingHash (int base, const std::string &s) : base(base) {
		int n = s.size();
		accumulated.resize(n + 1);
		beki.resize(n + 1, 1);
		inv.resize(n + 1);
		for (int i = 0; i < n; i++) {
			beki[i + 1] = (int64_t) beki[i] * base % MOD;
			accumulated[i + 1] = (accumulated[i] + (int64_t) s[i] * beki[i]) % MOD;
		}
		inv[n] = minv(beki[n]);
		for (int i = n; i--; ) inv[i] = (int64_t) inv[i + 1] * base % MOD;
	}
	int substr(int l, int r) {
		int res = accumulated[r] - accumulated[l];
		if (res < 0) res += MOD;
		return (int64_t) res * inv[l] % MOD;
	}
};

#define INF 1000000000

int main() {
	std::string s, t;
	std::cin >> s >> t;
	for (auto &i : s) i -= 'a';
	for (auto &i : t) i -= 'a';
	int n;
	{
		std::string s_bak = s;
		while (s.size() < t.size()) s += s_bak;
		n = s.size();
		s += s;
	}
	constexpr int bases[] = {998244353, 874899298, 372312948};
	RollingHash shash[3], thash[3];
	for (int i = 0; i < 3; i++) {
		shash[i] = RollingHash(bases[i], s);
		thash[i] = RollingHash(bases[i], t);
	}
	int m = t.size();
	bool ok[n];
	for (int i = 0; i < n; i++) {
		bool match = true;
		for (int j = 0; j < 3; j++) if (shash[j].substr(i, i + m) != thash[j].substr(0, m)) match = false;
		ok[i] = match;
	}
	int res = 0;
	std::vector<bool> used(n);
	for (int i = 0; i < n; i++) {
		if (used[i]) continue;
		std::vector<bool> cur;
		for (int j = i; !used[j]; j = (j + m) % n) used[j] = true, cur.push_back(ok[j]);
		if (std::accumulate(cur.begin(), cur.end(), 0) == (int) cur.size()) res = INF;
		else {
			std::vector<int> compressed{0};
			for (auto j : cur) {
				if (j) compressed.back()++;
				else if (compressed.back()) compressed.push_back(0);
			}
			if (!compressed.back()) compressed.pop_back();
			if (cur.front() && cur.back()) compressed.front() += compressed.back(), compressed.pop_back();
			for (auto i : compressed) res = std::max(res, i);
		}
	}
	printf("%d\n", res == INF ? -1 : res);
	return 0;
}


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

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	/*
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	*/
	int a,b,k;
	cin >> a >> b >> k;
	for(int i = 0; i < k; i++){
		if(i & 1){
			if(b & 1) b--;
			a += (b/2);
			b /= 2;
		}
		else{
			if(a & 1) a--;
			b += (a/2);
			a /= 2;
		}
	}
	cout << a << " " << b;
}

Measured memory_bytes: 256
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-7;
const double INF=1e77;

struct point{
	double x,y;
	point():x(0),y(0){}
	point(double x,double y):x(x),y(y){}
	point operator+(const point &a)const{ return point(x+a.x,y+a.y); }
	point operator-(const point &a)const{ return point(x-a.x,y-a.y); }
	bool operator< (const point &a)const{ return x+EPS<a.x || abs(x-a.x)<EPS && y+EPS<a.y; }
};

point operator*(double c,const point &a){ return point(c*a.x,c*a.y); }

double dot(const point &a,const point &b){ return a.x*b.x+a.y*b.y; }

double cross(const point &a,const point &b){ return a.x*b.y-a.y*b.x; }

double abs(const point &a){ return sqrt(a.x*a.x+a.y*a.y); }

struct line{
	point a,b;
	line(const point &a,const point &b):a(a),b(b){}
};

struct segment{
	point a,b;
	segment(const point &a,const point &b):a(a),b(b){}
};

bool cover(const segment &S,const point &p){
	return abs(cross(S.a-p,S.b-p))<EPS && dot(S.a-p,S.b-p)<EPS;
}

point get_intersect(const line &L1,const line &L2){
	double a1=cross(L1.b-L1.a,L2.b-L2.a);
	double a2=cross(L1.b-L1.a,L1.b-L2.a);
	if(abs(a1)<EPS) return L1.a;
	return L2.a+a2/a1*(L2.b-L2.a);
}

struct edge{ int v; double cost; };

int main(){
	for(int n;scanf("%d",&n),n;){
		double v1,v2; scanf("%lf%lf",&v1,&v2);
		point p[2000];
		rep(i,n) scanf("%lf%lf",&p[i].x,&p[i].y);

		vector<edge> G[2000];
		int n2=0;
		rep(i,n){
			// dig right
			if(i<n-1 && p[i].y<p[i+1].y){
				int j=i+1;
				while(j<n && p[i].y<p[j].y) j++;
				if(j<n){
					p[n+n2]=get_intersect(line(p[j-1],p[j]),line(p[i],p[i]+point(1,0)));
					G[i].push_back((edge){n+n2,abs(p[i]-p[n+n2])/v2});
					n2++;
				}
			}
			// dig left
			if(i>0 && p[i].y<p[i-1].y){
				int j=i-1;
				while(j>=0 && p[i].y<p[j].y) j--;
				if(j>=0){
					p[n+n2]=get_intersect(line(p[j+1],p[j]),line(p[i],p[i]+point(1,0)));
					G[n+n2].push_back((edge){i,abs(p[i]-p[n+n2])/v2});
					n2++;
				}
			}
		}

		rep(i,n-1){
			vector< pair<point,int> > Q;
			rep(j,n+n2){
				if(cover(segment(p[i],p[i+1]),p[j])) Q.push_back(make_pair(p[j],j));
			}
			sort(Q.begin(),Q.end());
			rep(j,(int)Q.size()-1){
				int u=Q[j].second,v=Q[j+1].second;
				G[u].push_back((edge){v,abs(Q[j+1].first-Q[j].first)/v1});
			}
		}

		double d[2000];
		rep(u,n+n2) d[u]=(u==0?0:INF);

		priority_queue< pair<double,int> > Q;
		Q.push(make_pair(0,0));
		while(!Q.empty()){
			double d_now=-Q.top().first;
			int u=Q.top().second; Q.pop();

			if(d[u]<d_now-EPS) continue;

			rep(i,G[u].size()){
				int v=G[u][i].v;
				double cost=G[u][i].cost;
				if(d[v]>d[u]+cost+EPS){
					d[v]=d[u]+cost;
					Q.push(make_pair(-d[v],v));
				}
			}
		}
		printf("%.9f\n",d[n-1]);
	}

	return 0;
}

Measured memory_bytes: 1336
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=1e6+10;
int a[N];
int main()
{
	int n,m,q;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
		for(int k=1;k<=n;k++){
			ans+=__gcd(__gcd(i,j),k);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3632
// ===== 2018/06/16 21:01:03 =====

// ../../../lib/template/includes.hpp

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// ../../../lib/template/const_value.hpp

namespace sub {
  template <typename T>
  constexpr typename std::enable_if<std::is_integral<T>::value, T>::type
  inf_sub() {
    return std::numeric_limits<T>::max() / 2 - 1000;
  }

  template <typename T>
  constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type
  inf_sub() {
    return std::min(std::numeric_limits<T>::max() / 2 - 1000, T(1e50));
  }
}

template <typename T> constexpr T inf() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return sub::inf_sub<T>();
}

template <typename T> constexpr T zero() {
  static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
  return T(0);
}

const long double pi = acos(-1.0);

// ../../../lib/template/initialize.cpp

struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

struct Initialize {
  Initialize() {
    std::locale loc(std::locale(), new yes_no);
    std::cout << std::boolalpha << std::setprecision(11) << std::fixed;
    std::cout.imbue(loc);
  }
};

const Initialize init;

// ../../../lib/template/macros.hpp

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

// ../../../lib/template/misc.hpp

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }

template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// ../../../lib/template/range.hpp

class range {
  class index_type {
    int x;

  public:
    index_type(int x_) : x(x_) {}
    int operator*() const { return x; }
    bool operator!=(index_type &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  index_type i, n;

public:
  range(int n_) : i(0), n(n_) {}
  range(int i_, int n_) : i(i_), n(n_) {}
  index_type &begin() { return i; }
  index_type &end() { return n; }
};

// ../../../lib/template/typedef.hpp

using ll = long long;
using ld = long double;
using Point = std::complex<ld>;

// ../../../lib/template/template.cpp

using namespace std;

// A.cpp

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

void solve(ll A, ll B) {
  ll c = max(A, B);
  if (c > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

int main() {
	ll A;
	ll B;
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(A, B);
	return 0;
}
// ===== 2018/06/16 21:01:03 =====



Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e4 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int mp[N];
		clr(mp,0);
		rep(i,1,100)
		{
			rep(j,1,100)
			{
				rep(k,1,100)
				{
					int c = i*i + j*j + k*k + i*j + i*k + j*k;
					if(c<=10000)
						mp[c]++;
				}
			}
		}
		rep(i,1,n)
		{
			cout << mp[i] << endl;
		}
	}
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int i, one_c=0, two_c=0;
	char s[4], one, two;
	for (i = 0; i < 4; i++){
		scanf("%c", &s[i]);
	}
for (i = 0; i < 4; i++) {
	if (s[0] != s[i]) {
		one =s[0];
		two =s[i];
	}
}

for (i = 0; i < 4; i++) {
	if (s[i]==one) {
		one_c++;
	}
	if (s[i] == two) {
		two_c++;
	}
}

if (one_c == 2 && two_c == 2) {
	puts("Yes");
}
else {
	puts("No");
}
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,a;
set<int> s;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a);
		if(s.find(a)!=s.end()) {
			cout<<"NO";
			return 0;
		}
		s.insert(a);
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdlib>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int a,b,c,da,db,dc,ans;
int main(){
  cin>>a>>b>>c;
  if(a%2==1 || b%2==1 || c%2==1){
      cout<<0<<endl;return 0;
  }
  da=a;db=b;dc=c;ans=0;
  do{
    int ah=da/2,bh=db/2,ch=dc/2;
    da=bh+ch;db=ah+ch;dc=ah+bh;
    ans++;
    if(da==a && db==b && dc==c){
      cout<<-1<<endl;return 0;
    }
  }while(da%2==0 && db%2==0 && dc%2==0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int sum_of_digit(int x) {
	int sum = 0;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}


int main()
{
	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;
	for (int x = 1; x <= n; x++) {
		int sum = sum_of_digit(x);
		if (a <= sum && sum <= b) ans += x;
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] number = new int[n];
        for(int i = 0;i<n;i++){
            number[i] = sc.nextInt();
        }
        Arrays.sort(number);
        int[] number2 = new int[n];
        for(int i = 0;i<n;i++){
            number2[i] = number[n-i-1];
        }
        int a = 0;
        int b = 0;
        for(int i = 0;i<n;i++){
            if(i%2 == 0){
                a += number2[i];
            }
            if(i%2 == 1){
                b += number2[i];
            }
        }
        System.out.println(a-b);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int count=0;
    for(int i=0;i<N;i++){
        int k,m;
        cin >> k >> m;
        if(k==m){
            count++;
        }else{
            count=0;
        }
        if(count == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3584
# ABC128C - Switches
import sys
from itertools import product

input = sys.stdin.readline


n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
con = list(map(int, input().rstrip().split()))
ans = 0
for i in product(range(2), repeat=n):
    cnt = 0
    for j in range(m):
        ons = 0
        for k in lst[j][1:]:
            if i[k - 1] == 1:
                ons += 1
        if ons % 2 == con[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)

Measured memory_bytes: 3064
a=input()
b=input()
c=input()
s=[a,b,c]
player=0
now=[0,0,0]
while 1:
  if now[player]==len(s[player]):
    print(chr(65+player))
    break
  else:
    if s[player][now[player]]=='a':
      now[player]+=1
      player=0

    elif s[player][now[player]]=='b':
      now[player]+=1
      player=1

    elif s[player][now[player]]=='c':
      now[player]+=1
      player=2

Measured memory_bytes: 3064
#!/usr/local/bin/python3.7

K, X = map(int, input().split())

min_range = X - K + 1
max_range = X + K

ans = []

for i in range(min_range, max_range):
    ans.append(i)
for i in range(0, len(ans)):
    print(ans[i], end=" ")


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int S=0,b=0,result=0;
    cin >> S;
    b = S;
    while (1){
        result = result + b  % 10;
        b = b / 10;
        if (b<=0){
            break;
        }
    }

//   cout << S << "," << result <<endl;

    if (S % result ==0){
        cout <<"Yes"<<endl;
    } else {
        cout <<"No"<<endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = ["0"] + S()
    n = n[::-1]
    dp1 = [inf] * (len(n))
    dp2 = [inf] * (len(n))
    dp1[0] = int(n[0])
    dp2[0] = 10-int(n[0])
    for i in range(len(n)-1):
        x = int(n[i+1])
        if dp1[i] + x < dp1[i + 1]:
            dp1[i + 1] = dp1[i] + x
        if x != 0:
            if dp1[i] + (10 - x) < dp2[i + 1]:
                dp2[i + 1] = dp1[i] + (10 - x)
        x += 1
        if x != 10:
            if dp2[i] + x < dp1[i + 1]:
                dp1[i + 1] = dp2[i] + x
        if dp2[i] + (10 - x) < dp2[i + 1]:
            dp2[i + 1] = dp2[i] + (10 - x)

    print(min(dp1[-1],dp2[-1]))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 157260
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    int n, x; cin >> n >> x;
    int m[n];

    for (int i=0;i<n;i++){
        cin >> m[i];
    }

    sort(m, m+n);

    int total = 0;
    int count = n;

    for (int i=0;i<n;i++){
        total += m[i];
    }
    
    while(x >= (total + m[0])){
        total += m[0];
        count ++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import bisect

def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [fetch_int_input() for _ in range(times)]


PREF, YEAR = 0, 1

N, M = fetch_int_input()
data = fetch_int_inputs(M)

pre_save = [[] for _ in range(N)]
for d in data:
    pre_save[d[PREF] - 1].append(d[YEAR])

for p in pre_save:
    p.sort()


def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError


for d in data:
    left = str(d[PREF]).zfill(6)
    right = str(index(pre_save[d[PREF] - 1], d[YEAR]) + 1).zfill(6)
    print(left+right)



Measured memory_bytes: 74204
#include<bits/stdc++.h>
using namespace std;
const int N=400005;
int tot,n,a[N],b[N],ans,A[N],B[N],f[N];
int ef(int x){
	int l=1,r=tot;
	while (l<r){
		int mid=(l+r)/2;
		if (A[mid]<x)l=mid+1;
		else r=mid;
	}
	return l;
}
int find(int x){
	if (x==f[x])return x;
	return f[x]=find(f[x]);
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++)scanf("%d",&a[i]),a[n]^=a[i];
	for (int i=0;i<n;i++)scanf("%d",&b[i]),b[n]^=b[i];
	int flag=1;
	for (int i=0;i<n;i++)
		if (a[i]!=b[i])flag=0;
	if (flag){
		puts("0");
		return 0;
	}	
	for (int i=0;i<=n;i++)A[i]=a[i],B[i]=b[i];
	sort(A,A+n+1);sort(B,B+n+1);
	for (int i=0;i<=n;i++)
		if (A[i]!=B[i]){
			puts("-1");
			return 0;
		}
	tot=0;	
	for (int i=0;i<=n;i++)
		if (a[i]!=b[i]||i==n){
			A[++tot]=a[i];
			A[++tot]=b[i];
			if (i<n)ans++;
		}	
	sort(A+1,A+tot+1);
	int num=1;
	for (int i=2;i<=tot;i++)
		if (A[i]!=A[num])A[++num]=A[i];
	tot=num;ans+=num;ans--;
	for (int i=1;i<=num;i++)f[i]=i;
	for (int i=0;i<=n;i++)
		if (a[i]!=b[i]){
			int k1=ef(a[i]),k2=ef(b[i]);
			if (find(k1)!=find(k2))f[find(k1)]=find(k2),ans--;
		}
	printf("%d\n",ans);	
	return 0;	
}

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

ll tri(ll x) {
  return x*x*x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  if(k % 2 == 1) {
    cout << tri(n/k) << "\n";
    return 0;
  }
  else {
    cout << tri(n/k) + tri(n/(k/2) - (n/k)) << "\n";
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
typedef vector<int> vi;

int main(void) {
	int n;
	cin >> n;
	string str;
	cin >> str;
	vi a(n, 0);
	vi b(n, 0);
	REP(i, n){
		if(i) a[i] = a[i-1];
		if(str[i] == 'W') a[i]++;
	}
	RREP(i, n){
		if(i != n-1) b[i] = b[i+1];
		if(str[i] == 'E') b[i]++;
	}
	int ans = min(a[n-1], b[0]);
	for(int i = 1; i < n - 1; i++) {
		ans = min(ans, a[i-1] + b[i+1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	vector<int> a(q), v(q); rep(i, 0, q) {
		cin >> a[i] >> v[i]; a[i]--;
	}
	using T = tuple<int, int>;
	priority_queue<T> pq;
	rep(i, 0, n)pq.emplace(0, -i);
	vector<int> point(n);
	rep(i, 0, q) {
		point[a[i]] += v[i];
		pq.emplace(point[a[i]], -a[i]);
		while (true) {
			int p, u; tie(p, u) = pq.top(); pq.pop();
			if (point[-u] != p)continue;
			cout << -u + 1 << " " << p << endl;
			pq.emplace(p, u);
			break;
		}
	}
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int r; std::cin >> r;
  std::cout << 2 * acos(-1) * r << "\n";
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}

Node treeMaximum(Node x){
 while(x->right != NIL)
    {
      x = x->right;
    }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;
  if(k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL)return treeMinimum(x->right);
  y = y->parent;
  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL)x = y->left;
  else x = y->right;
  if(x != NIL)x->parent = y->parent;
  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;
  if(y != z)z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)x = x->left;
      else x = x->right;
    }

  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
#!/usr/bin/env python
"""M-SOLUTIONS プロコンオープン 2020: B - Magic 2
https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
"""

import itertools


def is_success(cards):
    return cards[0] < cards[1] < cards[2]


def magic(A, B, C, K):
    for n in range(1, K + 1):
        for c in itertools.combinations([0, 1, 2] * n, n):
            cards = [A, B, C]
            for i in range(n):
                cards[c[i]] = cards[c[i]] * 2
            if is_success(cards):
                return True
    return False


def main():
    A, B, C = list(map(int, input().split()))
    K = int(input())

    if magic(A, B, C, K):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8756
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

long long solve(long long n) {
  n++;
  long long ans = 0;
  for (int i = 0; i < 40; i++) {
    long long loop = (long long)1 << (i + 1);
    long long num = (n / loop) * (loop / 2);
    //余った分
    num += max((long long)0, (n % loop) - (loop / 2));

    if (num % 2 == 1) ans += (long long)1 << i;
  }

  return ans;
}

int main() {
  long long a, b;
  cin >> a >> b;
  cout << (solve(a - 1) ^ solve(b)) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		char c[] = s.toCharArray();
		int max = 0;
		int ans = n;
		int nenn=0;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'E') {
				max++;
			}
		}
		nenn=max;
		for (int i = 0; i < n; i++) {
			if (c[i] == 'E') {
				max--;
			} else {
				max++;
			}
			if (ans > max) {
				ans = max;

}
		}
		System.out.println(Math.min(nenn, ans));
	}
}

Measured memory_bytes: 29108
#include<bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  int H = 100, W = 100, h = 50, w = 49;
  vector<vector<char>> S(H, vector<char>(W, '#'));
  for(auto i=0; i<h; ++i) for(auto j=0; j<W; ++j) S[i][j] = '.';
  for(auto i=1; i<B; ++i) {
    auto y=1+2*(i/w);
    auto x=1+2*(i%w);
    S[y][x] = '#';
  }
  for(auto i=1; i<A; ++i) {
    auto y=h+1+2*(i/w);
    auto x=1+2*(i%w);
    S[y][x] = '.';
  }
  cout << H << " " << W << endl;
  for(auto i: S) {
    for(auto j: i) cout << j;
    cout << endl;
  }
}


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

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

  vector<long long> Lucas(N+1);
  Lucas.at(0) = 2;
  Lucas.at(1) = 1;
  for(int i = 2;i <= N;i++) {
    Lucas.at(i) = Lucas.at(i-1) + Lucas.at(i-2);
  }

  cout << Lucas.at(N) << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}



// min
int main(void){

  int a, b;
  int ans = 0;

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

  ans = a + b;

  if(ans < a-b){
    ans = a-b;
  }

  if(ans < a * b){
    ans = a * b;
  }

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


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int accion,aux,i,j;
    string act;
    list<int> lista;
    cin >> accion;
    for(i=0;i<accion;i++){
        cin >> act;
        if(act=="insert"){
            cin >> aux;
            lista.push_front(aux);
            continue;
        }
        if(act=="delete"){
            cin >> aux;
            list<int>::iterator it = lista.begin();
            while(it!=lista.end()){
                if(*it==aux){
                 lista.erase(it);
                 break;
             }
             it++;
            }
             continue;
            /* for(j=0;j<lista.size();j++){
                if(*it==aux){
                    lista.erase(it);
                    break;
                }
                it++;
            }
            continue; */
        }
        if(act=="deleteFirst"){
            lista.pop_front();
            continue;
        }
        if(act=="deleteLast"){
            lista.pop_back();
            continue;
        }
    }
    aux=lista.size();
    for(i=0;i<aux;i++){
        cout << lista.front();
        if(i!=aux-1){
            cout << " ";
        }
        else{
            cout << endl;
        }
        lista.pop_front();
    }
    return 0;
}



Measured memory_bytes: 34352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll K;
    cin>>K;
    ll cur_num=0;
    ll next_add=7;
    ll ans=-1;
    for(int i=1;i<=K;i++){
        cur_num+=next_add;
        cur_num%=K;
        if(cur_num==0){
            ans=i;
            break;
        }
        next_add*=10;
        next_add%=K;
    }
    cout<<ans<<endl;
}


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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const ll M = 998244353;
const string END = "\n";

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

	int n, c[20], v[20];
	cin >> n;
	rep(i, n){
		cin >> v[i];
	}
	int ans = 0;
	rep(i, n){
		cin >> c[i];
		if(v[i]>=c[i]){
			ans += v[i] - c[i];
		}
	}
	cout << ans << END;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
   cin>>n>>h>>w;
   rep(i,n){
       cin>>a>>b;
       if(h<=a&&w<=b)ans++;
   }
   Cout(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int so[] = new int[n + 1];
        int count = 0;
        for (int i = 2; i <= n; i++) {
            int k = i;
            for (int j = 2; j <= i; j++) {
                while (k % j == 0) {
                    so[j]++;
                    k /= j;
                }
            }
        }
        Arrays.sort(so);
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 0;
        int e = 0;
        for (int i = 1; i <= n + 1; i++) {
            if (so[i - 1] < 2) {
                a = i;
            }
            if (so[i - 1] < 4) {
                b = i;
            }
            if (so[i - 1] < 14) {
                c = i;
            }
            if (so[i - 1] < 24) {
                d = i;
            }
            if (so[i - 1] < 74) {
                e = i;
            }
        }
        count += n + 1 - e;
        count += (n + 1 - d) * (n + 1 - a - 1);
        count += (n + 1 - c) * (n + 1 - b - 1);
        count += (n + 1 - b) * (n + 1 - b - 1) * (n + 1 - a - 2) / 2;
        System.out.println(count);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
long long const inf = 1e18;
int const mxn = 2e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
 
 
 long long f(long long x){
 		if (x==1)
 			return 1;
 		else
 			return 1+2*(f(x/2));
 }
 
 

 
int main(){
	long long h;
	cin>>h;
	cout<<f(h);
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i; i<n; i++){
    cin>>s.at(i);
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for(int i; i<m; i++){
    cin>>t.at(i);
  }
  int flag,top=0;
  for(int i=0; i<n; i++){
    flag=1;
    for(int j=i+1;i<j&&j<n; j++){
      if(s.at(i)==s.at(j))
        flag++;
    }

    for(int j=0; j<m; j++){
      if(s.at(i)==t.at(j))
        flag--;
    }
    if(flag>top)
      top=flag;
  }
  cout<<top<<endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch[20];
int main(){
	scanf("%s",ch+1);
	int len=strlen(ch+1);
	int t=0;
	for(int i=1;i<=len;i++)
		t+=ch[i]=='x';
	puts(t>7?"NO":"YES");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);

    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        P[i]--;
    }

    for (int i = 0; i < N; ++i) {
        cin >> C[i];
        C[i];
    }
    ll ans = -(pow(10, 10));
    for (int sp = 0; sp < N; ++sp) {
        int np = sp;
        ll total = 0;
        vector<int> path;
        while (1) {
            path.push_back(C[np]);
            total += C[np];
            np = P[np];
            if (np == sp) {
                break;
            }
        }

        ll l = path.size();
        ll t = 0;

        for (int j = 0; j < l; ++j) {
            t += path[j];
            if (j + 1 > K){
                break;
            }
            ll cur = t;
            if (total > 0) {
                ll e = (K-(j+1))/l;
                cur += total * e;
            }

            ans = max(cur, ans);
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int D;

int main () {
	
  cin >> D;
  
  D = abs(D-25);
  
  string S = "Christmas";
  
  for (int i = 0; i < D; i++) {
  
  	S = S + " Eve";
    
  }
  
  
  
  cout << S << "\n";
  
  return 0;
  
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const size_t SIZE = 1000 * 1500 + 10;
ll cnts[2][SIZE];

bool solve() {
    ll N, M;
    cin >> N >> M;
    if (!(N + M)) return false;
    V<ll> H(N), W(M);
    for (ll &e : H) cin >> e;
    for (ll &e : W) cin >> e;

    fill(cnts[0], cnts[0] + SIZE, 0);
    fill(cnts[1], cnts[1] + SIZE, 0);

    auto count = [](ll *cnt, const V<ll> &v) {
        ll N = v.size();
        for (ll i = 0; i < N; i++) {
            ll sum = 0;
            for (ll j = i; j < N; j++) {
                sum += v[j];
                cnt[sum]++;
            }
        }
    };

    count(cnts[0], H);
    count(cnts[1], W);
    
    ll ans = 0;
    for (ll i = 0; i < SIZE; i++) ans += cnts[0][i] * cnts[1][i];
    cout << ans << endl;
    return true;
}

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



Measured memory_bytes: 26596
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
    string s;
	cin >> s;
	ll k; cin >> k;
	ll cnt = 1, ans = 0, truer = 1;
	for(ll i = 1; i < s.length(); ++i){
		if(s[0] != s[i]){
			truer = 0;
			break;
		}
	}
	if(truer){
		cout << s.length() * k / 2;
	}else if(s[0] == s[s.length() - 1]){
		ll left = 0, right = s.length() - 1, ans = 0;
		while(s[0] == s[left]){
			left++;
		}
		while(s[s.length() - 1] == s[right]){
			right--;
		}
		right = s.length() - right - 1;
		ans = (left + right) / 2 * (k - 1);
		ll cnt = 1, kanta = 0;
		for(ll i = left; i < s.length() - right; ++i){
			if(s[i] == s[i + 1]){
				cnt++;
				if(i == s.length() - 2){
					kanta += (cnt / 2);
				}
			}else{
				kanta += (cnt / 2);
				cnt = 1;
			}
		}
		kanta *= k;
		cout << ans + left/2 + right/2 + kanta;
	}
	else{
		for(ll i = 0; i < s.length() - 1; ++i){
			if(s[i] == s[i + 1]){
				cnt++;
				if(i == s.length() - 2){
					ans += (cnt / 2);
				}
			}else{
				ans += (cnt / 2);
				cnt = 1;
			}
		}
		ans *= k;
		cout << ans;
	}
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N, M, X = map(int,input().split()) 
CA = [list(map(int,input().split())) for i in range(N)]

CAarray = np.array(CA)
C = CAarray[:,0]
A = CAarray[:,1:M+2]

if np.count_nonzero(np.sum(A, axis=0) < X) != 0:
    print(-1)
    exit()

Answer = np.sum(C)

for i in range(0,2**N):
    ll = [int(x) for x in list(str(format(i,'b').zfill(N)))]
    l = np.array(ll)

    if np.count_nonzero(np.dot(A.T,l.T) >= X) == M:
        if Answer >= np.dot(C.T,l.T):
            Answer = np.dot(C.T,l.T)

print(Answer)




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

int rec(int init, string circle, bool use, int n){
  int m = circle.size();
  bool f1 = true, f2 = true;
  for(int i=0;i<m;i++){
    if(circle[i]=='B')f1 = false;
    if(circle[i]=='G')f2 = false;
  }
  if(f1)return 0;
  if(f2)return m;

  int res = 0, rm = (init+n-1)%m;
  string tmp = circle;
  tmp.erase(tmp.begin() + rm);
  res = max(res, rec( rm%(m-1), tmp, use, n));

  if(!use){
    rm = (rm+1)%m;
    tmp = circle;
    tmp.erase(tmp.begin() + rm);
    res = max(res, rec( rm%(m-1), tmp, 1, n));
  }
  return res;
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while(T--){
    int n;
    string s;
    cin >> n >> s;
    cout << rec(0,s,0,n) << endl;
  }
}

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

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var S = new string[N];
        var T = new int[N];
        for (int i = 0; i < N; i++)
        {
            var vals = Console.ReadLine().Split(' ');
            S[i] = vals[0];
            T[i] = int.Parse(vals[1]);
        }
        var X = Console.ReadLine();

        var time = 0;
        var found = false;
        for (int i = 0; i < N; i++)
        {
            if (found)
            {
                time += T[i];
            }
            if (S[i] == X)
            {
                found = true;
            }
        }

        Console.WriteLine(time);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), num(200);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        num.at(A.at(i))++;
    }
    int ans = 0;
    for(int i = 0; i < 200; i++){
        if(num.at(i) > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

void fast()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int mxA = 1e7;
int freq [mxA+1] ;
int pref [mxA+1];

int main()
{
    fast();
    int a ,b;
    cin >> a>>b;
    if(a%2==0 || b%2==0) cout << "No";
    else cout << "Yes";




}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	long long int a, b, k;
	cin >> a >> b >> k;

	for (int i = 0; i < k; i++) {
		if (i % 2) {
			if (b % 2)b--;
			a += b / 2;
			b /= 2;
		}
		else {
			if (a % 2)a--;
			b += a / 2;
			a /= 2;
		}
	}
	cout << a << " " << b << endl;

	return 0;
}

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

int n=0;
int buri[86401];
string unko;

int main(){
    while(true){
        cin>>n;
        if(n==0){
            return 0;
        }
        else{
            for(int i=0; i<=86400; i++){
                buri[i]=0;
            }
            for(int i=0; i<n; i++){
                int j,h,b,j2,h2,b2;
                scanf("%d:%d:%d %d:%d:%d",&j,&h,&b,&j2,&h2,&b2);
                int tmp1=j*3600+h*60+b;
                int tmp2=j2*3600+h2*60+b2;
                //cout<<tmp1<<tmp2;
                for(int ii=tmp1; ii<tmp2; ii++){
                    buri[ii]++;
                }
            }

            int max=0;
            for(int i=0; i<=86400; i++){
                max=std::max(max,buri[i]);
            }
            cout<<max<<endl;
        }
    }
}




/*

std::vector<std::string> StringSplit(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/


Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
ll k,t,a[105];
int main(void){
    cin>>k>>t;
    for(int i=0;i<t;i++) cin>>a[i];
    sort(a,a+t);
    int l=0;
    for(int i=0;i<t-1;i++){
        l+=a[i];
    }
    if(a[t-1]<=l+1){
        cout<<0<<endl;
    }else{
        cout<<a[t-1]-l-1<<endl;
    }
    
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  char a[4],op[3];
  int i,j,sum,x[4];
  scanf("%s",a);
  for(i=0;i<4;i++){
    x[i]=a[i]-'0';
  }
  
  for(i=0;i<8;i++){
    sum=x[0];
    for(j=0;j<3;j++){
      if(i&(1<<j)){
        sum+=x[j+1];
        op[j]='+';
      }else{
        sum-=x[j+1];
        op[j]='-';
      }
    }
    if(sum==7){break;}
  }
  printf("%d%c%d%c%d%c%d=7\n",x[0],op[0],x[1],op[1],x[2],op[2],x[3]);
}

Measured memory_bytes: 128
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0; lli sum = 1000ll;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a)
		cin >> i;
	for (int i = 0; i + 1 < n; ++i)
	{
		lli x = 0ll;
		if (a[i] < a[i + 1])
			x = sum / a[i];
		sum += 1ll * (a[i + 1] - a[i]) * x;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3600