akhauriyash/Code-Regression huggingface dataset:
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  ll x;
  cin>>x;
  ll cur=100;
  int cnt=0;
  while(cur<x){
    cnt++;
    double risi=(101)/100.0;
    cur*=risi;
  }

  cout<<cnt<<endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
#define ld long double

int solve(){
	int s, w;
	cin>> s>> w;
	if(w >= s)
		cout<< "unsafe\n";
	else
		cout<< "safe\n";	
	return 0;
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}
//upper_bound returns an iterator pointing to the 
//first element in the range [first,last) which has a value greater than ‘val’

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

class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res = 0;
        for (int i = 0; i < a.Length; i++)
        {
            res = Math.Max(a.Take(i + 1).Sum() + b.Skip(i).Sum(), res);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13396
import sys
import itertools
import numpy as np
N, M, X = map(int, input().split())
CA = [0 for _ in range(N)]
for i in range(N):
    CA[i] = list(map(int, input().split()))
CA = np.array(CA)

cost = float('inf')
for i in range(1, N + 1):
    L = list(itertools.combinations(CA, i))
    for l in L:
        tmp = sum(l)
        if np.all(tmp[1:] >= X):
            cost = min(cost, tmp[0])
else:
    print(-1 if cost == float('inf') else cost)

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

long long memo[86];
long long luca(int n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (memo[n] != 0) return memo[n];
  return memo[n] = luca(n-1) + luca(n-2);
}

int main() {
  int N;
  cin >> N;
  cout << luca(N) << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <numeric>
#include <iostream>
using namespace std;

long long check(int n, int *a, bool *neg) {
    long long maxval[n+1][n+1], minval[n+1][n+1];
    for (int i = 0; i < n; i++)
        maxval[i][i+1] = minval[i][i+1] = a[i];
    for (int w = 2; w <= n; w++)
        for (int i = 0, j = w; j <= n; i++, j++) {
            long long mx = -(1LL<<60), mn = 1LL<<60;
            for (int k = i + 1; k < j; k++) {
                // [i, k), [k, j)
                if (neg[k]) {
                    mx = max(mx, maxval[i][k] - minval[k][j]);
                    mn = min(mn, minval[i][k] - maxval[k][j]);
                } else {
                    mx = max(mx, maxval[i][k] + maxval[k][j]);
                    mn = min(mn, minval[i][k] + minval[k][j]);
                }
            }
            maxval[i][j] = mx;
            minval[i][j] = mn;
        }
    return maxval[0][n];
}

int main() {
    int n; cin >> n;
    int a[n];
    bool neg[n];
    cin >> a[0];
    neg[0] = false;
    for (int i = 1; i < n; i++) {
        char c; cin >> c >> a[i];
        neg[i] = c == '-';
    }
    long long pref[n+1], suf[n+1];
    pref[0] = 0; suf[n] = 0;
    for (int i = 0; i < n; i++)
        pref[i+1] = pref[i] + a[i] * (neg[i] ? -1 : 1);
    for (int i = n-1; i >= 0; i--)
        suf[i] = suf[i+1] + a[i];
    // for (int i = 0; i <= n; i++) cerr << pref[i] << ' '; cerr << endl;
    // for (int i = 0; i <= n; i++) cerr << suf[i] << ' '; cerr << endl;
    long long ans = pref[n];
    for (int i = n-1, j = n; i >= 0; i--) {
        if (neg[i]) {
            ans = max(ans, pref[i] - suf[i] + 2 * suf[j]);
            j = i;
        }
    }
    cout << ans << endl;
    // if (ans != check(n, a, neg)) {
    //     cerr << "WA\n";
    //     cerr << n << endl;
    //     for (int i = 0; i < n-1; i++) cerr << a[i] << ' ' << (neg[i+1] ? '-' : '+') << ' ';
    //     cerr << ' ' << a[n-1] << endl;
    // }
}


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

using namespace std;

int main()
{
	int n;
	int sw = 1;

	cin >> n;

	vector<int> a;

	for (int i = 0; i < n; ++i)
	{
		int a_tmp;
		cin >> a_tmp;
		a.push_back(a_tmp);
	}

	for (int i = 0; i < n; ++i){
		sw = a[sw-1];
		if(sw==2){
			cout << i+1 << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

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

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

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

    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (i % 3 && i % 5) {
        ans += i;
      }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3656
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    multiset<int> st;

    for(int i = 0; i < n; i++){
        auto itr = st.lower_bound(a[i]);
        if(itr == st.begin()){
            st.insert(a[i]);
        } else {
            itr--;
            st.erase(itr);
            st.insert(a[i]);
        }
    }

    cout << st.size() << endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, D;
	cin >> N >> D;

	cout << (int)ceil((float)N / (D * 2 + 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[3010][3010];
char s[3010], t[3010];
pair <int, int > d[3010][3010];
int main(){
    int n, m;
    int ans=0;
    scanf("%s%s",s,t);
    n=strlen(s);
    m=strlen(t);
    a[0][0]=s[0]==t[0];
    d[0][0]=mk(0,0);
    for(int i=1; i<n; ++i){
        d[i][0]=d[i-1][0];
        if(s[i]==t[0])
            d[i][0]=mk(i, 0);
        a[i][0]=max(a[i-1][0], (int)(s[i]==t[0]));
    }
    for(int j=1; j<m; ++j){
        d[0][j]=d[0][j-1];
        a[0][j]=max(a[0][j-1], (int)(s[0]==t[j]));
        if(s[0]==t[j])
            d[0][j]=mk(0, j);
    }
    for(int i=1; i<n; ++i){
       for(int j=1; j<m; ++j){
            d[i][j]=d[i-1][j-1];
            a[i][j]=a[i-1][j-1];
            if(a[i][j-1]>a[i][j]){
                a[i][j]=a[i][j-1];
                d[i][j]=d[i][j-1];
            }
            if(a[i-1][j]>a[i][j]){
                a[i][j]=a[i-1][j];
                d[i][j]=d[i-1][j];
            }
            if(s[i]==t[j]){
                if(a[i-1][j-1]+1 > a[i][j]){
                    d[i][j]=mk(i,j);
                    a[i][j]=a[i-1][j-1]+1;
                }
            }
       }
    }
    ans=a[n-1][m-1];
    vector < char > v;
    int x, y, tmp1, tmp2;
    x=n;
    y=m;
    for(int i=0; i<ans; ++i){
        tmp1=d[x-1][y-1].fs;
        tmp2=d[x-1][y-1].sc;
        x=tmp1;y=tmp2;
        v.push_back(s[x]);
    }
    reverse(v.begin(), v.end());
    for(int i=0; i<v.size(); ++i)
        cout<<v[i];
    cout<<endl;
    return 0;
}




Measured memory_bytes: 106368
using System;

namespace ConsoleApp11
{
    class MainClass
    {
        public static void Main()
        {//Nが奇数　確率
            double N = int.Parse(Console.ReadLine());
            int E = (int)N / 2;  //偶数
            double ans = (N - E) / N;
            Console.WriteLine(ans.ToString("0.0000000"));
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef unsigned long long parallel_type;
const int bit_width=8*sizeof(parallel_type);

int main(){
	int H,W;
	for(;~scanf("%d%d",&H,&W)&&H&&W;){
		vector<string>m(H);
		for(int h=0;h<H;h++)cin>>m[h];
		if(H<=21){
			vector<vector<parallel_type> >l(H);
			int parallel_width=(W+bit_width-1)/bit_width;
			for(int h=0;h<H;h++){
				l[h].resize(parallel_width);
				for(int w=0;w<W;w++)l[h][w/bit_width]|=parallel_type(m[h][w]=='1')<<(w%bit_width);
			}
			int R=0;
			for(int i=0;i<1<<H;i++){
				vector<parallel_type> v(parallel_width);
				int r=0;
				for(int j=0;j<H;j++)if(i>>j&1){
					r++;
					for(int k=0;k<parallel_width;k++)v[k]^=l[j][k];
				}
				if(none_of(v.begin(),v.end(),[](parallel_type e){return e;}))R=max(R,r);
			}
			cout<<R<<endl;
		}else{
			vector<int>b(H);
			for(int h=0;h<H;h++){
				for(int w=0;w<W;w++)b[h]=(b[h]<<1)|(m[h][w]=='1');
			}
			vector<short>s(1<<W),t(1<<W);
			for(int w=1;w<1<<W;w++)s[w]=-1;
			for(int h=0;h<H;h++){
				for(int w=0;w<1<<W;w++){
					t[w]=max(s[w],short(s[w^b[h]]>=0 ? 1+s[w^b[h]] : -1));
				}
				swap(s,t);
			}
			cout<<s[0]<<endl;
		}
	}
}

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

int main(void){
   
    int a,b,r;
    unsigned long long int x;
    cin >> a >> b;

    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    x = (unsigned long long int)a * b;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    
    cout << x / b << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(){
    char indata[1000000],load[10000];
    int i,j,in,ln,state;
    
    scanf("%s",indata);
    scanf("%s",load);
    in=strlen(indata);
    ln=strlen(load);
    
    //printf("in = %d , ln = %d\n",in,ln);
    for(i=0;i<in;i++){
        state=1;
        if(indata[i]==load[0]){
            state=0;
            for(j=0;j<ln;j++){
                if(indata[i+j]!=load[j]){
                    state=1;
                    break;
                }
            }
        }
        if(state==0)printf("%d\n",i);
    }
    
    
    return 0;
    
}

Measured memory_bytes: 548
//CF handle :dineshg
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

ll n,m,v,p;
ll arr[100007];
ll faltu;
ll fi;

bool fun(ll x)
{
	ll tot = m*v;
	ll curr = (p)*m;
	curr+= (n-x)*m;

	if(curr >= tot)
		return 1;
	for(ll i=p;i<x ;i++)
	{
		//if(i!=x){
		if(arr[x] - arr[i] + m >=0)
			curr+=arr[x]-arr[i]+m;
		if(curr>=tot)
			return 1;
	//}
	}

	return 0;

}
int main()
{
	fastio
	cin >> n >> m >> v >>p;
	for(ll i=1;i<=n;i++)
		cin >> arr[i];
	sort(arr+1,arr+n+1 ,greater<int>());
	ll i;
	for( i=p+1;i<=n;i++)
	{
		if(arr[i]+m <arr[p])
			break;
	}
	ll start = p;
	ll end = i-1;

	fi = i;
	faltu = n-i+1;

	ll mid = start + (end-start)/2;
//	cout << start << " " << mid << " " << end << endl;
	while(end-start>1)
	{
		if(fun(mid))
			start =mid;
		else
			end=mid-1;

		mid = start + (end-start)/2;


	//cout << start << " " << mid << " " << end << endl;
	}
	ll ans;
	for(ll i= start ;i<=min(n,end);i++)
	{
		if(fun(i)){
	//		cout << i << endl;
			ans = i;
		}
	}
//	cout << fun(2);
	cout << ans << endl;

	return 0;	
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    Graph G(n);
    char buf = 0;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cin >> buf;
            if (j < i) continue;
            if (buf == '1') {
                G.at(i).push_back(j);
                G.at(j).push_back(i);
                cnt++;
            }
        }
    }

    int ans = 0;
    for (int i=0; i<n; i++) {
        queue<int> que;
        vector<int> dis(n, -1);
        dis.at(i) = 1;
        int buf = 0;
        que.push(i);
        while (!que.empty()) {
            int cur = que.front(); que.pop();
            for (int x : G.at(cur)) {
                if (dis.at(x) == -1) {
                    dis.at(x) = dis.at(cur) + 1;
                    que.push(x);
                    buf = max(buf, dis.at(x));
                }
                else {
                    if (dis.at(x) == dis.at(cur) - 1) {
                        continue;
                    }
                    if (dis.at(x) != dis.at(cur) + 1) {
                        cout << -1 << endl;
                        return 0;
                    }
                }
            }
        }
        ans = max(ans, buf);
    }
    cout << ans << endl;
    return 0;
}


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

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


int main() {
  
  int N; 
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int ans = 0;
  for(int i = 0; i < N; i++) {
    ans = gcd(A[i], ans);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int):
    print(1 << (N.bit_length() - 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;

char map[2048][2048];
int dp[2048][2048];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(dp, 0, sizeof(dp));
		memset(map, 0, sizeof(map));
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				scanf(" %c", &map[i][j]);
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (map[i][j] == '.'){
					dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				}
	//			printf("%d", dp[i][j]);
			}
	//		printf("\n");
		}
		
		int maxi = 0;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				maxi = max(maxi, dp[i][j]);
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}

Measured memory_bytes: 21516
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
/*
jq	 500M	 1000M
AAA	 35b50	 1ª11b00
AA	 37b50	 1ª17b00
A	 40b00	 1ª23b00
B	 43b00	 1ª29b00
C	 50b00	 1ª45b00
D	 55b00	 1ª56b00
E	1ª10b00	2ª28b00
*/
int main()
{
	const double t500m[] = { 
		0.00, 35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 70.00, DBL_MAX };
	const double t1000m[] = {
		0.00, 71.00, 77.00, 83.00, 89.00, 105.00, 116.00, 148.00, DBL_MAX };
	const string cname[] = { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };

//	cut here before submit 
//	freopen ("testcase.speedskat", "r", stdin );

	string str = "";
	int i,j;
	while (getline (cin, str ) ){
		double time1, time2;
		stringstream ss(str);
		ss >> time1 >> time2;

		int c500 = -1;
		int c1000 = -1;
		for (i = 0; i < sizeof(t500m)/sizeof(t500m[0]) - 1; ++i){
			if (time1 >= t500m[i] && time1 < t500m[i+1] ){
				c500 = i;
				break;
			} // end if
		} // end for

		for (j = 0; j < sizeof(t1000m)/sizeof(t1000m[0]) - 1; ++j){
			if (time2 >= t1000m[j] && time2 < t1000m[j+1] ){
				c1000 = j;
				break;
			} // end if
		} // end for

		int decide_class = max (c500, c1000);
		cout << cname[decide_class] << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
a, b, m = map(int, input().split())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
# 割引券を使った場合の最少額を求める
min_m = float('inf')
for ai, bi, c in [map(int, input().split()) for _ in range(m)]:
	if min_m > A[ai-1] + B[bi-1] - c:
		min_m = A[ai-1] + B[bi-1] - c
print(min(min(A)+min(B),min_m))

Measured memory_bytes: 62308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B, R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

// 1-D 標準出力にHelloWorldと出力する
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//1時間＝60分の60
		final int intMinute  = 60;

		//１分＝60秒の60
		final int intSecond = 60;

		//解答の時間を初期化
		int intAnswerHour = 0;

		//解答の分を初期化
		int intAnswerMinute = 0;

		//解答の秒を初期化
		int intAnswerSecond = 0;


		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力値をString型で受け取る
			String strLine = br.readLine();

			//入力値を数字に直す
			int intLine = Integer.parseInt(strLine);

			//時間を計算
			//3600で割った整数
			intAnswerHour = intLine / (intMinute * intSecond);

			//分を計算
			//3600の剰余を60で割った整数
			intAnswerMinute = (intLine % (intMinute * intSecond)) / intSecond ;

			//秒を計算
			//60の剰余
			intAnswerSecond = intLine % intSecond;

			//結果を出力
			System.out.println(intAnswerHour + ":" + intAnswerMinute + ":" + intAnswerSecond);

		//例外処理
		}catch(IOException e) {

			//例外時の出力
			System.out.println(e);

		//数字以外の例外
		}catch(NumberFormatException e) {

			//数値以外の入力値で出力
			System.out.println("数値で入力して下さい");
		}
	}
}

Measured memory_bytes: 16932
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;

void main()
{
	int n, k;
	readln.chomp.split.tie(n, k);
	if (k == 0) {
		writeln = cast(long) n * n;
		return;
	}
	long cnt = 0;
	for (int b = 1; b <= n; ++b) {
		int p = n / b;
		int r = n % b;
		cnt += p * max(0, b - k);
		cnt += max(0, r - k + 1);
	}
	cnt.writeln;
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  int k;
  cin >> k;
  vector<ll> q;
  for (int i = 1; i <= 9; i++)
  {
    q.push_back(i);
  }
  while (1)
  {
    vector<ll> old;
    swap(old, q);
    int l = old.size();
    if (l < k)
    {
      for (ll x : old)
      {
        for (int i = -1; i <= 1; i++)
        {
          int y = x % 10 + i;
          if (y < 0 || y > 9)
            continue;
          q.push_back(x * 10 + y);
        }
      }
      k -= l;
    }
    else
    {
      cout << old[k - 1] << endl;
      break;
    }
  }

  return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-4;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x[50], y[50];

signed main() {
	cin >> n;
	if (n%2) return cout << "NA" << ln, 0;
	rep(i,n) cin >> x[i] >> y[i];
	double xx = 1.*(x[0] + x[n/2])/2, yy = 1.*(y[0] + y[n/2])/2;
	bool ok = true;
	rep(i,n/2) if (fabs(x[i]+x[(i+n/2)%n]-xx*2)>=eps || fabs(y[i]+y[(i+n/2)%n]-yy*2)>=eps) ok = false;
	if (ok) printf("%.10lf %.10lf\n",xx,yy);
	else cout << "NA" << ln;
}


Measured memory_bytes: 3232
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
l=0
r=a[-1]
while r-l>1:
  cnt=0
  m=(l+r)//2
  #print("l,m,r",l,m,r)
  for i in a:
    cnt+=(i-1)//m
  if cnt<=k:
    r=m
  else:
    l=m
print(r)

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

using namespace std;

int n, p;
int peb[55];

void solve() {
	int c = 0;
	int p_ = p;
	
	while (1) {
		if (p_ == 0) {
			p_ += peb[c];
			peb[c] = 0;
			c++;
		} else {
			peb[c]++;
			if (peb[c] == p) break;
			p_--;
			c++;
		}
		
		c %= n;
	}
	
	cout << c << endl;
}

int main() {
	while (1) {
		cin >> n >> p; if (n == 0 && p == 0) break;
		memset(peb, 0, sizeof(peb));
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] temp = in.nextLine().trim().split("\\s");
        int n = Integer.parseInt(temp[0]);
        int w = Integer.parseInt(temp[1]);
        int[] warr = new int[n];
        int[] varr = new int[n];
        for(int i = 0; i < n; i++){
            temp = in.nextLine().trim().split("\\s");
            warr[i] = Integer.parseInt(temp[0]);
            varr[i] = Integer.parseInt(temp[1]);
        } 
        long[][] dp = new long[n+1][w+1];
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= w; j++){
                dp[i][j] = dp[i-1][j];
                if(j >= warr[i-1]){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j-warr[i-1]] + varr[i-1]);
                }
            }
        }
        
        System.out.println(dp[n][w]);
    }
}

Measured memory_bytes: 125780
#include<iostream>
using namespace std;
double u;
int N,M,A[1001],total,num,i;
int main()

{
    cin>>N>>M;
    for(i=1;i<=N;i++)
    {
        cin>>A[i];
        total= total+A[i];
    }
   u=total/(4.0*M);
    for(i=1;i<=N;i++)
    {
        if(A[i]>=u)
            num++;
    }
    if(num>=M)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  priority_queue <int> queue;
  vector <int> list;
  for(int i = 0; i < N; i++){
    int list_single;
    cin >> list_single;
    queue.push(list_single);
  }

  int sum_a = 0;
  int sum_b = 0;
  while(true){
    sum_a = sum_a + queue.top();
    queue.pop();
    if(queue.size() == 0){
       break;
    }
    sum_b = sum_b + queue.top();
    queue.pop();
    if(queue.size() == 0){
      break;
    }else{
      continue;
    }
  }
  cout << sum_a-sum_b << endl;
}


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

set<int>a;

int main()
{
	int n;cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		int p;cin>>p;
		if(a.find(p)!=a.end())a.erase(p);
		else a.insert(p);
	}
	cout<<a.size()<<endl;
	return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  int max1 = 0;
  int min1 = 100010;
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    max1 = max(max1,a);
    min1 = min(min1,b);
  }
  cout << max(0,min1-max1+1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] t = new int[n];
		for(int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		
		int m = sc.nextInt();
		int[][] p = new int[2][m];
		for(int i = 0; i < m; i++) {
			p[0][i] = sc.nextInt();
			p[1][i] = sc.nextInt();
		}
		
		int no;
		int sec;
		int sum;
		for(int i = 0; i < m; i++) {
			sum = 0;
			for(int j = 0; j < n; j++) {
				if(j + 1 == p[0][i]) {
					sum += p[1][i];
				} else {
					sum += t[j];
				}
			}
			System.out.println(sum);
		}

	}

}


Measured memory_bytes: 22356
def main():
    s = list(input())
    now = 0
    for i in range(len(s)):
        if s[i] == '?':
            if i == 0 or s[i-1] == 'P' or s[i-1] == '?':
                s[i] = 'D'
                continue
            if i+1 < len(s)  and( s[i+1] == 'D' or s[i+1] == '?'):
                s[i] ='P'
                continue
            s[i] = 'D'
    print(''.join(s))

if __name__=='__main__':
    main()


Measured memory_bytes: 10920
#include<stdio.h>

int main()
{
  int n;
  int i;
  long long p=1;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
  {
   p=(p*i)%(1000000007);
  }
  
  printf("%lld\n",p);
  
  return 0;
}

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

int main() {
    int n;
    string s, ss, sss;
    cin >> n >> s >> ss;
    for(int i = 0; i < n; ++i) {
        sss.push_back(s[i]);
        sss.push_back(ss[i]);
    }
    cout << sss << '\n';
}


Measured memory_bytes: 256
import java.io.*;
    import java.util.*;
    public class Main {
    	
    	static final int INF = Integer.MAX_VALUE;
    	static PriorityQueue<Vertex> pq = new PriorityQueue<>();
    	static boolean[] visited;
    	static Vertex[] vs;
    	
    	static class Vertex implements Comparable<Vertex> {
    		int index;
    		int shortestDist;
    		ArrayList<Integer> adj;
    		boolean[] used = new boolean[4];
    		
    		public Vertex(int i) {
    			index = i;
    			shortestDist = INF;
    			adj = new ArrayList<>();
    		}
    		
    		public int compareTo(Vertex v) {
    			return Integer.compare(shortestDist, v.shortestDist);
    		}
    		
    //		public String toString() {
    //			return "" + index + " " + shortestDist;
    //		}
    	}
    	
    	public static void main(String[] args) {
    		InputReader in = new InputReader();
    		int n = in.nextInt();
    		int m = in.nextInt();
    		
    		vs = new Vertex[n];
    		for (int i=0; i<n; i++)
    			vs[i] = new Vertex(i);
    		
    		for (int i=0; i<m; i++) {
    			int u = in.nextInt() - 1;
    			int v = in.nextInt() - 1;
    			vs[u].adj.add(v);
    		}
    		int s = in.nextInt() - 1, t = in.nextInt() - 1;
    		
    		visited = new boolean[n];
    		visited[s] = true;
    		vs[s].shortestDist = 0;
    		pq.add(vs[s]);
    		
    		while (!pq.isEmpty() && !visited[t]) {
    			Vertex v = pq.poll();
    			dijkstra(v.index, v.index, 0);
    		}
    		
    		System.out.println(vs[t].shortestDist == INF ? -1 : vs[t].shortestDist);
    		
    	}
    	
    	public static void dijkstra(int cur, int start, int dist) {
    		if (dist == 3) {
    			if (!visited[cur]) {
    				visited[cur] = true;
    				vs[cur].shortestDist = vs[start].shortestDist + 1;
    				pq.add(vs[cur]);
    			}
    			return;
    		}
    		if (!vs[cur].used[dist]) {
    			vs[cur].used[dist] = true;
    			for (int i: vs[cur].adj) {
    				dijkstra(i, start, dist+1);
    				vs[i].used[dist+1] = true;
    			}
    		}
    		
    	}
     
    	static class InputReader {
    		public BufferedReader br;
    		public StringTokenizer st;
    		
    		public InputReader() {
    			br = new BufferedReader(new InputStreamReader(System.in));
    			st = null;
    		}
    		
    		public String next() {
    			while (st == null || !st.hasMoreTokens()) {
    				try {
    					st = new StringTokenizer(br.readLine());
    				}
    				catch (IOException e) {
    					throw new RuntimeException(e);
    				}
    			}
    			return st.nextToken();
    		}
    		
    		public int nextInt() {
    			return Integer.parseInt(next());
    		}
    	}
    }

Measured memory_bytes: 58368
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int, N: int):
    if N < B:
        ret = A * N // B - A * (N // B)
    else:
        a = A * (B - 1) // B
        m = (N // B) * B - 1
        b = A * m // B - A * (m // B)
        c = A * N // B - A * (N // B)
        ret = max(a, b, c)
    print(ret)
    return

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
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()


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

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;



signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    string str;
    cin >> str;
    if(str.back() == 's'){
        cout << str + "es" << '\n';
        return 0;
    }
    cout << str + "s" << '\n';
    

    return 0;

}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;
	bool f=false;
	char c=getchar();
	while(!isdigit(c))f|=c=='-',c=getchar();
	while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f?~x+1:x;
}
int main(){
	int n=read();
	printf("%d",(1000-n%1000)%1000);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;

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

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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	string t = a + b;
	bool bo = false;
	for(int i = 1; i <= 400; i++) {
		if (to_string(i * i) == t) bo = true;
	}
	if (bo) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int ans = 700;
    for(int i=0;i<S.size(); i++){
        if(S[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

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

ll N;

int cal(ll x)
{
	int res = 0;
	while(x){
		res++;
		x/=10;
	}
	return res;
}

void solve()
{
	int ans = cal(N);
	for(ll x=2;x*x<=N;++x)if(N%x==0){
		ans=min(ans,max(cal(x),cal(N/x)));
	}
	cout << ans;
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	N = list(map(int,input().split()))
	input()
	n = N[0]
	m = N[1]

	cnt = 0
	while True:
		if m >= n:
			cnt += 1
			break
		n = n - m + 1
		cnt += 1

	print(cnt)


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	char A[H][W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < W + 2; i++) {
		cout << "#";
		if (i == W+1) {
			cout << endl;
		}
	}
	for (int i = 0; i < H ; i++) {
		cout << "#";
		for (int j = 0; j < W; j++) {
			cout << A[i][j];
		}
		cout << "#" << endl;
	}
	for (int i = 0; i < W + 2; i++) {
		cout << "#";
		if (i == W+1) {
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
from sys import setrecursionlimit


setrecursionlimit(10**6)



n = int(input())
t = [list(map(int, input().split())) for _ in range(n-1)]



hands = [0 for _ in range(n+1)]
for a, b in t:
    hands[a] += 1
    hands[b] += 1

number_of_colors = max(*hands)

def next_color(i):
    return i+1 if i < number_of_colors else 1



class edge():
    def __init__(self, en):
        self.ends = en
        self.color = 0

    def set_color(self, co):
        self.color = co

class nord():
    def __init__(self, tr):
        self.parent = tr
        self.edges = []

    def add(self, ed):
        self.edges.append(ed)

    def set_color(self, previous_color):
        co = next_color(previous_color)
        for ed in self.edges:
            if ed.color == 0:
                ed.set_color(co)
                for i in ed.ends:
                    no = self.parent.nords[i-1]
                    if self is not no:
                        no.set_color(co)
                co = next_color(co)

class tree():
    def __init__(self):
        self.nords = []

    def add_nord(self, no):
        self.nords.append(no)

    def add_edge(self, ed):
        for i in ed.ends:
            self.nords[i-1].add(ed)

    def set_color(self):
        self.nords[0].set_color(0)


tr = tree()
for _ in range(n):
    no = nord(tr)
    tr.add_nord(no)

e_tree = []
for en in t:
    ed = edge(en)
    e_tree.append(ed)
    tr.add_edge(ed)

tr.set_color()

print(number_of_colors)
for e in e_tree:
    print(e.color)

Measured memory_bytes: 99776
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int main(){
    LL n,b[100005*2];
    cin>>n;
    for(int i=1;i<=n;i++){
        LL a,k;
        cin>>a;
        if(n%2==0){
            if(i%2==0){
                k=(n-i)/2;
            }else{
                k=(n+i)/2;
            }
        }else{
            if(i%2==0){
                k=(n+i)/2;
            }else{
                k=(n-i)/2;
            }
        }
        b[k]=a;
    }
    for(int i=0;i<n;i++){
        cout<<b[i];
        cout<<" ";
    }
}

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

int main(){
    map<int,int> check;
    int N;cin>>N;
    for(int i=0;i<N;i++){
        int k;cin>>k;
        check[k]++;
    }
    auto begin=check.begin(); auto end=check.end();
    for(auto i=begin;i!=end;i++){
        if(i->second>=2){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef unsigned long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 500 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

vector<int> s, t;
vector<ll> u, v;
int n;
ll mat[maxN][maxN];

void no() {
	cout << "-1\n"; exit(0);
}

void transp() {
	for(int i = 0; i < n; i++)
		for(int j = 0; j < i; j++) swap(mat[i][j], mat[j][i]);
	swap(s, t);
	swap(u, v);
}

void cumplands() {
	for(int i = 0; i < n; i++) {
		if(s[i]) continue;
		ll crv = ~(ll(0));
		for(int j = 0; j < n; j++) crv &= mat[i][j];
		if(crv != u[i]) no();
	}
}

const int bts = 64;
const ll un = 1;

bool isColGood(int w) {
	ll ret = ~(ll(0));
	for(int i = 0; i < n; i++)
		ret &= mat[i][w];
	return ret == v[w];
}

void otsolv() {
	vector<int> inds, tbl(bts), frq(bts);
	vector<ll> msks(n);
	for(int i = 0; i < n; i++)
		if(!t[i]) inds.push_back(i);
	for(int i = 0; i < n; i++) {
		if(!s[i]) continue;
		ll crv = 0;
		for(int j = 0; j < n; j++) crv |= mat[i][j];
		if((crv | u[i]) != u[i]) no();
		crv = u[i] ^ crv;
		msks[i] = crv;
		if(!crv) continue;
		if(inds.empty()) no();
		for(int j = 0; j < bts; j++)
			if(un << j & crv) frq[j]++;
	}

	for(int i = 0; i < n; i++) {
		if(!msks[i]) continue;
		for(int j = 0; j < bts; j++) {
			if((un << j & msks[i]) && frq[j] == 1) {
				int good = -1;
				for(auto w: inds) {
					mat[i][w] ^= un << j;
					if(isColGood(w)) {good = w; break;}
					mat[i][w] ^= un << j;
				}
				if(good == -1) no();
				msks[i] ^= un << j;
			}
		}
	}

	for(int i = 0; i < n; i++) {
		if(!msks[i]) continue;
		for(int k = 0; k < bts; k++) {
			if(un << k & msks[i]) {
				mat[i][inds[tbl[k]]] |= un << k;
				tbl[k] = (tbl[k] + 1) % inds.size();
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n;
	s.resize(n);
	t.resize(n);
	u.resize(n);
	v.resize(n);
	for(int i = 0; i < n; i++) cin >> s[i];
	for(int i = 0; i < n; i++) cin >> t[i];
	for(int i = 0; i < n; i++) cin >> u[i];
	for(int i = 0; i < n; i++) cin >> v[i];

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(!s[i]) mat[i][j] |= u[i];
			if(!t[j]) mat[i][j] |= v[j];
			if(s[i] && t[j]) mat[i][j] = u[i] & v[j];
		}
	}

	for(int u = 0; u < 2; u++, transp()) cumplands();
	for(int u = 0; u < 2; u++, transp()) otsolv();
	for(int u = 0; u < 2; u++, transp()) cumplands();

	for(int i = 0; i < n; i++, cout << '\n')
		for(int j = 0; j < n; j++) cout << mat[i][j] << ' ';
}



Measured memory_bytes: 7620
#include <stdio.h>

int main() {
	int a,b,n,j,c;
	while(scanf("%d %d",&a,&b)!=EOF) {
		n = a+b;
		c=1;
		for(j=1;1;j++) {
			if ((c<=n)&&(n<10*c)) {
				printf("%d\n",j);
				break;
			}
			c*=10;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
  char a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  if(a[0]==a[1]&&a[1]==a[2]){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#H, W = map(int, input().split())
S = str(input())

if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) :
  print ("Yes")
elif (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]) :
  print ("Yes")
elif (S[0] == S[2] and S[1] == S[3] and S[0] != S[1]) :
  print ("Yes")
else :
  print ("No")
  


Measured memory_bytes: 3440
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2,N):
    ans=gcd(x[i],ans)
print(ans)


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

int main() {
  long long int n,m;
  cin >> n >> m;
  
  vector<int> a(n+1);
  vector<int> z(n+1);
  
  for (long long int i = 0; i < m; i++) {
    long long int p,q;
    cin >> p >> q;
    
    if (p==1) {
      a[q] = 1;
    }
    if (q==n) {
      z[p] = 1;
    }
  }
  
  int flag = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] * z[i]) {
      cout << "POSSIBLE" << endl;
      flag = 1;
      break;
    }
  }
  if (!flag)
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
 
map<char,vector<int>>m3;
string s,t;
int binarySearch(int i,int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
 
        // Check if x is present at mid
       	if ((m3[t[i]][m]<=x)&&(m3[t[i]][m+1]>x))
            return m+1;
 
        // If x greater, ignore left half
        if (m3[t[i]][m] < x)
            l = m + 1;
 
        // If x is smaller, ignore right half
        else
            r = m - 1;
    }
    return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    map<char,int>m1,m2;
    for(int i=0;i<n;i++){
        m1[s[i]]=1;
    }
    for(int i=0;i<m;i++){
        m2[t[i]]=1;
    }
    map<char,int>::iterator it=m2.begin();
    for(it;it!=m2.end();it++){
        if(m1[it->first]!=1){cout<<-1<<endl;return 0;}
    }
    for(int i=0;i<n;i++){
        m3[s[i]].push_back(i);
    }
    map<char,vector<int>>::iterator it1=m3.begin();
    for(it1;it1!=m3.end();it1++){
        sort((it1->second).begin(),(it1->second).end());
    }
    ll res=0;
    int cnt=0;
    int last=0;
    for(int i=0;i<m;i++){
        if(i==0){res+=(1+m3[t[0]][0]);last=m3[t[0]][0];continue;}
        int taille=m3[t[i]].size();
        int el=0;
        if(last>=m3[t[i]][taille-1])el=m3[t[i]][0];
        else{el=m3[t[i]][binarySearch(i,0,taille-1,last)];}
        if(el>last){res+=(el-last);}
        else{res+=(el+1);res+=(n-last-1);}
        last=el;
    }
    cout<<res<<endl;
    return 0;
    }

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	cout.tie(0);
	int ans = 0;
	string pron;string cad;
	cin >> cad >> pron;
	for (int i = 0; i < 3; ++i)
	{
		if(cad[i] == pron[i]) ans++;
	}
     cout << ans;
}

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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007


using namespace std;
void  initialize(vector<int> &v, int n) {
	REP(i, n) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	return;

}


int main() {
	int n;
	double ave = 0, m=0;
	while (1) {
		cin >> n;
		if (n == 0) break;
		vector<int> v;
		initialize(v, n);
		REP(i, n) {
			ave += v[i];
		}
		ave /= n;
		REP(i, n) {
			m += (v[i] - ave)*(v[i] - ave);
		}
		m /= n;
		cout << fixed << setprecision(8) << sqrt(m) << endl;
		ave = 0;
		m = 0;
	}

	return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>

#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H, i, A[MAX+1];

  scanf("%d", &H);

  for(i=1; i<=H; i++) scanf ("%d", &A[i]);

  for(i=1; i<=H; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i)>=1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ", A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2056