akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int N, X, f = 0;
  cin >> N;
  X = N;

  while (true) {
    f += N % 10;
    N = N / 10;
    if (N == 0) break;
  }
  
  if (X % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
   
}

Measured memory_bytes: 3608
a, b = gets.chomp.split.map(&:to_i)

def f(n)
  if (n - 1) % 2 == 0
    result = (n / 2) % 2
  else
    result = ((n - 1) / 2) % 2 ^ n
  end
  return result
end

p f(a - 1) ^ f(b)


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


A = list(map(int, input().split()))

s=1

if 0 in A:
    print(0)
else:
    for i in range(N):
        if s > 10 ** (18):
            s=-1
            break
        s=s*A[i]

    if s > 10 ** (18):
        print(-1)
    else:
        print(s)

Measured memory_bytes: 21712
#define ll long long
#define pb push_back
#define make_pair mp
#define first f
#define second s
#define upper_bound ub
#define lower_bound lb
#define MOD 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

ll spf[1000006];
#define ordered_set tree<pair<ll,ll> , null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>ll fn
void sieve(){
    for(ll i=1;i<=1000000;i++){
        spf[i]=i;
    }
    for(ll i=2;i<=1000000;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<=1000000;i++){
        if(spf[i]==i){
            for(ll j=2*i;j<=1000000;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}
vector<ll> primefactors(ll n){
    vector<ll> primefactors;
    while(n!=1){
        if(primefactors.size()==0){primefactors.pb(spf[n]);}
        else if(primefactors.back()!=spf[n]){primefactors.pb(spf[n]);}
        n/=spf[n];
    }
    return primefactors;
}
void solve(){
  sieve();
  ll n;cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  bool freq[1000006];
  memset(freq,0,sizeof(freq));
  bool f=1;
  ll gcd=a[0];
  for(ll i=0;i<n;i++){
    if(i>0){
        gcd=__gcd(gcd,a[i]);
    }
    vector<ll> pf = primefactors(a[i]);
    for(ll j=0;j<pf.size()&&f==1;j++){
        if(freq[pf[j]]&&pf[j]!=1){
            f=0;
        }
        freq[pf[j]]=1;
    }
  }
  if(f){
    cout<<"pairwise coprime";
  }
  else if(gcd==1){
    cout<<"setwise coprime";
  }
  else{
    cout<<"not coprime";
  }
}

int main ()
{
  ios_base::sync_with_stdio (false);
  cin.tie (NULL);
  ll t;
  //cin>>t;
  t = 1;
  while (t)
    {
      solve();t--;
      //cout<<"end of test case"<<endl;
    }
  return 0;
}


Measured memory_bytes: 20196
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=2333;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
ll n;
int g[233];
void init(){
	g[1]=0;
	for(int i=2;i<=80;++i){
		for(int k=1;;++k){
			if((1LL<<k)-i>=g[k]){
				g[i]=k;break;
			}
		}
	}
}
const int table[6][23] = {
{},
{1,2},
{0,0,2},
{0,0,0,4,6},
{0,0,0,0,36,108,220,334,384},
{0,0,0,0,0,976,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf,inf}
};
int Get_g(ll n){
	if(n<=80)return g[n];
	for(int k=1;;++k){
		if((1LL<<k)-n>=g[k])return k;
	}
	return 114514;
}
int Solve(ll n,ll k){
	if(n<k)swap(n,k);
	if(k<63&&(1LL<<k)-n<n){
		return Solve((1LL<<k)-n,k);
	}
	if(!k)return 1;
	if(k<=5)return table[k][n];
	return inf;
}
int main(){
	init();
	n=read();
	int ans=Solve(n,Get_g(n))+(n==4)+(n==7)*2;
	printf("%d\n",ans>1000?-1:ans);
	return 0;
}



Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#include <vector>

using namespace std;

int main() {
	int n;

	cin >> n;

	vector<tuple<int, int, char, long long, string>> T;
	int v, w;
	long long d;
	char t;
	string s;
	
	for (int i = 0; i < n; i++) {
		cin >> v >> w >> t >> d >> s;
		T.emplace_back(v, w, t, d, s);
	}

	sort(T.begin(), T.end());

	for (int i = 0; i < n; i++) {
		cout << get<0>(T[i]) << " " << get<1>(T[i]) << " " << get<2>(T[i]) << " " << get<3>(T[i]) << " " << get<4>(T[i]) << endl;
	}
}




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

void solve() {
	ll n, x, m; cin >> n >> x >> m;
	int cycle = 0;
	x %= m;
	map<ll, int> mapp;
	vector<ll> temp;
	while (mapp[x] == 0) {
		cycle++;
		temp.push_back(x);
		mapp[x] = cycle;
		if (cycle == n) {cout << accumulate(temp.begin(), temp.end(), 0ll); return ;}
		x = x * x % m;
	}
	if (x == 0) {
		cout << accumulate(temp.begin(), temp.end(), 0ll);
		return ;
	}
//	for (auto u : temp)cout << u << ' '; cout << endl;
	n -= mapp[x] - 1;
	ll cur = n / (cycle - mapp[x] + 1);
	n %= (cycle - mapp[x] + 1);
	ll ans = 0;
	for (int i = 0; i < mapp[x] - 1; i++)ans += temp[i];
	ll wow = 0, all = 0;
	if (mapp[x] - 1 >= 0)for (int i = mapp[x] - 1 ; i <= cycle; i++) {
			if (i <= n + mapp[x] - 2)wow += temp[i];
			all += temp[i];
		}
	ans += all * cur;
	//for (auto u : temp)cout << u << ' '; cout << endl;
	//cout << mapp[x] - 2 + n  << endl;
	ans += wow;
	cout << ans;



}

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

}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool query(int x){
	printf("? %lld\n", x);
	fflush(stdout);
	char s[20]; scanf("%s", s);
	return s[0] == 'Y';
}
int pows(int x, int y) {
	int z = 1;
	while(y) {
		if(y & 1) z *= x;
		x *= x, y >>= 1;
	} return z;
}
signed main() {
	int len = 11;
	while(len and not query(pows(10, len - 1))) len--;
	if(len == 11) {
		len = 0;
		do len++; while(not query(pows(10, len) - 1));
		printf("! %lld\n", pows(10, len - 1));
	} else {
		int l = pows(10, len - 1) + 1, r = pows(10, len) - 1;
		while(l < r) {
			int m = (l + r) >> 1;
			if(query(m * 10)) r = m;
			else l = m + 1;
		}
		printf("! %lld\n", l);
	}
	return 0;
}

Measured memory_bytes: 596
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
#include<bits/stdc++.h>
using namespace std;
int n;
double a;
priority_queue<double,vector<double>,greater<double> > q;
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>a;
		q.push(a);
	}
	while(q.size()!=1)
	{
		double x=q.top();
		q.pop();
		double y=q.top();
		q.pop();
		q.push(1.0*(x+y)/2); 
	}
	printf("%.5f\n",q.top());
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        String str = "" + A;
        int N = str.length();
        for (int i = 0; i < N /2; i++) {
            if (str.charAt(i) != str.charAt(N - i - 1)) {
                System.out.println("No");
                return ;
            }
        }
        System.out.println("Yes");
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 21076
#include<stdio.h>
int main(void)
{
	int a,b,i,s;
	for(i=0;i<4;i++){
		scanf("%d %d",&a,&b);
		if(a==1){
			s=b*6000;
		}
		if(a==2){
			s=b*4000;
		}
		if(a==3){
			s=b*3000;
		}
		if(a==4){
			s=b*2000;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int all_sum(int a, int b){
    int sum = 0;
    for(int i = a; i <= b; i++){
        sum += i;
    }
    return sum;
}

int main(){
    string s;
    cin >> s;
    int n = s.size()+1;
    ll sum = 0;
    vector<int> a(n);
    for(int i = 0; i < n-1; i++){
        if(s[i] == '<') chmax(a[i+1], a[i]+1);
    }
    for(int i = s.size()-1; i >= 0; i--){
        if(s[i] == '>'){
            chmax(a[i], a[i+1]+1);
        }
    }
    for(int i = 0; i < n; i++) sum += a[i];
    cout << sum << endl;
    return 0;
}


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


void solve(long long A, long long B, long long C, long long D){
    if (A + B > C + D)
        cout << "Left" << '\n';
    else if (A + B < C + D)
        cout << "Right" << '\n';
    else
        cout << "Balanced" << '\n';
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	vector<long long> cnt(5, 0);
	REP(i,N){
		string s; cin >> s;
		if(s[0] == 'M') cnt[0]++;
		else if(s[0] == 'A') cnt[1]++;
		else if(s[0] == 'R') cnt[2]++;
		else if(s[0] == 'C') cnt[3]++;
		else if(s[0] == 'H') cnt[4]++;
	}

	int P[10] = {0,0,0,0,0,0,1,1,1,2};
	int Q[10] = {1,1,1,2,2,3,2,2,3,3};
	int R[10] = {2,3,4,3,4,4,3,4,4,4};

	long long int ans = 0;
	REP(i,10){
		ans += cnt[P[i]]*cnt[Q[i]]*cnt[R[i]];
	}

	cout << ans << endl;

	return 0;

}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
    int n, m = (int)1e6, cnt = 0, t;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &t);
        if(m > t)cnt++;
        m = min(m, t);
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 * TITLE : Beginner
 * URL : https://atcoder.jp/contests/abc156/tasks/abc156_a
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        int answer = N >= 10 ? R : R + 100 * (10 - N);
        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 22996
public class Main {
	public static void main(String[] args) {
		java.util.Scanner in = new java.util.Scanner(System.in);
		
		String[] str = new String[5];
		int[] prs = new int[5];
		for (int i=0; i<5; i++) {
			str[i] = in.next();
			prs[i] = java.lang.Integer.parseInt(str[i]);
		}
		int tmp1 = 2000, tmp2 = 2000;
		for (int i=0; i<5; i++) {
			if(i<3) {
				if (prs[i] <tmp1)
					tmp1 = prs[i];
			}
			else if(i<5) {
				if (prs[i] < tmp2)
					tmp2 = prs[i];
			}
		}
		System.out.println(tmp1+tmp2-50);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N, X;
    cin >> N >> X;
    int ans = 1;
    int sum = 0;
    REP(i,N){
        int l;
        cin >> l;
        sum += l;
        if (sum <= X){
            ans++;
        }
        else{
            break;
        }
    }

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


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

using namespace std;
typedef long long ll;

int main(){
	ll N;
	cin >> N;
	for(ll k=N;k>=1;k--)
		if((k-1)*k/2<N){
			N-=k;
			cout << k << endl;
		}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int cnt=0;
  char s[10],t[10];
  scanf("%s",s);
  scanf("%s",t);
  if(s[0]==t[0])
    cnt++;
  if(s[1]==t[1])
    cnt++;
  if(s[2]==t[2])
    cnt++;
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	REP(i, n){
		ll a, b, c;cin >> a >> b >> c;
		if(a * a + b * b == c * c){cout << "YES" << endl;continue;}
		if(a * a + c * c == b * b){cout << "YES" << endl;continue;}
		if(c * c + b * b == a * a){cout << "YES" << endl;continue;}
		cout << "NO" << endl;
	}

	return 0;
}



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

using namespace std;

int main() {

  int n;
  string str;

  cin >> n;
  getline(cin,str);

  for(int i=0;i<n;i++) {

    getline(cin,str);

    while(str.find("Hoshino")!=string::npos) {

      str.replace(str.find("Hoshino"),7,"Hoshina");

    }

    cout << str << endl;

  }

  return 0;

}

Measured memory_bytes: 0
N,M = map(int,input().split())

d = {i:[False,0] for i in range(1,N+1)}

wa = 0
clear = 0

for i in range(M):
  input_ = input().split()
  p = int(input_[0])
  S = input_[1]
  
  if S == "WA":
    if not d[p][0]:
      # もしWAで、未正解なら不正解カウントを増やす
      d[p][1] += 1
    else:
      # もし既に正解しているのにWAなら、無視する
      pass
  elif S == "AC":
    if not d[p][0]:
      # もしACで、未正解なら正解カウントを増やして正解判定にする
      clear += 1
      d[p][0] = True
    else:
      # もし既に正解していて、またACなら、無視する
      pass
    
for i in d:
  tmp = d[i]
  
  if tmp[0]:
    # もしACしていたら、その不正解カウントをペナルティとして加算
    wa += tmp[1]

print(clear,wa)
  

Measured memory_bytes: 23204
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
 
signed main(){

    int n;
    cin >> n;
    int d[3][100010];
    cin >> d[0][0] >> d[1][0] >> d[2][0];
    for(int i = 1;i <= n-1;i++){
        int a,b,c;
        cin >> a >> b >> c;
        d[0][i] = max(d[1][i-1],d[2][i-1]) + a;
        d[1][i] = max(d[2][i-1],d[0][i-1]) + b;
        d[2][i] = max(d[0][i-1],d[1][i-1]) + c;
    }

    cout << max({d[0][n-1],d[1][n-1],d[2][n-1]}) << endl;
    

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://dp.contest.atcoder.jp/tasks/dp_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Ma, Mb;
ll A[45], B[45], C[45];
ll DP[45][405][405];

int main(){
  cin >> N >> Ma >> Mb;
  for (int i = 1; i <= N; i++){
    cin >> A[i] >> B[i] >> C[i];
  }

  fill((ll*)DP, (ll*)(DP + N + 1), 1e18);
  DP[0][0][0] = 0;

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= 400; j++){
      for (int k = 0; k <= 400; k++){
        DP[i][j][k] = DP[i-1][j][k];
      }
    }

    for (int j = 0; j <= 400; j++){
      for (int k = 0; k <= 400; k++){
        if (DP[i-1][j][k] == 1e18) continue;
        DP[i][j+A[i]][k+B[i]] = min(DP[i-1][j][k] + C[i], DP[i][j+A[i]][k+B[i]]);
      }
    }
  }

  ll ans = 1e18;
  for (int i = 1; i <= 400; i++){
    int a = Ma * i, b = Mb * i;
    if (a > 400 || b > 400) break;
    ans = min(ans, DP[N][a][b]);
  }
  if (ans == 1e18) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 56176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int n; cin >> n;
	int fib[50];
	fib[0] = 1; fib[1] = 1;
	FOR(i, 2, n + 1)
	{
		fib[i] = fib[i - 1] + fib[i-2];
	}
	cout << fib[n] << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
#define Yes "Yay!"
#define No ":("
signed main() {
	int h, w, k; cin >> h >> w >> k;
	V<string> s(h);
	rep(i, h) { cin >> s[i]; }
	veb is_st(h);
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') { is_st[i] = true; }
		}
	}
	int now_st = 1;
	vvel ans(h, vel(w,0));
	vel all_h;
	rep(i, h) {
		all_h.push_back(i);
		if(is_st[i]) {
			vel all_w;
			rep(j, w) {
				all_w.push_back(j);
				if(s[i][j]=='#') {
					for (auto x : all_h) {
						for (auto y : all_w) {
							ans[x][y] = now_st;
						}
					}
					now_st++;
					all_w = {};
				}
			}
			all_h = {};
		}
	}
	rep(i, h) {
		rep(j, w-1) {
			mmax(ans[i][j + 1], ans[i][j]);
		}
	}
	rep(i, h-1) {
		rep(j, w) {
			mmax(ans[i+1][j], ans[i][j]);
		}
	}
	rep(i, h) {
		rep(j, w - 1) { cout << ans[i][j] << " "; }
		cout << ans[i][w - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 2816
#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>

using namespace std;
#define N 4
#define NN N*N

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
int H[NN][NN];
int state_count;

struct Puzzle
{
  int field[NN],space,MD;
  int cost;

    bool operator < (const Puzzle& p) const {
    for(int i=0; i<NN; i++) {
        if( field[i] == p.field[i] ) continue;
        return field[i] < p.field[i];
    }
    return false;
    }
};

struct State
{
  Puzzle puzzle;
  int f_value;
  bool operator < (const State &s) const{
    return f_value > s.f_value;
  }
};

int getTotalMD(Puzzle pz){
    int sum=0;
    for(int i=0; i<NN; i++) {
    if( pz.field[i] == NN ) continue;
    sum += H[i][pz.field[i]-1];
    }
    return sum;
}

bool isSolved(Puzzle pz){
  int i;
  for (int i = 0; i < NN; ++i)if(pz.field[i] != i+1)return false;
  return true;
}

int astar(Puzzle pz){
  priority_queue<State> q;
  pz.MD = getTotalMD(pz);
  pz.cost = 0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = pz;
  initial.f_value= getTotalMD(pz);
  q.push(initial);

  while(!q.empty()){
    State st = q.top(); q.pop();state_count++;
    u = st.puzzle;
    if( isSolved(u) ) return u.cost;
    V[u] = true;

    int sx = u.space / N;
    int sy = u.space % N;

    for(int r=0; r<4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if( tx<0 || ty<0 || tx>=N || ty>=N ) continue;
        v = u;

        v.MD -= H[tx*N+ty][v.field[tx*N+ty]-1];
        v.MD += H[sx*N+sy][v.field[tx*N+ty]-1];

        swap(v.field[sx*N+sy], v.field[tx*N+ty]);
        v.space = tx*N+ty;
        if( !V[v] ) {
        v.cost++;
        State news;
        news.puzzle = v;
        news.f_value = v.cost + v.MD;
        q.push(news);
        }
    }
    }
    return -1;
}

int main(){
for(int i = 0; i<NN; i++)
  for(int j =0;j < NN;j++)
    H[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for(int i=0;i<NN;i++){
    cin >> in.field[i];
    if(in.field[i] == 0){
      in.field[i] = NN;
      in.space = i;
    }
  }

  cout << astar(in) << endl;
  //cout <<"state_count="<<state_count<<endl;
  return 0;
}


Measured memory_bytes: 257616
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  int s,d,f,c,w;
  c = 0;
  f= 1;
  cin >> s;
  w = s;
  while(s){
    cin >> d;
    a.push_back(d);
    s--;
  }
 
  while(1){
    f = a.at(f-1);
    if(f == 2){
      cout << c+1 << endl;
      break;
    }
    
    if(c >= w){
      cout << -1 << endl;
      break;
    }
    c++;
  }
}
  

Measured memory_bytes: 892
H, W = map(int, input().split())

s_list = []
for i in range(H):
    s_list.append(input())
    
out_list = []

eight_dir = ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))

for i in range(H):
    cur_str = ''
    for j in range(W):
        if s_list[i][j] == '#':
            cur_str += "#"
        else:
            count = 0
            for k in range(8):
                search_x = j + eight_dir[k][1]
                search_y = i + eight_dir[k][0]
                if 0 <= search_x < W and 0 <= search_y < H:
                    if s_list[search_y][search_x] == '#':
                        count += 1
            cur_str += str(count)
#     out_list.append(cur_str)
    print(cur_str)
                
    

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

long int g(long int x);

int main(void)
{
  long int n;
  scanf("%ld", &n);

  long int ans=0;
  long int x;
  for(int i=1;i<=n;i++){
    x = n/i;
    ans += i*g(x);
  }

  printf("%ld\n", ans);

  return 0;
}

long int g(long int x)
{
  return x*(x+1)/2;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	int lmax = 0;
	int rmin = 100001;
	for (int i = 0; i < M; i++) {
		int L, R;
		cin >> L >> R;
		lmax = max(lmax, L);
		rmin = min(rmin, R);
	}
	cout << max(0, rmin - lmax + 1) << endl;
}

Measured memory_bytes: 256
<?php
list($numOfPerson, $numOfFood) = explode(' ', trim(fgets(STDIN)));

$allFood = [];
for ($i = 1; $i <= $numOfFood; $i++) {
	$allFood[] = $i;
}

$result = $allFood;
for ($i = 0; $i < $numOfPerson; $i++) {
    $favoriteFood = explode(' ', trim(fgets(STDIN)));
    array_shift($favoriteFood);
    $result = array_intersect($result, $favoriteFood);
}

echo count($result), PHP_EOL;

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

using namespace std;

int const N = 2e5 + 100;
int n, a[N], vis[N], c[N], mx = 0;

int main(){
    scanf("%d", &n);
    for(int i = 0;i < n;++i) scanf("%d", &a[i]);
    
    for(int i = 0;i < n;++i){
        vis[a[i]] = 1;
        if(vis[a[i] - 1] == 1) c[a[i]] = c[a[i] - 1] + 1;
        mx = max(c[a[i]], mx);
    }
    
    cout << n - mx - 1 << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main()
{
char c;
cin>>c;
switch(c)
{
case('a'):
    cout<<"vowel";
    break;
case('e'):
    cout<<"vowel";
    break;
case('i'):
    cout<<"vowel";
    break;
case('o'):
    cout<<"vowel";
    break;
case('u'):
    cout<<"vowel";
    break;
default:
    cout<<"consonant";
}

    return 0;
}


Measured memory_bytes: 256
package main

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

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

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

func main() {
	s := strings.Split(readLine(), "")

	a := s[0]

	var sei []string

	if a == "0" {
		sei = append(sei, "0")
		for i := 1; i < len(s); i++ {
			if sei[i-1] == "0" {
				sei = append(sei, "1")
			} else {
				sei = append(sei, "0")
			}
		}
	} else {
		sei = append(sei, "1")
		for i := 1; i < len(s); i++ {
			if sei[i-1] == "0" {
				sei = append(sei, "1")
			} else {
				sei = append(sei, "0")
			}
		}
	}

	var count int

	for i := 0; i < len(s); i++ {
		if s[i] != sei[i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double

#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const ll mod =1e9+7;
const ll maxn=1e5+10;

int main()
{ 
 
   IOS
  
  ll n;
  string s;
  cin>>n>>s;
  if(n%2==0)
  {
    if(s.substr(0,n/2)==s.substr(n/2,n/2))
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int k, a, b;
	cin >> k >> a >> b;
	
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

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

int main()
{
    int ss;
    cin >> ss;
    int a1 = ss / 1000;
    ss = ss % 1000;
    int a2 = ss / 100;
    ss = ss % 100;
    int a3 = ss / 10;
    int a4 = ss % 10;
    if ((a2 ==a3) && (a1 == a2 || a3 == a4)) {
            cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    s = input()
    count = 0
    new_left = 0
    new_right = 0

    # See:
    # https://www.youtube.com/watch?v=5FOTOiV5p0U
    for si in s:
        if si == '(':
            count += 1
        else:
            count -= 1

            if count == -1:
                count = 0
                new_left += 1

    new_right = count

    print('(' * new_left + s + ')' * new_right)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr long long int mod = 1e9 + 7;

//素数判定。計算量はO(log √n)。
bool IsPrime(Int n) {

	if (n < 2)return false;
	else if (n == 2)return true;
	else if (n % 2 == 0)return false;

	for (Int i = 3; i * i <= n; ++i) {
		if (n % i == 0)return false;
	}

	return true;

}

int main() {

	Int X; cin >> X;
	
	Int num = X;

	while (!IsPrime(num)) {
		num++;
	}

	cout << num << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

LL X,Y,A,B,C,p[100001],q[100001],r[100001],ans=0ll;

int main() {
	cin>>X>>Y>>A>>B>>C;
	for(int i=0;i<A;i++)cin>>p[i];
	for(int i=0;i<B;i++)cin>>q[i];
	for(int i=0;i<C;i++)cin>>r[i];
	sort(p,p+A);
	sort(q,q+B);
	sort(r,r+C);
	reverse(p,p+A);
	reverse(q,q+B);
	reverse(r,r+C);
	for(int i=0;i<X;i++)ans+=p[i];
	for(int i=0;i<Y;i++)ans+=q[i];
	int np=X-1,nq=Y-1;
	for(int i=0;i<C;i++){
		if(np<0&&nq<0)break;
		if(np<0&&q[nq]<r[i]){
			ans+=r[i]-q[nq];
			nq--;
		}
		else if(nq<0&&p[np]<r[i]){
			ans+=r[i]-p[np];
			np--;
		}
		else if(np>=0&&nq>=0){
			if(p[np]>=q[nq] && q[nq]<r[i]){
				ans+=r[i]-q[nq];
				nq--;
			}
			else if(p[np]<r[i]){
				ans+=r[i]-p[np];
				np--;
			}
		}
		else break;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <algorithm>

struct info
{
  long long x;
  long long y;
  long long h;
};

int main()
{
  int n;
  scanf("%d", &n);
  info a[100];
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].h);
  }
  
  for (int y = 0; y <= 100; ++y)
  {
    for (int x = 0; x <= 100; ++x)
    {
      long long H = 0;
      for (int i = 0; i < n; ++i)
      {
        if (a[i].h != 0)
        {
          H = a[i].h + std::abs(a[i].x - x) + std::abs(a[i].y - y);
          break;
        }
      }
      bool ans = true;
      for (int i = 0; i < n; ++i)
      {
        if (a[i].h != std::max(H - std::abs(a[i].x - x) - std::abs(a[i].y - y), 0LL))
        {
          ans = false;
          break;
        }
      }
      if (ans)
      {
        printf("%lld %lld %lld\n", x, y, H);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
    typedef pair <int, int> ii;
     
    const int Maxn = 100005;
    const int mod = 998244353;
     
    int n;
    int diag[Maxn], dif[Maxn];
    map <ii, int> M;
    int dp[Maxn][2];
     
    int main()
    {
        fill(diag, diag + Maxn, -1);
        fill(dif, dif + Maxn, -1);
        scanf("%d", &n);
        int m; scanf("%d", &m);
        for (int i = 0; i < m; i++) {
            int r, c, val; scanf("%d %d %d", &r, &c, &val);
            if (r == c)
                if (diag[r] != -1 && diag[r] != val) {
                    printf("0\n"); return 0;
                } else diag[r] = val;
            else {
                if (r < c) swap(r, c);
                map <ii, int>::iterator it = M.find(ii(r, c));
                int oldval = it == M.end()? -1: it->second;
                int st = r - c;
                if (st == 1)
                    if (oldval == -1) M[ii(r, c)] = val;
                    else {
                        int wr = oldval != val;
                        if (dif[r] != -1 && dif[r] != wr) {
                            printf("0\n"); return 0;
                        } else dif[r] = wr;
                    }
                else if (st == 2)
                    if (oldval == -1) M[ii(r, c)] = val;
                    else {
                        int wr = oldval != val;
                        if (diag[r - 1] != -1 && diag[r - 1] != wr) {
                            printf("0\n"); return 0;
                        } else diag[r - 1] = wr;
                    }
                else if (oldval == -1) M[ii(r, c)] = val;
                     else if (oldval != val) {
                        printf("0\n"); return 0;
                     }
            }
        }
        dp[1][0] = 1;
        for (int i = 1; i <= n; i++)
            for (int j = 0; j < 2; j++) if (dp[i][j])
                for (int k = 0; k < 2; k++) {
                    if (diag[i] != -1 && diag[i] != k) continue;
                    if (dif[i] != -1 && dif[i] != (j != k)) continue;
                    dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % mod;
                }
        int res = (dp[n + 1][0] + dp[n + 1][1]) % mod;
        ll rem = (ll(n) * n - n) / 2 - int(M.size());
        int a = 2;
        while (rem) {
            if (rem & 1) res = ll(res) * a % mod;
            rem >>= 1ll; a = ll(a) * a % mod;
        }
        cout << res << endl;
        return 0;
    }

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
using namespace std;

inline int num (const std::string& S, int idx){ return S.at(idx) - '0'; }
inline unsigned int bitMask(int i){ return (1 << i); }
inline bool isTrue(unsigned int bit, int i){ return bit & bitMask(i); }

void set(int hit, int A[9], bool OK[9]){
	for(int i=0; i<9; ++i){
		if(hit == A[i]){
			OK[i] = true;
		}
	}
}

bool bingo(bool OK[9]){
	if(OK[0] && OK[1] && OK[2]) return true;
	if(OK[3] && OK[4] && OK[5]) return true;
	if(OK[6] && OK[7] && OK[8]) return true;
	if(OK[0] && OK[3] && OK[6]) return true;
	if(OK[1] && OK[4] && OK[7]) return true;
	if(OK[2] && OK[5] && OK[8]) return true;
	if(OK[0] && OK[4] && OK[8]) return true;
	if(OK[2] && OK[4] && OK[6]) return true;
	return false;
}

int main(){
	int A[9];
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4] >> A[5] >> A[6] >> A[7] >> A[8];
	int N;
	cin >> N;
	bool OK[9] = {false};
	for(int i=0; i<N; ++i){
		int hit;
		cin >> hit;
		set(hit, A, OK);
		if(bingo(OK)){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int n, count=0;
    cin>>n;
    for(int i=105; i<=n; i+=2){
        int y=0;
        for(int j=1; j<=(int)sqrt(i); j++){
            //cout<<i<<" "<<j<<endl;
            if(i%j==0)
                y++;
        }
        if(y==4)
            count++;
    }
    
    cout<<count<<endl;
    return 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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#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++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a,b,c,n,k;
    string s, t;
    ll ans;
    double dans;
    string sans;


    cin  >> s;

    if(s == "Sunny") sans = "Cloudy";
    else if(s == "Cloudy") sans = "Rainy";
    else if(s == "Rainy" ) sans = "Sunny";

    // std::cout << ans << endl; 
    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	int n=read();
	vi a;
	REP(i,n*2-1){
		a.PB(read()-1);
	}
	int lb=0,ub=2*n-1;
	vector<bool> gr(2*n-1);
	while((ub-lb)>1){
		const int mid=(ub+lb)/2;
		REP(i,2*n-1)
			gr[i]=a[i]>=mid;
		pii k=MP(1145141919,-1);
		for(int d=1;n-1-d>=0;d++)
			if(gr[n-1-d]==gr[n-1-d+1])
				chmin(k,MP(d,(int)gr[n-1-d]));
		for(int d=1;n-1+d<2*n-1;d++)
			if(gr[n-1+d-1]==gr[n-1+d])
				chmin(k,MP(d,(int)gr[n-1+d]));
		if(k.second!=-1){
			if(k.second)
				lb=mid;
			else
				ub=mid;
		}else{
			if(n%2==0){
				if(!gr[n-1])
					lb=mid;
				else
					ub=mid;
			}else{
				if(gr[n-1])
					lb=mid;
				else
					ub=mid;
			}
		}
	}
	cout<<lb+1<<endl;
}


Measured memory_bytes: 1528
int main(){
int a,b,c,d;
scanf("%d %d\n",&a,&b);
while (!(a==0 && b==0)) {
if (a>b) {c=b; d=a;}
else {c=a; d=b;}
printf("%d %d\n",c,d);
scanf("%d %d\n",&a,&b);
}
return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	pair<ll,ll> arr[n];
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		arr[i]={x,y};
	}
	ll ans=max((ll)1,n-1);
	sort(arr,arr+n);
	
	for(ll i=0;i<n;i++)
	{
		
		for(ll j=i+1;j<n;j++)
		{
			map<pair<ll,ll>,ll>mp;
			ll cost=j;
			ll p=arr[j].f-arr[i].f,q=arr[j].s-arr[i].s;
			for(ll k=0;k<=j;k++)
			mp[{arr[k].f+p,arr[k].s+q}]=1;
			for(ll k=j+1;k<n;k++)
			{
				if(mp[{arr[k].f,arr[k].s}])
				cost--;
				mp[{arr[k].f+p,arr[k].s+q}]=1;
				cost++;
			}
		
		ans=min(ans,cost);
	}}
	cout<<ans;
}

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

bool chmax( ll &a, ll b){ 
  if( a < b){ a = b; return 1;} return 0;}

ll dp[100][2];

int main(){
ll N,K; cin >> N >> K;
  vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  for(ll i = 0; i < 100; i++){ dp[i][0] = -1; dp[i][1] = -1;} 
  // -1 means dp[i][j] has not been updated
  
  dp[45][1] = 0;
  // j == 0 means the X is less than K while j == 1 means the X is no more than K
  
  for(int d = 44; d >= 0; d--){
    ll num = 0; ll mask = 1LL << d;
    for(ll i = 0; i < N; i++){ if( A[i] & mask){ num++;}}
    // num counts how many  A[i]'s d-th digits are 1
    
    if( dp[d+1][0] >= 0){ // in the case dp[d+1][0] ( X < K)  exists
      chmax( dp[d][0], dp[d+1][0] + mask * max( num , N - num));}
    if( dp[d+1][1] >= 0){ // in the case dp[d+1][1] ( X == K) exists
      if( K & mask){ // in the case X's d-th disits is 1
        chmax( dp[d][1] , dp[d+1][1] + mask * ( N - num));
        chmax( dp[d][0] , dp[d+1][1] + mask * num);}
      else{// in the case X's d-th digits is 0
        chmax( dp[d][1] , dp[d+1][1] + mask * num);} 
    }
  }
  
  cout << max( dp[0][0], dp[0][1] ) << endl; return 0;}
              

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll L,a[100001];
	vint ans;
	int lasti;
	scan(N>>L);
	rep(i,N){
		scan(a[i]);
	}
	int flag=0;
	rep(i,N-1){
		if(a[i]+a[i+1]>=L){
			flag=1;
			lasti=i;
			ans.push_back(lasti);
		}
	}
	if(flag){
		prin("Possible");
		for(int i=lasti-1;i>=0;i--) ans.push_back(i);
		for(int i=lasti+1;i<N-1;i++) ans.push_back(i);
		rep(i,N-1){
			prin(ans.back()+1);
			ans.pop_back();
		}
	}
	else{
		prin("Impossible");
	}
	return 0;
}


Measured memory_bytes: 2548
#import"bits/stdc++.h"
main(){long n,a,b,c,d,m;std::cin>>n>>a>>b;for(n;n>1;n--){std::cin>>c>>d;m=std::max((a-1)/c+1,(b-1)/d+1);a=c*m;b=d*m;}std::cout<<a+b;}

Measured memory_bytes: 256