akhauriyash/Code-Regression huggingface dataset:
S = input()
T = input()
AL=[chr(ord('A') + i) for i in range(26)]
al=[chr(ord('a') + i) for i in range(26)]

def cnvS(St):
  import re
  cnt = 0
  while (cnt < 26):
    fnd=re.search('[a-z]', St)
    if fnd:
      St = St.replace(fnd.group(),AL[cnt])
      cnt +=1
    else:
      break
  return St

if cnvS(S)==cnvS(T):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 4144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		int power = 0;
		long leastCommon = 1;
		for (int i = 0; i < n; i++) {
			long num = sc.nextLong();
			int pow = calcTwoPow(num);
			if (i == 0) {
				power = pow;
			} else if (power != pow) {
				print(0);
				return;
			}
			leastCommon = calcLeastCommon(leastCommon, num);
			if (leastCommon > m * 2) {
				print(0);
				return;
			}

		}
		print((m + leastCommon / 2) / leastCommon);
		sc.close();
	}

	public static int calcTwoPow(long num) {
		int count = 0;
		while (num % 2 == 0) {
			num = num / 2;
			count++;
		}
		return count;
	}

	public static long calcLeastCommon(long x, long y) {
		return x * y / calcGreatestCommon(x, y);
	}

	public static long calcGreatestCommon(long x, long y) {
		long temp;
		while (x % y != 0) {
			temp = y;
			y = x % y;
			x = temp;
		}
		return y;
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 51568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int M,N;
	cin>>M>>N;
	auto a = mv(N);
	cin>>a;
	if(M==2){
		int ans = INF;
		int tmp = 0;
		REP(i,N){
			if(a[i]!=i%2+1)tmp++;
		}
		CHMIN(ans,tmp);
		tmp=0;
		REP(i,N){
			if(a[i]!=3-(i%2+1))tmp++;
		}
		CHMIN(ans,tmp);
		OUT(ans);
		return 0;
	}
	int ans = 0;
	int now = 1;
	FOR(i,1,N){
		if(a[i-1]!=a[i]){
			ans+=now/2;
			now=1;
		}else now++;
	}
	OUT(ans+now/2);
}


Measured memory_bytes: 3588
#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 int long long
#define _GLIBCXX_DEBUG

signed main() {
  int X; cin >> X;
  
  int k=0; int i=1;
  while (k<X) {
    k += i;
    i++;
  }
  
  cout << i-1 << endl;



}

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

int n, x;
int a, b, anum, bnum;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (!a) a = x, anum = 1;
    else if (x == a) anum++;
    else if (!b) b = x, bnum = 1;
    else if (x == b) bnum++;
    else return !puts("No");
  }
  if (a < b) swap(a, b), swap(anum, bnum);
  if (b && b != a - 1) return !puts("No");
  if (bnum) a -= bnum, n -= bnum;
  else if (a == n - 1) return !puts("Yes");
  if (a <= 0 || a == n) return !puts("No");
  puts(a * 2 <= n ? "Yes" : "No");
  return 0;
}


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

int n, ans=0;
string s;
set<int>st;

int main(){
	cin >> n >> s;
	for (int i=0;i<1000;i++){
		vector<int>tmp;
		int ii=i;
		for (int j=0;j<3;j++){
			tmp.push_back(ii%10);
			ii/=10;
		}
		for (int j=0;j<n;j++){
			if (tmp.empty()) break;
			if (tmp.back()+'0'==s[j]) tmp.pop_back();
		}
		if (tmp.empty() && !st.count(i)){
			ans++;
			st.insert(i);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 384
def findSumOfDigits(n):
    sum = 0
    while n > 0.1:
        sum = sum + (n % 10)
        #print(n % 10)
        n = n - (n % 10)
        n = n / 10
        #print(n)
    return sum

# スペース区切りの整数の入力
n, a, b = map(int, input().split())

ans = 0

for i in range(1,n+1):
    #print(i)
    test = findSumOfDigits(i)
    if a <= test <= b:
        ans = ans + i

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> qi;
  rep (i, n) {
    int x;
    cin >> x;
    qi.push(x);
  }

  rep (i, m) {
    int tmp = qi.top() / 2;
    qi.pop();
    qi.push(tmp);
  }

  ll ans = 0;
  while (!qi.empty()) {
    ans += qi.top();
    qi.pop();
  }

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


Measured memory_bytes: 3892
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	cout << (a - 1) * (b - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 5e5+2;


int main()
{
   int n;
   scn(n);

   vector<int> a(n+1), dp(n+1, inf);

   rep(i, 1, n+1) {
      scn(a[i]);
   }

   dp[1] = 0; dp[2] = abs(a[2] - a[1]);

   rep(i, 3, n+1) {
      dp[i] = min(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
      dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
   }

   prin(dp[n]);
   return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

#define MAX_N 500000

long long count = 0;
int A[MAX_N+1];

void merge(int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1]; int R[n2+1];
  for(int i=0;i<n1;i++) {
    L[i] = A[left+i];
  }
  for(int i=0;i<n2;i++) {
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = 0x7FFFFFFF;
  int i = 0; int j = 0;
  for(int k=left;k<right;k++) {
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      if(i != n1) {
        count += n1 - i;
        // printf("insert(%d)\n",R[j]);
      }
      A[k] = R[j];
      j++;
    }
  }
}

void merge_sort(int left, int right) {
  if(right - left > 1) {
    int mid = (left + right) / 2;
    merge_sort(left, mid);
    merge_sort(mid, right);
    merge(left, mid, right);
  }
}

int main () {
  int n; scanf("%d",&n);
  for(int i=0;i<n;i++) {
    scanf("%d ",A+i);
  }
  merge_sort(0, n);
  printf("%lld\n",count);
}

Measured memory_bytes: 2592
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vector<ll>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		v[i]=v[i]-(i+1);
	}
	sort(v.begin(),v.end());
	ll ans=0;
	if(n&1){
		ll med=v[n/2];
		for(int i=0;i<n;i++){
			ans+=abs(v[i]-med);
		}
		cout<<ans<<endl;
		return 0;
	}
	else{
		ll med1=v[(n-1)/2],med2=v[(n+1)/2];
		ll ans1=0,ans2=0;
		for(int i=0;i<n;i++){
			ans1+=abs(v[i]-med1);
		}
		for(int i=0;i<n;i++){
			ans2+=abs(v[i]-med2);
		}
		cout<<min(ans1,ans2)<<endl;
	}
}

Measured memory_bytes: 1792
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    string s ; 
    cin >> s ; 
    int n = (int) s.size() ; 
    int cnt = 0 ;
    for(int i=0;i<n;){
    	char c = s[i] ; 
    	while(i < n && s[i] == c){
    		i++ ; 
    	}
    	cnt++ ; 
    }
    debug() << imie(cnt) ;
    cout << cnt - 1 << endl;
    return 0 ;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 300000 

bool prime[MAX];
int main(){
	for(int i = 0; i < MAX; i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	for(int i = 2; i < MAX; i++){
		if(prime[i]){
			for(int j = i + i; j < MAX; j+=i){
				prime[j] = false;
			}
		}
	}
	
	int n;
	cin >> n;
	while(n != 0){
		int ans;
		ans = 0;
		for(int i = n + 1; i <= n * 2; i++){
			if(prime[i])ans++;
		}
		cout << ans << endl;
		cin >> n;
	}
	
	return 0;
}

Measured memory_bytes: 1452
N = int(input())
words = [input() for _ in range(N)][::-1]

def shiritori(last, now):
    if mem.get(now) is not None:
        return False
    else:
        if last[-1] != now[0]:
            return False
    mem[now] = 1
    return True


last = words.pop()
mem = {last: 1}

ok = True
for i in range(N-1):
    now = words.pop()
    if not shiritori(last, now):
        ok = False
        break
    last = now

if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<cstdio>
#include<string>
#include<set>

#define R 114
#define G 103
#define B 98

using namespace std;

class DATA{
	public:
		DATA(string temp){			//ÌzñÆzñÌ·³ðnµÄ °Ä­¾³¢
			step = 0;
			arr = temp;
		}
		
		DATA(string temp, int step) :arr(temp), step(step) {}
		
		//I¹»èH
		int check(void){
			char t = arr[0];
			for(int i = 0; i < arr.size(); i++){
				if(arr[i] != t){
					return 0;
				}
			}
			return 1;
		}
		
		int step;		//Xebv(JÚ)
		string arr;	//rgbÌÀÑ
};

//¦
int ans = -1;

int main()
{
	string rgb;
	string temp;
	int i,j, len;
	int temp3;
	char g;
	
	
	for(;;){
		
		set<string> table;

		cin >> rgb;
		if(rgb == "0"){
			break;
		}
		len = rgb.size();
		ans = -1;
		queue<DATA> Q;
		
		DATA start(rgb,0);
		
		Q.push(start);
		while(!Q.empty()){
			//`FbN·éf[^ðæèo·
			DATA d = Q.front();
			Q.pop();
			
			if(table.count(d.arr)){
				continue;
			}
			
			table.insert(d.arr);
			
			//I¹
			if(d.check() == 1){
				ans = d.step;
				break;
			}
			
			//·×ÄÌp^[ÉÎµÄóÔJÚµAL[Éi[
			for(i = 0; i < len-1; i++){
				temp = d.arr;
				if(d.arr[i] != d.arr[i+1]){
					switch(d.arr[i]+d.arr[i+1]){
						case R+B:
							temp[i] = temp[i+1]= G;
							break;
						case R+G:
							temp[i] = temp[i+1] = B;
							break;
						case G+B:
							temp[i] = temp[i+1] = R;
					}
					
					DATA next(temp,d.step+1);
					Q.push(next);
				}
			}
		}
		if(ans == -1){
			cout << "NA" << endl;
		}
		else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 2112
n = list(input())

a = [0,0,0,0]
for i in range(4):
    a[i] = int(n[i])

op = [0,0,0]
for i in range(8):
    temp = i
    for j in range(3):
        op[j] = temp % 2
        temp //= 2

    check = 0
    ans = a[0]
    for j in range(3):
        if op[j] == 0:
            ans += a[j + 1]
        else:
            ans -= a[j + 1]
    if ans == 7:
        s = str(a[0])
        for j in range(3):
            if op[j] == 0:
                s = s + "+" + str(a[j + 1])
            else:
                s = s + "-" + str(a[j + 1])
        s += "=7"
        print(s)
        exit()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll a[1000002];
ll timma[1000002];
ll ans[1000002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
		timma[i]=-1;
	}
	ll st=1;
	ll timm=0;
	while(timma[st]==-1)
	{
		ans[timm]=st;
		if (k==0)
		{
			cout<<st<<endl;
			return 0;
		}
		timma[st]=timm++;
		k--;
		st=a[st];
	}
	ll diff=timm- timma[st];
	k%=diff;
	cout<<ans[timma[st]+k]<<endl;
	return 0;
}


Measured memory_bytes: 31408
import sys
import bisect

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))

a.sort()
b.sort()
c.sort()

b_ans_list = [0 for _ in range(n)]
for i in reversed(range(n)):
    # b[i]における選択可能なcの個数
    if i == n-1:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i])
    else:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i]) + b_ans_list[i+1]

ans = 0
for i in range(n):
    b_index = bisect.bisect_right(b, a[i])
    if b_index < n: ans += b_ans_list[b_index]

print(ans)


Measured memory_bytes: 95844
n, m = map(int, input().split())
h = list(map(int, input().split()))


lower = []

for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        lower.append(b-1)
    if h[b-1] >= h[a-1]:
        lower.append(a-1)

print(n - len(set(lower)))

Measured memory_bytes: 20048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int L,R,D; cin>>L>>R>>D;
  int ans=0;
  for(int i=L;i<=R;i++){
    if(i%D==0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 055 B / Link: http://abc055.contest.atcoder.jp/tasks/abc055_b  ----- */


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

	LL N; 
	cin >>N;
	
	LL ans = 1;
	FOR(i, 1, N + 1) {
		ans *= i;
		ans %= MOD;
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  int k, x;
  std::cin >> k >> x;

  if(k*500 >= x) std::cout << "Yes" << std::endl;
  else           std::cout << "No" << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
 
using namespace std;
 
bool cmp(const vector<int> &a, const vector<int> &b)
{
    return a[1] > b[1];
}
 
int main(int argc, const char * argv[]) {
    int n = 0;
    cin >> n;
    
    int v[n];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    map<int, int> m_even;
    map<int, int> m_odd;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            m_even[v[i]]++;
        } else {
            m_odd[v[i]]++;
        }
    }
    
    vector<vector<int>> v1;
    for (std::map<int, int>::iterator i = m_even.begin(); i != m_even.end(); i++) {
        vector<int> tmp;
        tmp.push_back(i->first);
        tmp.push_back(i->second);
        v1.push_back(tmp);
    }
    
    sort(v1.begin(), v1.end(), cmp);
    vector<int> tmp;
    tmp.push_back(0);
    tmp.push_back(0);
    v1.push_back(tmp);
    
    vector<vector<int>> v2;
    for (std::map<int, int>::iterator i = m_odd.begin(); i != m_odd.end(); i++) {
        vector<int> tmp;
        tmp.push_back(i->first);
        tmp.push_back(i->second);
        v2.push_back(tmp);
    }
    
    sort(v2.begin(), v2.end(), cmp);
    v2.push_back(tmp);
    
    if (v1[0][0] != v2[0][0]) {
        cout << n - v1[0][1] - v2[0][1] << endl;
    } else {
        cout << min(n - v1[0][1] - v2[1][1], n - v2[0][1] - v1[1][1]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 11060
<?php
// 総数のあと改行して改行区切りの数字の集合
fscanf(STDIN, '%d', $q);
for ($i  = 0; $i < $q; $i++) {
    $lr[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}

$is_prime = is_prime(10 ** 5);

$s = array_fill(0, 10 ** 5, 0);
for ($i = 1; $i <= 10 ** 5; $i++) {
    if ($is_prime[$i] && $is_prime[($i + 1) / 2]) {
        $s[$i] = $s[$i - 1] + 1;
    } else {
        $s[$i] = $s[$i - 1];
    }
}

for ($i = 0; $i < $q; $i++) {
    $l = $lr[$i][0];
    $r = $lr[$i][1];
    echo ($s[$r] - $s[$l - 1]).PHP_EOL;
}

/**
 * エラトステネスのふるい
 * $maxまでの整数が素数かどうかboolを格納した配列を返す
 */
function is_prime($max) {
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int solve(string s) {
    if (s == "SUN") return 7;
    if (s == "MON") return 6;
    if (s == "TUE") return 5;
    if (s == "WED") return 4;
    if (s == "THU") return 3;
    if (s == "FRI") return 2;
    if (s == "SAT") return 1;
}

int main() {
    string S;
    cin >> S;
    cout << solve(S) << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]

vrows = {r: False for r in range(h)}
vcols = {c: False for c in range(w)}

for r in range(h):
    for c in range(w):
        if a[r][c] == '#':
            vrows[r] = True
            vcols[c] = True

for r in range(h):
    if vrows[r]:
        row = ''
        for c in range(w):
            if vcols[c]:
                row += a[r][c]
        print(row)


Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

mint dp[101][4][4][4];
//A0 C1 G2 T3
//0?21 02?1
int main(){
  int n; cin >> n;
    rep(p,101)rep(i,4)rep(j,4)rep(k,4) dp[p][i][j][k]=0;
    rep(i,4)rep(j,4)rep(k,4) dp[3][i][j][k]=1;
    dp[3][0][2][1]=0;
    dp[3][0][1][2]=0;
    dp[3][2][0][1]=0;
    for(int i=4; i<=n; i++){
      rep(j,4)rep(k,4)rep(p,4){
        if((j==0 && k==2 && p==1) || (j==0 && k==1 && p==2) || (j==2 && k==0 && p==1)) continue;
        if(k==2 && p==1){
          rep(m,4){
            if(m==0) continue;
            dp[i][j][k][p]+=dp[i-1][m][j][k];
          }
        }
        else if(j==2 && p==1){
          rep(m,4){
            if(m==0) continue;
            dp[i][j][k][p]+=dp[i-1][m][j][k];
          }
        }
        else{
          rep(m,4){
            dp[i][j][k][p]+=dp[i-1][m][j][k];
          }
        }
      }
    }
    mint ans=0;
    rep(i,4)rep(j,4)rep(k,4) ans+=dp[n][i][j][k];
    cout << ans.x << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b; cin >> a >> b;
    cout << (a - 2 * b >= 0 ? a - 2 * b : 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
  double side_A, side_B, Hour, minute;
  cin >> side_A >> side_B >> Hour >> minute;
  double angle_A = 0.5 * minute + 30. * Hour;
  double angle_B = 6. * minute;
  double angle_rad = fabs(angle_A - angle_B);
  
  if(angle_rad > 180.) angle_rad = 360. - angle_rad;
  double side_C = sqrt(pow(side_A, 2) - 2*side_A*side_B*cos(angle_rad * M_PI/180.) + pow(side_B, 2));
  
  cout << fixed << setprecision(10) << side_C << endl;
  return 0;
}

Measured memory_bytes: 4252
n = int(input())
A = list(map(int, input().split()))
tmp = 0
sign = 1
ans = []
for a in A:
    tmp += a * sign
    sign *= -1
ans.append(tmp)
before = tmp // 2
for i in range(n-1):
    before = A[i] - before
    ans.append(before * 2)
print(' '.join(list(map(str, ans))))


Measured memory_bytes: 19140
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

A = [0] + list(map(int, input().split())) + [0]

S = 0
for i in range(N + 1):
    S += abs(A[i] - A[i + 1])

for i in range(N):
    print(S - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2]))


Measured memory_bytes: 20652
N = int(input())
count = 0
if N ==2:
    print(1)
else:

    for i in range(2,int((N-1)**0.5)+1):
        if (N-1)%i == 0:
            count += 1
            if (N-1)//i != i:
                count += 1

    for j in range(2,int(N**0.5)+1):
        if N%j == 0:
            n = N
            while n%j == 0:
                n = n//j
            if n%j == 1:
                count += 1
            if N//j != j:
                n = N
                while n%(N//j) == 0:
                    n = n//(N//j)
                if n%(N//j) == 1:
                    count += 1
    print(count+2)



Measured memory_bytes: 3188
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

bool bfs(unordered_map<int, set<pair<int, ll>>>& graph, unordered_map<int, ll>& visited, int start) {
    deque<pair<int, ll>> que;
    pair<int, ll> nd;
    nd.first = start;
    nd.second = 0;
    que.push_back(nd);
    while (1) {
        if (que.size() <= 0) break;
        nd = que.front();
        que.pop_front();
        for (auto& adj : graph[nd.first]) {
            pair<int, ll> new_nd;
            new_nd.first = adj.first;
            new_nd.second = nd.second + adj.second;
            if (visited.find(new_nd.first) == visited.end()) {
                que.push_back(new_nd);
                visited.insert(new_nd);
            }
            else {
                if (visited[new_nd.first] != new_nd.second) return false;
            }
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    unordered_map<int, set<pair<int, ll>>> graph;
    unordered_set<int> start_list;
    rep(i, N) start_list.insert(i + 1);
    rep(i, M) {
        int L, R;
        ll D;
        cin >> L >> R >> D;
        graph[L].insert(make_pair(R, D));
        graph[R].insert(make_pair(L, -D));
    }
    if (start_list.size() == 0) {
        cout << "No" << endl;
        return 0;
    }

    unordered_map<int, ll> visited;
    REP(s, 1, N + 1) {
        if (visited.find(s) != visited.end()) continue;
        visited[s] = 0;
        if (bfs(graph, visited, s) == false) {
            cout << "No" << endl;
            return 0;
        }

    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 43940
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
 
using namespace std;
 
 
int main()
{
	unsigned int H;
  	int N;
  
    cin >> H >> N;    
  
  	
    unsigned int sum = 0;
  	for (int i = 0; i < N; i++) {
      unsigned int v;
      cin >> v;
		sum += v;
    }
  	if (H <= sum) {
      	cout << "Yes" << endl;
    } else {
      	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;

    vector<int> dist(N,-1);
    vector<vector<pair<int,int>>> G(N);
    rep(i,N-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--;
        v--;
        G[u].push_back(make_pair(v,w));
        G[v].push_back(make_pair(u,w));

    } 
    queue<int> q;
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(auto p:G[v]){
            int nv=p.first;
            int nx=p.second;
            if(dist[nv]!=-1)continue;
            dist[nv]=dist[v]+nx%2;
            dist[nv]%=2;
            q.push(nv);



        }

    }
    rep(i,N){
        cout << dist[i] << endl;
    }



    



}


Measured memory_bytes: 8704
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	double A, B;
	cin >> A >> B;
	double mA, mB, MA, MB;
	mA = floor(A / 0.08);
	mB = floor(B / 0.1);
	MA = ceil(A / 0.08);
	MB = ceil(B / 0.1);
	for (double i = min(mA, mB); i <= max(MA, MB); i++) {
		if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
 #include <cmath>
 using namespace std;
 int main(){
   int nw;
   int n;cin>>n;
   int a[n];for(int i = 0; n > i; i++)cin>>a[i];
   
   //+-+-+-....
   long long sh = 0;
   nw = 0;
   for(int i = 0; n > i; i++){
     nw = (long long)nw+a[i];
     if(i % 2 == 0)if(nw<=0)sh = (long long)sh+1-nw,nw=1;
     if(i % 2 == 1)if(nw>=0)sh = (long long)sh+nw+1,nw=-1;
   }
   
   //-+-+-+...
   long long hs = 0;
   nw = 0;
   for(int i = 0; n > i; i++){
     nw = (long long)nw+a[i];
     if(i % 2 == 1)if(nw<=0)hs = (long long)hs+1-nw,nw=1;
     if(i % 2 == 0)if(nw>=0)hs = (long long)hs+nw+1,nw=-1;
   }
   
   cout << min(hs,sh) << endl;
   
 }

Measured memory_bytes: 640
import java.util.*;
import static java.util.Map.Entry.comparingByValue;
import static java.util.stream.Collectors.toMap;

public class Main {

    public static void main(String[] args) {
        int C = 0;
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        Integer A[] = new Integer[N];
        boolean T = true;

        for (int I = 0; I < N; I++) {
            A[I] = Input.nextInt();
        }

        while (T) {
            for (int I = 0; I < N; I++) {
                String S = A[I] + "";
                if (Integer.parseInt(S.charAt(S.length() - 1) + "") % 2 == 0) {
                    A[I] = A[I] / 2;
                     C++;
                } else {
                    T = false;
                }
            }
       }
        System.out.println(C/N);
    }
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  while(1){
    int h,w;
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if((i+j)%2)cout<<".";
        else cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = RL();
            //var sprlst = spr(rl);
            //var intlist = sprlst.Select(x => c2i(x)).ToList();
            var k = c2i(rl);
            //var ls1 = Enumerable.Range(0, 10).Select(x => (long)x);
            var fbsum = (k * (k + 1)) / 2;
            var num3 = (k / 3) * 3; 
            var num5 = (k / 5) * 5;
            var num15 = (k / 15) * 15;
            var ans = fbsum - getsum(num3,3)-getsum(num5,5) +getsum(num15,15);

            bool ret = false;



            Console.WriteLine(ans);
            //Console.ReadLine();
            




        
        }
        static Int64 getsum(Int64 last, int ct) { return (ct + last) * (last / ct) / 2; }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 17608
function Main(input) {
	input = input.split(" ");
	var x = input[0];
    
    var num = x.length;
    var count = Math.ceil(num/2);
    
    var ans = [];
    for(var i = 0; i < count; i++){
        var kisu = x[i*2];
        ans.push(kisu);
    }
    
    ans = ans.join("");
    console.log(ans);
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int strNum = sc.nextInt();
		int strLen = sc.nextInt();
		sc.nextLine();
		String[] strs = new String[strNum];
		for(int i=0; i<strNum; i++) {
			strs[i] = sc.nextLine();
		}

		//ソートループ
		for(int i=0; i<strNum; i++) {
			for(int j=i+1; j<strNum; j++) {
				if(!minStr(strLen,strs[i],strs[j])) {
					String tmp=strs[i];
					strs[i]=strs[j];
					strs[j]=tmp;
				}
			}
		}

		output(strs);

	}

	private static boolean minStr(int strLen, String strs, String strt) {
		for(int j=0; j<strLen; j++) {
			char sChar = strs.charAt(j);
			char tChar = strt.charAt(j);
			if(sChar != tChar) {
				return sChar<tChar;
			}
		}
		return true;
	}

	private static void output(String[] strs) {
		for(int i=0; i<strs.length; i++) {
			System.out.print(strs[i]);
		}
		System.out.println();
	}

}


Measured memory_bytes: 21332
def istriangle(a, b, c)
    return a+b > c && b+c > a && c+a > b
end

n = gets.chomp.to_i
l = gets.chomp.split(" ").map(&:to_i)
ans = 0

n.times do |i|
    (i...n).each do |j|
        (j...n).each do |k|
            next if i == j || j == k || k == i
            next if l[i] == l[j] || l[j] == l[k] || l[k] == l[i]
            ans += 1 if istriangle(l[i], l[j], l[k])
        end
    end
end

puts ans

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

class comb{
	vector<ll> f,fr;
	ll MOD_;
	public:
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
		}
		fr[n] = calc(f[n],mod-2,mod);
		for(ll i=n-1;i>=0;i--){
			fr[i] = fr[i+1] * (i+1) % mod;
		}
	}
	ll nCr(ll n,ll r){
		if(n<0||r<0||n<r)return 0;
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}//nHr = n+r-1Cr
};


int main(){

	ll S,mod=1000000007;
	cin >> S;

	ll ans = 0;
	comb co;
	co.init(S+1000000,mod);
	for(int i=1;i<S+1;i++){
		ll res = S - 3*i;
		if(res < 0)break;

		ans += co.nCr(res+i-1,res);
		ans %= mod;

	}

	cout << ans << endl;

}




Measured memory_bytes: 18832
while True :
	a, op, b = map(str, input().split())
	
	if op == "+" :
		print(str(int(a) + int(b)))
	if op == "-" :
		print(str(int(a) - int(b)))
	if op == "*" :
		print(str(int(a) * int(b)))
	if op == "/" :
		print(str(int(a) // int(b)))
	if op == "?" :
		break

Measured memory_bytes: 7576
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class DLine {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,x,y;
        in >> n >> x >> y;
        x--;y--;
        vector<vector<int>> ab(n);
        rep(i,n-1){
            ab[i].push_back(i+1);
            ab[i+1].push_back(i);
        }
        ab[x].push_back(y);
        ab[y].push_back(x);
        vector<vector<int>> d(n,vector<int>(n,-1));
        for(int i=0;i<n;i++){
            deque<int> q;
            q.push_back(i);
            d[i][i]=0;
            while(q.size()!=0){
                int node = q.front();
                q.pop_front();
                for (int j = 0; j < ab[node].size(); ++j) {
                    if(d[i][ab[node][j]]==-1){
                        q.push_back(ab[node][j]);
                        d[i][ab[node][j]]=d[i][node]+1;
                    }
                }
            }
        }
        vector<int> ans(n,0);
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                ans[d[i][j]]++;
            }
        }
        for(int i=1;i<n;i++){
            out << ans[i] << endl;
        }
	}
};


int main() {
	DLine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c, d[100000], e[100000], count = 0;
	char uc[100000];
	cin >> a>>b>>c;
	a = a - b;
	while (a >= c) {
		a=a - c;
		
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b;
  char op;

  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if( op == '?') break;
    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);
    }
  }
  return 0;
  
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define ins insert
#define emp emplace
#define era erase
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;
typedef tuple<int,int,int> tiii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll mod = 1e9 + 7;
const ll inf = (1LL << 62) - 1;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}


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

    string s,t;cin>>s>>t;
    int memo[2][26]={},sl=0,tl=0,ss[200010],tt[200010];
    for(char c:s){
        sl++;
        if(!memo[0][c-'a']) memo[0][c-'a']=sl,ss[sl]=sl;
        else ss[sl]=memo[0][c-'a'];
    }
    for(char c:t){
        tl++;
        if(!memo[1][c-'a']) memo[1][c-'a']=tl,tt[tl]=tl;
        else tt[tl]=memo[1][c-'a'];
    }
    rep1(i,sl){
        if(tt[i]!=ss[i]) esc("No");
    }
    esc("Yes");
}


Measured memory_bytes: 2452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC119_1 solver = new ABC119_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC119_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/mm/dd");
//        LocalDate ldt = LocalDate.parse( S , formatter );
//        LocalDate date_EndOf_Heisei = LocalDate.parse( "2019/04/30", formatter);

            if (S.compareTo("2019/04/30") > 0) {
                out.println("TBD");
            } else {
                out.println("Heisei");
            }
        }

    }
}



Measured memory_bytes: 21844
// 解き直し.
// ABC049/ARC065解説.
// https://img.atcoder.jp/arc065/editorial.pdf
// 以下のライブラリを使ってみる.
// 素集合データ構造(Union-Find)
// https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
#include <bits/stdc++.h>
using namespace std;
int ar[200001];
int br[200001];

struct UnionFind{

    vector<int> data;
    UnionFind(int sz){ data.assign(sz, -1); }
    
    // 頂点 x, y の 結合.
    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)            return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    
    // 頂点 k を 探索.
    int find(int k){
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    
    // 頂点 k を含む集合 の 大きさ.
    int size(int k){ return (-data[find(k)]); }
};

int main(){

    // 1. 入力情報取得.
    int N, K, L;
    int p, q;
    scanf("%d %d %d", &N, &K, &L);
    UnionFind ufc(N); // 道路で連結.
    UnionFind uft(N); // 鉄道で連結.
    
    // 2. 道路で連結している都市.
    for(int i = 0; i < K; i++){
        scanf("%d %d", &p, &q);
        p--, q--;
        ufc.unite(p, q);
    }
    
    // 3. 鉄道で連結している都市.
    for(int i = 0; i < L; i++){
        scanf("%d %d", &p, &q);
        p--, q--;
        uft.unite(p, q);
    }
    
    // 4. 各都市に, Union-Findでの根の都市番号を保存(道路, 鉄道).
    for(int i = 0; i < N; i++){
        ar[i] = ufc.find(i);
        br[i] = uft.find(i);
    }
    
    // 5. (ar[i], br[i]) の 出現回数を集計.
    map<pair<int, int>, int> m;
    for(int i = 0; i < N; i++){
        pair<int, int> p = make_pair(ar[i], br[i]);
        m[p]++;
    }
    
    // 6. 各都市について, 5. で確認した出現回数を出力.
    for(int i = 0; i < N; i++){
        pair<int, int> p = make_pair(ar[i], br[i]);
        printf("%d ", m[p]);
    }

    // 7. 後処理.
    return 0;

}

Measured memory_bytes: 15104
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@m,@x = gets.to_s.split.map{ |v| v.to_i }
    @c = []
    @a = []
    n.times do |i|
      @a[i] = gets.to_s.split.map{ |v| v.to_i }
      @c[i] = @a[i].shift
    end
  end

  def solve
    ans = 10 ** 15
    (1<<n).times do |mask|
      cost = 0
      know = Array.new(m, 0)
      n.times do |i|
        if mask >> i & 1 == 1
          cost += c[i]
          m.times do |j|
            know[j] += a[i][j]
          end
        end
      end
      if know.all?{ _1 >= x } && cost < ans
        ans = cost
      end
    end
    ans
  end

  def show(ans)
    puts ans == 10 ** 15 ? -1 : ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14540