akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;


ll N;
ll keta=0;
vector<ll> ans;
bool f(ll pos,ll n){
  while(pos>0){
    pos--;
    n/=2;
  }
  if(n%2 == 1) return true;
  return false;
}
int main(){
  cin >> N;
  ll n = N+1;
  while(n>0){
    keta++;
    n/=2;
  }
  n=N+1;
  keta--;
  cerr << keta << endl;
  ll k =0 ;
  rep(i,keta){
    if(f(i,n)){
      ans.push_back(100-k);
      k++;
    }
    ans.push_back(i+1);
  }
  rep(i,keta){
    ans.push_back(i+1);
  }
  rep(i,k){
    ans.push_back(100+(i-k+1));
  }
  cout << ans.size() << endl;
  cout << ans[0];
  rep(i,ans.size()-1){
    cout << " "<< ans[i+1];
  }
  cout << endl;
}


Measured memory_bytes: 256
N = int(input())

def solve(n,h,N):
    if 4*n*h-N*(n+h) <= 0:
        return 1.5
    
    else:
        return (N*n*h)/(4*n*h-N*(n+h))

for n in range(1,3501):
    for h in range(1,3501):
        ans = solve(n,h,N)
        if ans == int(ans) and int(ans)<=3500:
            print(h,n,int(ans))
            exit()


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

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3528
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin >> n;
	vector<ll> vl, vr;
	rep(i, 0, n) {
		ll a;
		cin >> a;
		vl.pb(a);
	}
	rep(i, 0, n) {
		ll a;
		cin >> a;
		vr.pb(a);
	}
	ll mx1 = 0;
	rep(i, 0, vl.sz) {
		mx1 = max(mx1, vl[i]);
	}
	ll mx2 = 0;
	rep(i, 0, vr.sz) {
		mx2 = max(mx2, vr[i]);
	}
	if(mx1!=mx2){
		cout << 0 << endl;
		return 0;
	}
	ll mx = mx1;
	ll l, r;
	rep(i, 0, n) {
		if (vl[i] == mx) {
			l = i;
			break;
		}
	}
	for (ll i = n - 1; i >= 0; i--) {
		if (vr[i] == mx) {
			r = i;
			break;
		}
	}
	if (r < l) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1LL;
	if (r - l - 1 > 0) {
		rep(i, 0, r - l - 1) {
			ans *= mx;
			ans %= MOD;
		}
	}
	ll mxl = vl[0];
	if (l > 0) {
		rep(i, 1, l) {
			if (vl[i] == mxl) {
				ans *= vl[i];
				ans %= MOD;
			}
			mxl = vl[i];
		}
	}
	ll mxr = vr[n - 1];
	if (r < n - 1) {
		for (ll i = n - 2; i > r; i--) {
			if (vr[i] == mxr) {
				ans *= vr[i];
				ans %= MOD;
			}
			mxr = vr[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2548
N = int(input())
w = []
for i in range(N):
  w.append(input())

v = True
z = list(set(w))
if len(z) != len(w):
  print("No")
else:
  for j in range(N - 1):
    if w[j][-1] != w[j+1][0]:
      v = False
  print("Yes") if v else print("No")

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int dp[k+1]={0};
    for(int i=0;i<=k;i++)
    {
      if(dp[i]!=1)
        for(int j=0;j<n;j++)
        {
            if(i>=a[j] && dp[i-a[j]]==0)
            dp[i]=1;
        }
    }
    if(dp[k]==1)
    cout<<"First";
    else 
    cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int A;
int res[50];
int main(){
  int Lj4PdHRW, i;
  rd(N);
  rd(M);
  for(Lj4PdHRW=0;Lj4PdHRW<2*M;Lj4PdHRW++){
    rd(A);A += (-1);
    res[A]++;
  }
  for(i=0;i<N;i++){
    wt_L(res[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, M, A;
// int res[50];
// {
//   rd(N,M);
//   rep(2M){
//     rd(A--);
//     res[A]++;
//   }
//   rep(i,N) wt(res[i]);
// }


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

int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	arr.push_back(1000000001);
	sort(arr.begin(),arr.end());
	int ret = 0;
	int counter = 0;
	for(int i=1; i<arr.size(); i++){
		if(arr[i-1]==arr[i]) counter++;
		else{
			counter++;
			if(counter<arr[i-1]) ret+=counter;
			else ret+=(counter-arr[i-1]);
			counter = 0;
		}
	}
	cout<<ret;
}

Measured memory_bytes: 4028
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    integers = sorted([A, B, C])
    midMinDiff = integers[1] - integers[0]  # 2つめと3つめの差。2の倍数の時、まず、この2つを揃えられる
    step = 0
    if midMinDiff % 2 == 0:
        step += midMinDiff // 2
        step += integers[2] - integers[1]
    else:
        # この時は、まず1番大きいものと、2番目におおきいものに1を足す
        step += 1
        step += (midMinDiff + 1) // 2
        step += integers[2] - integers[1]
    print(step)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
A, B, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
ans = min(As) + min(Bs)

for _ in range(M):
    x, y, c = map(int, input().split())
    value = As[x-1] + Bs[y-1] - c
    ans = min(ans, value)

print(ans)

Measured memory_bytes: 70468
#include <iostream>

using namespace std;
int findsum(int n){
int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main()
{
    int N,a,b;
    cin>> N>>a>>b;
    int total=0;
    for (int i=1;i<=N;++i){
        int sum=findsum(i);
        if(sum>=a&&sum<=b){
            total+=i;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int n;cin >> n;
  while(n--){
    int a,b;cin >> a >> b;
    if(d.left()==a) d.roll('E');
    if(d.right()==a) d.roll('W');
    while(d.top()!=a) d.roll('N');
    while(d.front()!=b) d.roll('R');
    cout << d.right() << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(){
  char input[100][101];
  int h,w,i;
  
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%s",input[i]);
  }
  
  for(i=0;i<h;i++){
    printf("%s\n",input[i]);
    printf("%s\n",input[i]);
  }
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
    int w,a,b,s=0;
    scanf("%d%d%d",&w,&a,&b);
    if(a<=b)
        while(a+w<b-s)
            s++;
    if(b<=a)
        while(b+w<a-s)
            s++;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 1704
#include <stdio.h>

int main(void)
{
	int s[3] = {1};
	char c[2];
	
	while(scanf("%c,%c", &c[0], &c[1]) != EOF) {
		int temp;
		
		if(c[0] == 'A') {
			if(c[1] == 'B') {
				temp = s[1];
				s[1] = s[0];
				s[0] = temp;
			}
			else {
				temp = s[2];
				s[2] = s[0];
				s[0] = temp;
			}
		}
		else if(c[0] == 'B') {
			if(c[1] == 'A') {
				temp = s[1];
				s[1] = s[0];
				s[0] = temp;
			}
			else {
				temp = s[2];
				s[2] = s[1];
				s[1] = temp;
			}
		}
		else if(c[0] == 'C') {
			if(c[1] == 'B') {
				temp = s[1];
				s[1] = s[2];
				s[2] = temp;
			}
			if(c[1] == 'A') {
				temp = s[2];
				s[2] = s[0];
				s[0] = temp;
			}
		}
	}
		if(s[0] == 1) puts("A");
		if(s[1] == 1) puts("B");
		if(s[2] == 1) puts("C");
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vi a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int now=a[0];
    ll ans=0;
    for(int i=0;i<n;i++){
        if(now-a[i]>=0) ans+=now-a[i];
        now=max(now,a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

	int N;
	cin >> N;

	vector<double> tmp(N);

	for (int i = 0; i < N; i++) {
		cin >> tmp.at(i);
	}

	sort(all(tmp));

	for (int i = 0; i < N - 1; i++) {
		tmp[i + 1] = (tmp[i] + tmp[i + 1]) / 2.0;
	}

	printf("%f\n", tmp[N - 1]);

	return 0;
}

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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int half = B / 2;
  
  if(A <= 5) {
    
    cout << "0" << endl;
    
  } else if(6 <= A && A <= 12) {
    
    cout << half << endl;
    
  } else {
    
    cout << B << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#print(sum(len(str(i+1))%2for i in range(int(input()))))
#
#print(sum(len(str(i+1))%2for i in range(int(input()))))
#
#print(len([1 for i in range(1,int(input())+1) if len(str(i))%2 == 1]))
#



n = int(input())
count = 0
for i in range(1,n+1):
	if len(str(i))%2:
		count += 1
print(count)




""" 
N = int(input())
ans = 0
for i in range(1,N+1):
    if len(str(i)) %2 != 0:
        ans += 1
print(ans)
 """


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

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

    while(n!=0){
        double s[1000]={}, sum1=0, sum2=0, mean, std;

        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        for(int i=0; i<n; i++){
            sum1+=s[i];
        }
        mean=sum1/n;

        for(int i=0; i<n; i++){
            sum2+=(s[i]-mean)*(s[i]-mean);
        }
        std=sqrt(sum2/n);

        cout << fixed << setprecision(6);
        cout << std << endl;
        cin >> n;
        }

    return 0;  
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vl A;
void input() {
	cin >> x >> y;
}
void solve() {	
	if (fabsl(x - y) < 2)cout << "Brown" << endl;
	else cout << "Alice" << endl;
}

int main() {
	input();
	solve();
}

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

const int INF = 1e9 + 5;

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];		
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n-1; i++){
		for(int z = 1; z < 3; z++){
			int j = i + z;
			if(j < n)
				dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
		}			
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] hw = new char[h][w];
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                hw[i][j] = s.charAt(j);
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (hw[i][j] == '.') {
                    continue;
                }
                if (i > 0 && hw[i - 1][j] == '#') {
                    continue;
                }
                if (i < h - 1 && hw[i + 1][j] == '#') {
                    continue;
                }
                if (j > 0 && hw[i][j - 1] == '#') {
                    continue;
                }
                if (j < w - 1 && hw[i][j + 1] == '#') {
                    continue;
                }
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;
struct edge
{
    int to, cost;
};

typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<edge> g[n];
    rep(i, n)
    {
        rep(j, n)
        {
            int temp = 0;
            edge ed;
            cin >> temp;
            if (temp == -1)
                ed.cost = INT_MAX;
            else
                ed.cost = temp;
            ed.to = j;
            g[i].push_back(ed);
        }
    }
    //solve by  fast prim
    bool used[n];
    int mincost[n];
    rep(i, n)
    {
        used[i] = false;
        mincost[i] = INT_MAX;
    }
    int ans = 0;
    mincost[0] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));
    while (que.empty() == false)
    {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (mincost[v] < p.first || used[v] == true)
            continue;
        used[v] = true;
        ans += p.first;
        rep(i, g[v].size())
        {
            auto e = g[v][i];
            mincost[e.to] = min(mincost[e.to], e.cost);
            que.push(P(mincost[e.to], e.to));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3196
import sys
sys.setrecursionlimit(10**8)

def dfs_fill(m, x, y):
    if not (0 <= x < W and 0 <= y < H) or m[y][x] == "0":
        return False
    m[y][x] = "0"
    for dx in range(-1, 2):
        for dy in range(-1, 2):
            if dx == dy == 0:
                continue
            dfs_fill(m, x+dx, y+dy)

while True:
    W, H = map(int, input().split())
    if W == H == 0:
        break
    C = [input().split() for _ in range(H)]

    count = 0
    for y in range(H):
        for x in range(W):
            # print("\n".join(["".join(c) for c in C]))
            if C[y][x] == "1":
                count += 1
                dfs_fill(C, x, y)

    print(count)


Measured memory_bytes: 7992
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll LINF = ll(1e18);

const int MAX_N = 100000;
int parent[MAX_N+1], size[MAX_N+1];

int root(int a){
  int b = parent[a];
  if(a==b)return a;
  return parent[a]=root(b);
}

void unite(int a, int b){
  if(size[a]>size[b])swap(a, b);
  parent[a] = b;
  size[b] += size[a];
}

int main(){
  int n, m;cin>>n>>m;
  rep(i, n){
    parent[i]=i;
    size[i]=1;
  }
  vector<ll> ans;
  vector<P> bridge(m);
  rep(i, m){
    int a, b;cin>>a>>b;
    bridge[m-1-i]=P(--a, --b);
  }
  ll inc = ll(n)*(n-1)/2;
  for(auto& e: bridge){
    ans.push_back(inc);
    int a=root(e.first), b=root(e.second);
    if(a!=b){
      inc -= ll(size[a])*size[b];
      unite(a, b);
    }
  }
  for(int i=m-1;i>=0;i--)cout<<ans[i]<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3828
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

template<typename T> inline size_t popcount(T x){
    static int const mask = 65535;
    static int dp[66000];
    if(dp[mask] != 16) for(int i = 0; i <= mask; i++) dp[i] = (i&1) + dp[i>>1];
    if(false){
    } else if(sizeof(T) == 4){
        return dp[x&mask] + dp[(x>>16)&mask];
    } else if(sizeof(T) == 8){
        return dp[x&mask] + dp[(x>>16)&mask] + dp[(x>>32)&mask] + dp[(x>>48)&mask];
    } else {
        assert(false);
        // int res = 0;
        // while(x) res += dp[x&65535], x >>= 16;
        // return res;
    }
}

int solve(ll s, ll d){
    if(s <= 0 && d >= 0) return popcount(-s) + popcount(d);
    else if(s >= 0 && d >= 0){
        int j = 0;
        int ans = 0;
        while(s < d){
            if((s>>j&1) && (d>>j&1)){
                s += 1LL<<j;
                d -= 1LL<<j;
                ans += 2;
            } else if((s>>j&1) ^ (d>>j&1)){
                s += 1LL<<j;
                ans ++;
            }
            j++;
        }
        return ans;
    } else return solve(-d,-s);
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N;
    cin >> N;
    rep(i,N){
        ll s,d;
        cin >> s >> d;
        cout << solve(s,d) << endl;
    }
}

Measured memory_bytes: 1456
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code
    ll t;
    cin>>n>>x>>t;
    p=ceil((double)n/x)*t;
    cout<<p<<endl;


    //code
    return 0;
}




Measured memory_bytes: 50540
package main

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

func main() {
	scan_init()
	n := scanInt()
	a := make([]int, n)
	max := 0
	for i:= 0; i<n; i++ {
		a[i] = scanInt()
		if max < a[i] {
			max = a[i]
		}
	}
	if boolSosu(a, max) {
		fmt.Println("pairwise coprime")
	} else {
		g := 0
		for i:= 0; i<n;i ++ {
			g = gcd(g,a[i])
		}
		if g == 1 {
			fmt.Println("setwise coprime")
		} else {
			fmt.Println("not coprime")
		}
	}
}
	func gcd(a int, b int) int {
		// aの方が小さくなるように設定する
		// ユークリッドの互除法で最大公約数を出す
		if a>b {
			//swap
			tmp := a
			a = b
			b = tmp
		}
		if a == 0 {
			return b
		}
		r := b % a
		if r != 0 {
			return gcd(r,a)
		} else {
			return a
		}
	}
	func allSosu(max int) map[int]bool{
		// max値までの素数群を返す
		// 計算量logmax*logmax
		output := map[int]bool{}
		furui := make([]int, max+1)
		for i:= 2; i*i<=max; i++ {
			if furui[i] > 0 {
				continue
			}
			for j:=i+i; j<=max; j += i{
				furui[j]++
			}
		}
		for i:=2; i<=max; i++ {
			if furui[i] == 0 {
				output[i] = true
			}
		}
		return output
	}
	func boolSosu(list []int, max int) bool {
			// 与えられた群がすべての要素に対し互いに素の時trueを返す
			furui := make([]int, max+1)
			for i:= 0;i<len(list); i++ {
				furui[list[i]]++
			}
			for i:=2; i<max; i++ {
				cnt := 0
				for j:=i; j<=max; j+= i {
					cnt += furui[j]
				}
				if cnt>1 {
					return false
				}
			}
			return true
		}
var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 23152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define pb push_back
#define UM unordered_map<int,int>
#define mxsize (int)1e6
vector<int> adj[mxsize];    //adjacency list
bool vis[mxsize];   //vis array for node transversal
int c=0;
void dfs(int node){
    vis[node]=1;
    c++;
    for(auto child:adj[node]){
        if(vis[child]==0){
            dfs(child);
        }
    }
}
void fun(){
    int n;  // number of nodes
    int k;  // number of edges
    cin>>n>>k;
    // 1 to n different type of nodes
    fi(0,k){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int ans=0;
    int no_of_connected_components=0;
    fi(1,n+1){
        if(vis[i]==0){
            dfs(i);
            ans=max(ans,c);
            c=0;
        }
    }
    if(ans==0)  ans=1;
    cout<<ans<<"\n";

    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 39692
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int h, w, k;
string s[15];
bool b[15];
int f(int i) {
	if (i < h - 1) {
		int r = f(i + 1);
		b[i] = 1;
		r = min(r, f(i + 1));
		b[i] = 0;
		return r;
	}
	int cnt[15], cntsub[15], ans = 0;
	for0(i, h) { if (b[i])ans++; cnt[i] = 0; cntsub[i] = 0; }
	for0(j, w) {
		int p = 0;
		bool b00l = 0;
		for0(i, h) {
			if (s[i][j] == '1')cntsub[p]++;
			if (b[i]) {
				if (cntsub[p] > k)return mod;
				else if (cntsub[p] + cnt[p] > k)b00l = 1;
				p++;
			}
		}
		if (cntsub[p] > k)return mod;
		else if (cntsub[p] + cnt[p] > k)b00l = 1;
		ans += b00l;
		if (b00l) for0(i, p + 2)cnt[i] = 0;
		for0(i, p + 2) {
			cnt[i] += cntsub[i]; cntsub[i] = 0;
		}
	}
	return ans;
}
signed main() {
	cin >> h >> w >> k;
	for0(i, h)cin >> s[i];
	puts(f(0));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n; ll d;
ll a[300001];
int main() {
	cin >> n >> d;
	ll s = 0;
	rep(i, n) {
		cin >> a[i];
		a[i]--; a[i] %= (d + 1);
		s ^= a[i];
	}
	if (s==0)cout << "Second" << endl;
	else cout << "First" << endl;
	//stop
	return 0;
}



Measured memory_bytes: 5052
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=((h+1)/2)*((w+1)/2)+(h/2)*(w/2);
    if(h==1||w==1)ans=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int N, M;
Graph G;

void solve() {
    vector<int> dist(N, -1);
    vector<int> prev(N, -1);
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto nv : G[v]) {
            if(dist[nv] == -1) {
                dist[nv] = dist[v] + 1;
                prev[nv] = v;
                que.push(nv);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; ++i)
        cout << prev[i] + 1 << endl;
}

int main() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    solve();
}

Measured memory_bytes: 10608
#include <iostream>
using namespace std;
int main()
{
 int i,l,n;
 l=0;
 cin >> n;
 int a[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 for(i=0;i<n;i++)
 {
  if(a[i]==(l+1))
  l++;
 }
 if(l==0)
 cout << "-1";
 else
 cout << n-l;
 return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    ll n;
    cin >> n;
    vector<ll> arr(n,0);
    ll sum=0;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        sum+=arr[i];
    }
    ll tmp_sum=0;
    ll min=1e18;
    for(int i=0; i<n; i++){
        tmp_sum+=arr[i];
        sum-=arr[i];
        // cout << tmp_sum << " " << sum-tmp_sum << endl;
        if(abs(tmp_sum - sum) < min)
            min = abs(tmp_sum - sum);
    }

    cout << min << endl;

 
 
    return 0;
}

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

int main(){
  int H1, M1, H2, M2, K;
  
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int ans = (H2 * 60 + M2) - (H1 * 60 + M1) - K;
  cout << ans;
}

Measured memory_bytes: 3632
#include <stdio.h>

int gcd(int x, int y)
{
    if(x < y) return gcd(y,x);
    return y==0 ? x : gcd(y, x%y);
}

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d\n", gcd(a,b));
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  int D; cin >> D;
  int X; cin >> X;
  auto res = X;

  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    for (int day = 1; day <= D; day += a) {
      ++res;
    }
  }

  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

void add(T)(ref T a, T b) { a = (a + b) % MOD; }

long calc(string s, int d) {
    int n = cast(int) s.length;
    auto dp = new int[][][](n + 1, 2, d);
    // dp[i][j][k]
    // i: 上から i 桁目まで
    // j: n 未満か
    // k: mod d

    dp[0][0][0] = 1;
    foreach (i; 0..n) {
        foreach (j; 0..2) {
            foreach (k; 0..d) {
                int lim = j == 1 ? 9 : s[i] - '0';
                foreach (m; 0..lim+1) {
                    add(dp[i + 1][j || m < lim][(k + m) % d], dp[i][j][k]);
                }
            }
        }
    }

    // -1 は 0 の分
    return (-1L + MOD + dp[n][0][0] + dp[n][1][0]) % MOD;
}

void main() {
    string s = read!string;
    int d = readint;
    writeln(calc(s, d));
}


Measured memory_bytes: 14332
S = gets.chomp
T = gets.chomp
N = S.length

map = Hash.new

N.times do |i|
    if map[S[i]] && map[S[i]] != T[i]
        puts 'No'
        exit
    end
    map[S[i]] = T[i]
end

if map.length != map.values.uniq.length
    puts 'No'
else
    puts 'Yes'
end

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            
            int ans = 1;
            
            for(int i = 0 ; i < N ; i++)
            {
                ans = Math.Min(ans*2, ans+K);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
import heapq
def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d


n=int(input())
edge = [[] for i in range(n)]
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append((z,y-1))
    edge[y-1].append((z,x-1))


q,k=map(int,input().split())
d=dijkstra_heap(k-1)

ans_list=[]
for g in range(q):
    x,y=map(int,input().split())
    ans_list.append(d[x-1]+d[y-1])

for g in range(q):
    print(ans_list[g])

Measured memory_bytes: 99744
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    long long  n;
    cin >> n;
    long long ans=1e13;

    for (long long i = 1; i*i <= n; i++){
        long long j;
        j = n / i;
        if (n % i == 0) {
            
            ans = min(ans, i + j - 2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int head[maxn],nxt[maxn],ver[maxn],num[maxn],flow[maxn],tot=1;
inline void addedge(int a,int b,int c,int v)
{
	nxt[++tot]=head[a];ver[tot]=b;flow[tot]=c;num[tot]=v;head[a]=tot;
	nxt[++tot]=head[b];ver[tot]=a;flow[tot]=0;num[tot]=v;head[b]=tot;
}
int d[maxn],s,t,q[maxn],he,ta;
inline bool bfs()
{
	for(int i=1;i<=t;i++) d[i]=0;d[q[he=ta=1]=s]=1;
	while(he<=ta)
	{
		int x=q[he++];
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];if(flow[i]==0||d[y]) continue;
			d[y]=d[x]+1;q[++ta]=y;if(y==t) return 1;
		}
	}
	return 0;
}
inline int dinic(int x,int Flow)
{
	if(x==t) return Flow;
	int ans=0;
	for(int i=head[x];i;i=nxt[i])
	{
		int y=ver[i];if(flow[i]==0||d[y]!=d[x]+1) continue;
		int t=dinic(y,min(flow[i],Flow));
		flow[i]-=t;Flow-=t;flow[i^1]+=t;ans+=t;
		if(!Flow) break;
	}
	return ans;
}
int n,m,a[101][101];
int main()
{
	scanf("%d%d",&n,&m);s=n+n+1;t=n+n+2;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
	for(int ttt=1;ttt<=m;ttt++)
	{
		for(int i=1;i<=t;i++) head[i]=0;tot=1;
		for(int i=1;i<=n;i++) for(int j=ttt;j<=m;j++) addedge(i,(a[i][j]-1)/m+n+1,1,j);
		for(int i=1;i<=n;i++) addedge(s,i,1,-1),addedge(i+n,t,1,-1);
		while(bfs()) dinic(s,23333333);
		for(int i=1;i<=n;i++) for(int v=head[i];v;v=nxt[v]) if(ver[v]>n&&ver[v]<=n+n&&flow[v]==0)
			swap(a[i][ttt],a[i][num[v]]);
	}
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%d ",a[i][j]);putchar('\n');}
	for(int i=1;i<=m;i++)
	{
		vector<int> V;
		for(int j=1;j<=n;j++) V.push_back(a[j][i]);
		sort(V.begin(),V.end());
		for(int j=1;j<=n;j++) a[j][i]=V[j-1];
	}
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)printf("%d ",a[i][j]);putchar('\n');}
	return 0;
}

Measured memory_bytes: 4168
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string S;
    in(S);

    if (S <= "2019/04/30")
    {
        outl("Heisei");
    }
    else
    {
        outl("TBD");
    }

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b)*c/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
  
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    int i;
    vector<int> a;
    for(i=0;i<n;i++){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    
    int counter = 0;
    while(1){
        bool all_even = true;
        for(i=0;i<n;i++){
            if(a[i]%2==1){
                all_even = false;
                break;
            }
        }
        if(all_even){
            counter++;
            for(i=0;i<n;i++)
                a[i] = a[i]/2;
        }
        else
            break;
    }
    
    cout << counter << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

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

	if (n == 1) {
		if (m == 1) {
			cout << 1 << endl;
		}
		else if(m==2) {
			cout << 0 << endl;
		}
		else {
			cout << m - 2 << endl;
		}
	}
	else if (n == 2) {
		cout << 0 << endl;
	}
	else {
		if (m == 1) {
			cout << n - 2 << endl;
		}
		else if (m == 2) {
			cout << 0 << endl;
		}
		else {
			cout << (m - 2)*(n-2) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100009],b[100009],c[100009];
int dp[100009][3];
int main() {
    ios::sync_with_stdio(false);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    memset(dp,0x3f, sizeof(dp));
    dp[1][0]=a[1];dp[1][1]=b[1];dp[1][2]=c[1];
    for(int i=2;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	long long int arr[3]={0},temp[3];
	for(i=0;i<3;i++)
		cin>>arr[i];
	for(j=1;j<n;j++)
	{
		for(i=0;i<3;i++)
			temp[i]=arr[i];
		for(i=0;i<3;i++)
			cin>>arr[i];
		for(i=0;i<3;i++)
			arr[i]= arr[i] + max( temp[(i+1)%3],temp[(i+2)%3]);
	}
	cout<<max(arr[0],max(arr[1],arr[2]));
	return 0;
}

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

int main() {
  int n; cin >> n;
  int ans = 0;
  vector<int> a(n), c(n-1);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i, n) {
    int b; cin >> b;
    ans += b;
  }
  rep(i, n-1) cin >> c[i];
  rep(i, n-1) {
    if (a[i] + 1 == a[i+1]) ans += c[a[i]];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
N = input()
E = []

if N%2==0:
  for i in range(1, N+1):
    for j in range(i+1, N+1):
      if i+j!=N+1:
        E += [(i, j)]
else:
  for i in range(1, N):
    for j in range(i+1, N):
      if i+j!=N:
        E += [(i, j)]
    E += [(i, N)]

print len(E)
for e in E:
  print e[0], e[1]


Measured memory_bytes: 2948
import bisect
inpl = lambda: list(map(int,input().split()))
_ = int(input())
A = sorted(inpl())
Anlist = []
ap = 0
for a in A:
  if a > ap:
    Anlist.append([a,1])
    ap = a
  else:
    Anlist[-1][1] += 1

A = [ a for a,n in Anlist ]
N = len(Anlist)

ans = 0
for i in range(1,N+1):
  if Anlist[-i][1] == 0:
    continue
  
  p = len(bin(A[-i]))-3
  B = (1 << (p+1)) - A[-i]
  if A[-i] == B:
    ans += Anlist[-i][1]//2
  else:
    m = bisect.bisect_left(A,B,0,N-i)
    if m < N-i and A[m] == B:
      pairs = min(Anlist[m][1],Anlist[-i][1])
      ans += pairs
      Anlist[m][1] -= pairs

print(ans)

Measured memory_bytes: 33940
#include<bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
const int mod=1e9+7;
vector<vector<long long int>> edges(mx);
vector<vector<long long int>> dp(mx,vector<long long int>(2,1));
vector<bool> vis(mx,false);

void find(int v)
{
  vis[v]=true;
  for(auto i:edges[v])
  {
    if(!vis[i])
    {
      find(i);
      dp[v][0]=(dp[v][0]*dp[i][1])%mod;
      dp[v][1]=(dp[v][1]*(dp[i][0]+dp[i][1])%mod)%mod;
    }
  }
}
int main()
{
  int n;
  cin>>n;
  int u,v;
  for(int i=0;i<n-1;i++)
  {
    cin>>u>>v;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  find(1);
  long long int ans=(dp[1][0]+dp[1][1])%mod;
  cout<<ans;
}

Measured memory_bytes: 15360
#include <iostream>
#include <cmath>

using namespace std; 

int main(void) {
	double N,T,A;
	cin >> N >> T >> A;

	int now = -1;
	double nmin = (1 << 28);
	for (int i = 0; i < N; ++i) {
		double H;
		cin >> H;
		if (abs(A-(T-(H*0.006))) < nmin) {
			nmin = abs(A-(T-(H*0.006)));
			now = i+1;
		}
	}
	cout << now << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  string S;cin>>S;
  int x=0,m=0;
  for(int i=0; i<N; i++){
    if(S[i]=='I')x++;
    else if(S[i]=='D')x--;
    m=max(m,x);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    int k[11];
    int s[11][11];
    int p[11];
    cin >> N >> M;
    rep(i,M){
        cin >> k[i];
        rep(j,k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,M){
        cin >> p[i];
    }
    int ans = 0;
    for(int bit=0;bit<(1<<N);bit++){
        bool flg=true;
        rep(i,M){
            int tmp=0;
            rep(j,k[i]){
                if(bit&(1<<s[i][j])){
                    tmp++;
                }
            }
            if(tmp%2!=p[i]){
                flg=false;
            }
        }
        if(flg){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int main(){
    ll h,n,sum=0;
    cin>>h>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}                     

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

int main() {
	int N, M, A[1010], B[1010], K[1010][1010];
	cin >> N >> M;
	for(int i=0; i<N; ++i){
	    cin >> A[i];
	    for(int j=0; j<M; ++j) K[i][j]=0;
	}
	for(int i=0; i<M; ++i) cin >> B[i];
	sort(A, A+N, greater<int>()); A[N]=0;
	sort(B, B+M, greater<int>()); B[M]=0;
	int ans=1, h=0, w=0;
	for(int i=N*M; i>0; --i){
	    if(A[h]==i){
	        ++h;
	        if(B[w]==i) ++w;
	        else ans=((long) ans*w)%1000000007;
	    }
	    else if(B[w]==i){
	        ++w;
	        ans=((long) ans*h)%1000000007;
	    }
	    else ans=((long) ans*(h*w-(N*M-i)))%1000000007;
	    if(ans==0) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256