akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int a[5];
  for(int i=0;i<5;i++){
    a[i]=0;
  }
  for(int i=0;i<3;i++){
    int x,b;
    cin>>x>>b;
    a[x]++;
    a[b]++;
  }
  bool ok=true;
  for(int i=0;i<5;i++){
    if(a[i]>2){
      ok=false;

    }
  }
  if(ok){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }


  


}


  

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str1, str2, str;
    int n;
    cin>>n;
    cin>>str1;
    cin>>str2;
    for(int i = 0; i < n; i++)
    {
        cout<<str1[i]<<str2[i];
    }
    return 0;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int H = sc.nextInt();
		int W = sc.nextInt();

		int num = 0;

		for(int i = 0; i < H; i++) {
			String A = sc.next();
			for(int j = 0; j < W; j++) {
				char t = A.charAt(j);
				if(t == '#') {
					num++;
				}
			}
		}
		sc.close();
		//設定完了

		String answer = "Impossible";
		if(num == H+W-1) {
			answer = "Possible";
		}
		System.out.println(answer);

	}

}


Measured memory_bytes: 27036
#-*- coding:utf-8 -*-
import math
import sys
a = list(map(int,input().split()))

s = 0
if a[1] < 10:
    s = 10*a[0]+a[1]
elif a[1] < 100:
	s = 100*a[0]+a[1]
else: s = 1000*a[0]+a[1]

n = math.floor(math.sqrt(s))

for i in range(n):
	if (i+1)**2 == s:
		print("Yes")
		sys.exit()
print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll  fac[500009];
ll inv[500009];
ll mod=1e9+7;
ll nCr(int n, int r)
{
    return ((fac[n]*inv[r])%mod*inv[n-r])%mod;
}
int main()
{   int n,m;
    cin>>n>>m;
    fac[0]=1;
    for(int i=1;i<=m;i++)  fac[i]=(fac[i-1]*i)%mod;
    inv[0]=1;
    inv[1]=1;
    for(int i = 2; i <=m; ++i)
    inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
    for(int i=2;i<=m;i++) inv[i]=(inv[i]*inv[i-1])%mod;
    ll ans=(nCr(m,n)*fac[n])%mod;
    ll add=0;
    ll p=1;
    for(int i=0;i<=n;i++)
    {
        add=(add+((nCr(n,i))*(p*(nCr(m-i,n-i)*fac[n-i])%mod)%mod)%mod+mod)%mod;
        p=-1*p;
    }
    ans=((ans*add)%mod+mod)%mod;
    cout<<ans;
}


Measured memory_bytes: 11372
#include <bits/stdc++.h>
using namespace std;
int N, Q; 
vector<int> E[200010]; 
long long int add[200010]; 
long long int ans[200010]; 
void dfs(int now, int parent){
	ans[now] = ans[parent] + add[now]; 
	for(auto i : E[now]){
		if(i == parent) continue; 
		dfs(i, now); 
	}
}
int main(){
	cin >> N >> Q; 
	for(int i = 0; i < N-1; i++){
		int a, b; cin >> a >> b; 
		a--; b--;
 		E[a].push_back(b); 
		E[b].push_back(a); 
	}
	for(int q = 0; q < Q; q++){
		int a; long long int x; cin >> a >> x; 
		a--; 
		add[a] += x; 
	}
	dfs(0, -1); 
	for(int i = 0; i < N; i++) cout << ans[i] << " "; 
  cout << endl; 
}

Measured memory_bytes: 25600
while 1:
 
  x = raw_input().split()
  a = int(x[0])
  op = x[1]
  b = int(x[2])
 
  if op == '+':
    print a+b
  elif op == '-':
    print a-b
  elif op == '*':
    print a*b
  elif op == '/':
    print a/b
  elif op == '?':
    break

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> p(a), q(b), r(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.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    //for(int i=0;i<a;i++)
      //  cout<<p[i]<<" ";
    //cout<<endl;
    vector<int> d;
    for (int i = 0; i < x; ++i) d.push_back(p[i]);
    for (int i = 0; i < y; ++i) d.push_back(q[i]);
    for (int i = 0; i < c; ++i) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    for (int j = 0; j < x + y; ++j) ans += d[j];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4596
#include<iostream>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n)cin>>c[0][i];R(i,n)cin>>c[1][i];fill(p[1],p[1<<n],1e9);;R(B,1<<n){int o=0,d[n];R(i,n)if(!(B&1<<i))d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1)p[B|1<<i][k]=min(p[B|1<<i][k],p[B][j]+d[i]);}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

Measured memory_bytes: 52608
function Main(input) {
    var input = input.split('\n');
    var n = parseInt(input[0], 10);
    var k = parseInt(input[1], 10);
    var xn = input[2].split(' ').map(n => parseInt(n, 10));
    var robob = xn.map(n => 2 * (k -n));
    var roboa = xn.map(n => 2 * n);
    var sum = 0;
    for(i = 0; i < n; i++) {
        if(roboa[i] <= robob[i]) {
            sum += roboa[i];
        } else {
            sum += robob[i];
        }
    }
    console.log(sum);

    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7624
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;

	vector<ll> X(N),cop(N);
	rep(i,N){
		cin >> X[i];
		cop[i] = X[i];
	}

	sort(cop.begin(),cop.end());
	ll l = N/2 - 1;
	ll lx = cop[l];

	rep(i,N){
		if(X[i]<=lx){
			cout << cop[l+1] << endl;
		}
		else{
			cout << cop[l] << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 5376
n,k = [int(x) for x in input().strip().split()]
H = [int(x) for x in input().strip().split()]

dp = [0]+[10**9 + 7] * (n-1)
for i in range(n):
    for j in range(i+1,min(n,i+k+1)):
        dp[j] = min (dp[j], dp[i] + abs(H[i] - H[j]))
print (dp[-1])

Measured memory_bytes: 52452
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    Int a, b;
    cin >> a >> b;
    if((a+b)%2 != 0){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a+b)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int s, w; cin >> s >> w;
    if (w >= s)
        cout << "unsafe\n";
    else
        cout << "safe\n";

}


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

int main() {
	string s;
	cin >> s;

	int count[26] = {};
	for (int i = 0; i < s.length(); i++) {
		count[s.at(i)-'a']++;
	}
	string ans = "None";
	char w;
	for (int i = 0; i < 26; i++) {
		if (count[i] == 0) {
			w = i+'a';
			ans = w;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int K,S,A;
  cin >> K >> S;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0 && S-i-j<=K){
        A++;
      }
    }
  }
  cout << A << endl;
}
        
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

bool OneCharStr(string S){
    char c=S.front();
    string _S(S.size(),c);
    if(S==_S) return true;
    else return false;
}

int main(){
    string S; cin>>S;

    int ans=INT_MAX;
    for(char c='a';c<='z';c++){
        int _ans=0;
        string _S=S;

        while(!OneCharStr(_S)){
            _ans++;
            rep(i,0,_S.size()){
                if(_S.at(i)==c && i!=0) _S.at(i-1)=c;
            }
            _S.erase(_S.size()-1);
        }

        ans=min(ans,_ans);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n,m;
	cin>>n>>m;
	int p[m],y[m];
	int yans[m];
	vector< pair<int,int> > t[n+1];
	int count[n+1]={};
	REP(i,m){
		cin>>p[i]>>y[i];
		count[p[i]]++;
		t[p[i]].push_back(make_pair(y[i],i));
	}
	for(int i=1;i<=n;i++){
		sort(t[i].begin(),t[i].end());
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<t[i].size();j++){
			yans[t[i][j].second]=j+1;
		}
	}
	for(int i=0;i<m;i++){
		printf("%06d",p[i]);
		printf("%06d\n",yans[i]);
	}
	return 0;
}
		

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

using namespace std;

long long prime = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << (a + b) << endl;
    }
    return 0;
}


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

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

    vector<int> v;
    while (!b.empty()) {
        for (int i = b.size() - 1; i >= 0; i--) {
            if (b[i] == i) {
                v.push_back(i + 1);
                b.erase(b.begin() + i);
                break;
            }
            if (i == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    
    for (int i = N - 1; i >= 0; i--) {
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<tuple>
using namespace std;
int x[11][3], y[11][3], b[11];
int n, m; string S[10], T[10];
void init() {
	for (int i = 0; i < 33; i++) { x[i / 3][i % 3] = 0; y[i / 3][i % 3] = 0; b[i / 3] = 0; }
	for (int i = 0; i < n; i++) {
		x[i + 1][0] = x[i][0]; x[i + 1][1] = x[i][1]; x[i + 1][2] = x[i][2]; bool Ind = true;
		for (int j = 0; j < S[i].size(); j++) {
			if (S[i][j] != '.')Ind = false; if (Ind == true)b[i] = j + 1;
			if (S[i][j] == '(')x[i + 1][0]++; if (S[i][j] == ')')x[i + 1][0]--;
			if (S[i][j] == '{')x[i + 1][1]++; if (S[i][j] == '}')x[i + 1][1]--;
			if (S[i][j] == '[')x[i + 1][2]++; if (S[i][j] == ']')x[i + 1][2]--;
		}
	}
	for (int i = 0; i < m; i++) {
		y[i + 1][0] = y[i][0]; y[i + 1][1] = y[i][1]; y[i + 1][2] = y[i][2];
		for (int j = 0; j < T[i].size(); j++) {
			if (T[i][j] == '(')y[i + 1][0]++; if (T[i][j] == ')')y[i + 1][0]--;
			if (T[i][j] == '{')y[i + 1][1]++; if (T[i][j] == '}')y[i + 1][1]--;
			if (T[i][j] == '[')y[i + 1][2]++; if (T[i][j] == ']')y[i + 1][2]--;
		}
	}
}
vector<tuple<int,int,int>> search() {
	vector<tuple<int, int, int>>vec;
	for (int i = 1; i <= 20; i++) {
		for (int j = 1; j <= 20; j++) {
			for (int k = 1; k <= 20; k++) {
				bool OK = true;
				for (int l = 0; l < n; l++) {
					if ((x[l][0] * i + x[l][1] * j + x[l][2] * k) != b[l])OK = false;
				}
				if (OK == true)vec.push_back(make_tuple(i, j, k));
			}
		}
	}
	return vec;
}
int main() {
	while (true) {
		cin >> n >> m; if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++)cin >> S[i];
		for (int i = 0; i < m; i++)cin >> T[i];
		vector<int>res[10]; init(); search();
		vector<tuple<int, int, int>>F = search();
		for (int i = 0; i < F.size(); i++) {
			int a1 = get<0>(F[i]), a2 = get<1>(F[i]), a3 = get<2>(F[i]);
			for (int j = 0; j < m; j++) {
				int TT = y[j][0] * a1 + y[j][1] * a2 + y[j][2] * a3;
				for (int k = 0; k < res[j].size(); k++) {
					if (res[j][k] == TT)goto E;
				}
				res[j].push_back(TT); E:;
			}
		}
		for (int i = 0; i < m; i++) {
			if (i)cout << ' ';
			if (res[i].size() >= 2) { cout << "-1"; }
			else { cout << res[i][0]; }
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

struct Shop {
	long long int a, b;
	Shop(const long long int aa, const long long int bb) {
		a = aa, b = bb;
	}
	bool operator<(const Shop &s)const {
		return s.a * (b + 1) < a*(s.b + 1);
	}
};

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

	/*
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			for (int k = 1; k <= 10; k++) {
				for (int l = 1; l <= 10; l++) {
					int a = i + j + 1;
					a = a + (a + 1)*k + l;
					int b = k + l + 1;
					b = b + (b + 1)*i + j;
					if (a == b)cout << i << " " << j << " " << k << " " << l << endl;
				}
			}
		}
	}
	*/
	cin >> N >> M;
	vector<long long int>zero;
	vector<Shop>shop;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		if (L)shop.emplace_back(L, R);
		else zero.push_back(R);
	}
	sort(shop.begin(), shop.end());
	vector<long long int>dp(40, MOD*MOD);
	dp[0] = 0;
	for (auto i : shop) {
		//cout << i.a << " " << i.b << endl;
		for (int j = 38; j >=0; j--) {
			if (dp[j] > M)continue;
			dp[j + 1] = min(dp[j + 1], dp[j]+1 + (dp[j] + 1)*i.a + i.b);
		}
	}
	sort(zero.begin(), zero.end());
	int ans = 0;
	for (auto &i : zero)i++;
	for (int i = 1; i < zero.size(); i++) {
		zero[i] += zero[i - 1];
	}
	for (int i = 0; i <= 39; i++) {
		if (dp[i] > M)continue;
		ans = max(ans, i + (int)(upper_bound(zero.begin(), zero.end(), M - dp[i])-zero.begin()));
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0

for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
            ans += gcd(x,y,z)
            
print(ans)


Measured memory_bytes: 69844
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, n) for(int i = 1; i <= n; ++i)
#define rep1(i,start,n) for(int i=start;i<n;++i)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define MP make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
LL ar[200001];
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    LL n,need;
    while(cin>>n>>need)
    {
        LL ans=0;
        rep(i,n) cin>>ar[i];
        for(int i=1;i<=n;i++)
        {
           // cout<<"ar[i] = "<<ar[i-1]<<endl;
             if(ar[i]+ar[i-1]>need)
             {
                 ans+=((ar[i]+ar[i-1])-need);
                 ar[i]-=((ar[i]+ar[i-1])-need);
             }
        }
        cout<<ans<<endl;

    }

}




Measured memory_bytes: 1024
using System;

class AtCoder
{
    static void Main()
    {
        string[] s;
        s = NextS();

        int n, q;
        n = int.Parse(s[0]);
        q = int.Parse(s[1]);

        s = NextS();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);

        int[] x = new int[q];
        for (int i = 0; i < q; i++)
            x[i] = int.Parse(Console.ReadLine().Trim());

        int[] b = new int[n];
        for (int i = 0; i < n; i++)
            b[i] = a[n - 1 - i];

        long[] sum0 = new long[n];
        sum0[0] = b[0];
        for (int i = 1; i < n; i++)
            sum0[i] = sum0[i - 1] + b[i];

        long[] sum1 = new long[n];
        sum1[0] = a[0]; sum1[1] = a[1];
        for(int i=2; i<n; i++)
            sum1[i] = sum1[i - 2] + a[i];

        int[] c = new int[n];
        for (int i = 1; i < n; i++)
        {
            if (i * 2 < n) c[i] = (b[i] + b[i * 2]) / 2 + 1;
            else c[i] = 0;            
        }
            

        long ans = 0;
        int l, r;
        int m = 0;
        for (int i = 0; i < q; i++)
        {
            l = 0; r = n;
            while (r - l > 1)
            {
                m = (l + r) / 2;
                if (x[i] < c[m]) l = m;
                else r = m;
            }
            if (n == 2) Console.WriteLine(b[0]);
            else
            {
                m = r;
                DebugWL(m);
                if (m == n || c[m] == 0) Console.WriteLine(sum0[(n - 1) / 2]);
                else
                {
                    ans = sum0[m - 1];
                    ans += sum1[n - 1 - m * 2];
                    Console.WriteLine(ans);
                }
                
            }
            
        }
       
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

Measured memory_bytes: 32724
N, K = map(int, input().split())

list0 = []
list1 = []
set1 = set()

td = []
for i in range(N):
    t, d = map(int, input().split())
    td.append((t, d))

td.sort(key=lambda x: (x[0], -x[1]))

for t, d in td:
    if t in set1:
        list0.append(d)
    else:
        set1.add(t)
        list1.append(d)

list0.sort(reverse=True)
list1.sort(reverse=True)

various = min(K, len(list1))
selected0 = []
selected1 = []
for i in range(various):
    selected1.append(list1.pop(0))
if K > various:
    for i in range(K - various):
        selected0.append(list0.pop(0))


ans = sum(selected0) + sum(selected1) + various ** 2

mn = selected1[-1]
sum0 = sum(selected0)
sum1 = sum(selected1)
while list0 and list0[0] > mn:
    sum0 += list0.pop(0)
    sum1 -= selected1.pop(-1)
    various -= 1
    tmp = sum0 + sum1 + various ** 2
    if tmp <= ans:
        break
    ans = tmp

print(ans)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 200000 + 1000;
int a[maxn], now, len[maxn], n;

int LIS() {
	int lis = 0;
	for (int i = 0; i < now; ++i) {
		int x = upper_bound(len, len + lis, a[i]) - len;
		len[x] = a[i], lis = max(lis, x + 1);
	}
	return lis;
}
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> n;
	forn(i, n) cin >> a[i];
	int now = 1;
	int tot = 0;
	forn(i, n) {
		if (a[i] == now) {
			++tot;
			++now;
		}
	}
	cout << (n - tot == n ? -1 : n - tot) << endl;
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

int main() {
    int k, s, z, ans = 0;
    cin >> k >> s;
    for(int i=0; i<=k; i++) {
        for(int j=0; j<=k; j++) {
            z = s -i -j;
            if(z >= 0 && z <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

double dp[301][301][301];

double solve(int x, int y, int z, int n) {

	if (x < 0 or y < 0 or  z < 0) return 0;
	else if (x == 0 and y == 0 and z == 0) return 0;
	else if (dp[x][y][z] > -0.9) return dp[x][y][z];
	double ans = n + x * (solve(x - 1, y, z, n)) + y * (solve(x + 1, y - 1, z, n)) + z * (solve(x, y + 1, z - 1, n));
	return dp[x][y][z] = ans / (x + y + z);

}


int main() {
	memset(dp, -1, sizeof dp);
	int n;
	cin >> n;

	int x = 0 , y = 0 , z = 0, num;
	for (int i = 0; i < n; i++) {
		cin >> num;
		if (num == 1) x++;
		else if (num == 2) y++;
		else if (num == 3) z++;
	}
	// cout << x << " "	 << y << " " << z << endl;
	cout << fixed << setprecision(10) << solve(x, y, z, n) << endl;
	return 0;
}

Measured memory_bytes: 216900
from sys import stdin
INF = float("inf")#無限大の設定1
IINF = 10 ** 18#無限大の設定2
MOD = 10 ** 9 + 7#まれに用いるmodを予め設定しておく
n = int(stdin.readline().rstrip())
ax = list(map(int, stdin.readline().rstrip().split()))

a = 1
i = 0
ans = 0
lim = True
while lim:
    if ax[i] != a:
        i += 1
        ans += 1
    else:
        i += 1
        a += 1
    if i == n:
        lim = False
    else:
        pass
if ans == n:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 26140
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int W, H, N;

        W = sc.nextInt();
        H = sc.nextInt();
        N = sc.nextInt();

        int x, y, a, x_min = W, x_max = 0, y_min = H, y_max = 0;
        for (int i = 0; i < N; i++) {
            x = sc.nextInt();
            y = sc.nextInt();
            a = sc.nextInt();

            switch (a) {
                case 1:
                    if (x_max < x ) {
                        x_max = x;
                    }
                    break;
                case 2:
                    if (x_min > x ) {
                        x_min = x;
                    }
                    break;
                case 3:
                    if (y_max < y ) {
                        y_max = y;
                    }
                    break;
                case 4:
                    if (y_min > y ) {
                        y_min = y;
                    }
                    break;
                default:
                    break;
            }
        }
        
        if ((x_min - x_max) > 0 && (y_min - y_max) > 0) {
            out.println((x_min - x_max)*(y_min - y_max));
        } else {
            out.println(0);
        }
        
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template <typename T> T inline gcd(T a, T b) {
	// if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	// return abs(b);
	return b;
}

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

    vector<vector<int>> g(K+1, vector<int>(K+1));

    rep1(i, K+1) {
        rep1(j, K+1) {
            g[i][j] = gcd(i, j);
        }

    }

    int ans = 0;
    rep1(k, K+1) {
        rep1(i, K+1) {
            rep1(j, K+1) {
                ans += gcd(k, g[i][j]);
            }
        }
    }

    cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    int sum = 1;
    char pre;

    cin >> pre;

    for(int i=1; i<n; i++){
        char s;
        cin >> s;
        if(pre != s){
            sum++;
        }
        pre = s;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;

int n;
int d[100];
int ans;

int main() {
  int buf_l,buf_r;
  int sum = 0;
  cin >> n;

  for (int i = 0;i<n;i++){
    cin >> d[i];
    sum += d[i];
  }
  ans = sum;
  for (int t = 0; t<n-1;t++){
    buf_l = 0;
    buf_r = 0;
    for (int i = 0; i <= t; i++) {
      buf_l += d[i];
    }
    buf_r = sum - buf_l;
    ans = min(ans,abs(buf_l-buf_r));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

int main()
{
	int i, N, h[200001];
	long long C;
	scanf("%d %lld", &N, &C);
	for (i = 1; i <= N; i++) scanf("%d", &(h[i]));
	
	int j, k = 1, l, r, m;
	long long dp[200001], q[200001][2];
	q[0][0] = -h[1] * 2;
	q[0][1] = (long long)h[1] * h[1];
	for (i = 2, dp[1] = 0; i <= N; i++) {
		l = 0;
		r = k - 1;
		while (l < r) {
			m = (l + r) / 2;
			if (q[m][0] * h[i] + q[m][1] < q[m+1][0] * h[i] + q[m+1][1]) r = m;
			else l = m + 1;
		}
		dp[i] = (long long)h[i] * h[i] + C + q[l][0] * h[i] + q[l][1];
		
		q[k][0] = -h[i] * 2;
		q[k][1] = dp[i] + (long long)h[i] * h[i];
		for (; k > 1; k--) {
			if ((q[k-1][0] - q[k][0]) * (q[k-1][1] - q[k-2][1]) >= (q[k-2][0] - q[k-1][0]) * (q[k][1] - q[k-1][1])) {
				q[k-1][0] = q[k][0];
				q[k-1][1] = q[k][1];
			} else break;
		}
		k++;
	}
	
	printf("%lld\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7120
S = input()
S_list = list(S)
A = int(S_list[0]) * 10 + int(S_list[1])
B = int(S_list[2]) * 10 + int(S_list[3])

if A <= 12 and 1 <= A:
    if B <= 12 and 1 <= B:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if B <= 12 and 1 <= B:
        print("YYMM")
    else:
        print("NA")

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    ll K; cin >> K;

    ll tmp = 1;
    rep(i, s.size()){
        if(s[i] != '1'){
            tmp = i+1;
            break;
        }
    }

    if(K < tmp){
        cout << 1 << endl;
    }else{
        cout << s[tmp-1] << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;
typedef pair<int, pair<int, int>> Trio;
typedef pair<int, int> Pair;
 
int main(void) {
	int a,b;
	cin >>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0){
	cout <<"Possible"<<endl;
	}else{
	cout <<"Impossible"<<endl;
	}
	return 0;
	
 
	return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())

sum = 0

for i in range(1, n+1):
    cnt = 0
    while(1):
        if i < k:
            cnt += 1
            i = i * 2
        else:
            break
    sum = sum + (1/n) * (1/2)**cnt

print(sum)

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      if(a== 5 && b == 7 && c ==5){
      	System.out.println("YES");
      }else if(a== 5 && b== 5 &&c ==7){
      	System.out.println("YES");
      }else if(a == 7 && b == 5&& c ==5){
      	System.out.println("YES");
      }else{
      	System.out.println("NO");
      }
    }
}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 153456;
const ll mod = 1e18 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    int a , b;
    cin >> a >> b;

    int maxi = max(a , b);
    if(maxi > 9) {
        cout << -1 << endl;
    }
    else {
        cout << a * b << endl;
    }
    
    return 0;
}


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

def main():
    n, m = map(int, input().split())
    cand = {j + 1 for j in range(m)}
    for i in range(n):
        ka = list(map(int, input().split()))
        cand &= set(ka[1:])
    print(len(cand))

main()


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll X;
  std::cin >> X;

  ll x = X;

  ll cnt = (x + 10) / 11;
  ll ans = cnt * 2;
  if (cnt * 11 - 5 >= x) {
    ans--;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
V=[int(i) for i in input().split()]
if len(set(V))==1:
  print(n//2)
else:
  O,E=[],[]
  for i in range(n//2):
    O.append(V[2*i])
    E.append(V[2*i+1])
  cO=collections.Counter(O).most_common()
  cE=collections.Counter(E).most_common()
  if cO[0][0]!=cE[0][0]:
    print(n-cO[0][1]-cE[0][1])
  else:
    print(min(n-cO[0][1]-cE[1][1],n-cO[1][1]-cE[0][1]))

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

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

// 重载<<操作符，用来打印vector
template < typename T >
ostream& operator<< (ostream& out, vector< T > vec) {
	foreach(i, vec) {
		if(i != vec.begin()) {
			out << " ";
		}
		out << *i;
	}
    return out;
}


const UDW maxN = 1e5 + 7;
SDW N, M, K;
vector< SDW > ans;
set< pair< SDW, SDW> > friendship;
set< pair< SDW, SDW> > blockship;

SDW dsu[maxN], sz[maxN];	// DISJOINT_SET_UNION 并查集 

SDW Find(SDW x){
	while (x != dsu[x]) x = dsu[x] = dsu[dsu[x]];
	return x;
} 

void Union(SDW x, SDW y){
	if (sz[x] > sz[y]) swap(x, y);
	dsu[x] = y;
	sz[y] += sz[x];
}

void input(){
	cin >> N >> M >> K;
	
	// 并查集初始化 
	Rep(i, N) {
		dsu[i] = i;
		sz[i] = 1;
	}
	
	ans.assign(N, 0);
}

void solve(){
	SDW A, B, C, D;
	
	Rep(i, M) {
		cin >> A >> B;
		SDW x = Find(--A);
		SDW y = Find(--B);
		if(x != y) {
			Union(x, y);
		}
		--ans[A];
		--ans[B];
	}
	
	Rep(i, N) {
		SDW x = Find(i);
		ans[i] += sz[x] - 1;
	}
	
	Rep(i, K) {
		cin >> C >> D;
		SDW x = Find(--C);
		SDW y = Find(--D);
		if(x == y) {
			--ans[C];
			--ans[D];
		}
	}
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 3968
import math

N,K=map(int,input().split())
Ans=0
if N<K:
    for i in range(1,N+1):
        p=math.ceil(math.log(K/i,2))
        Ans+=(1/N)*(1/2)**p
else:
    for i in range(1,K):
        p=math.ceil(math.log(K/i,2))
        Ans+=(1/N)*(1/2)**p
    for i in range(K,N+1):
        Ans+=(1/N)

print(Ans)

Measured memory_bytes: 3064
N=int(input())
a=[]
b=[]
for _ in range(N):
  a_=int(input())
  a.append(a_)
  b.append(a_)
x=max(a)
b.sort()
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      print(b[-2])
    else:print(x)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector <double> v(n);
  rep(i, n) cin >> v.at(i);
  double ans = 0;
  rep(i, k) {
    ans += (v.at(i)+1)/2;
  }
  double tmp = ans;
  rep(i, n-(k-1)-1) { 
    tmp -= (v.at(i)+1)/2;
    tmp += (v.at(i+(k-1)+1)+1)/2;
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << fixed << setprecision(12);
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x = in.nextLong();

        long year = 0;
        double y = 100.0;
        while (y < x && y > 0) {
            y = Math.floor(y * 1.01);
            year++;
        }

        System.out.println(year);
    }
}

Measured memory_bytes: 35760
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,w,h,k,m,maxi,d,x;
	cin>>h>>w>>m;
	map<ll,ll> ro,co;
	map<pair<ll,ll>,ll> mp;
	for(j=0;j<m;j++)
	{
		cin>>h>>w;
		ro[h]++;
		co[w]++;
		mp[{h,w}]=1;
	}
	ll mr=0,mrt=0;
	tr(ro,it)
	{
		if(it->second>mrt)
		{
			mrt=it->second;
			mr=it->first;
		}

	}
	vector<ll> vr,vc;
	tr(ro,it)
	{
		if(it->second==mrt)
		{
			vr.push_back(it->first);
		}

	}

	ll crt=0,cr=0;
	tr(co,it)
	{
		if(it->second>crt)
		{
			crt=it->second;
			cr=it->first;
		}
	}
	tr(co,it)
	{
		if(it->second==crt)
		{
			vc.push_back(it->first);
		}
	}
	k=0;
	for(i=0;i<vr.size();i++)
	{
		for(j=0;j<vc.size();j++)
		{
			if(mp.find({vr[i],vc[j]})==mp.end())
			{
				k=1;
				break;
			}
		}
		if(k==1)
			break;
	}
	if(k==1)
	{
		cout<<mrt+crt;
	}
	else
	cout<<mrt+crt-1;
}






	



Measured memory_bytes: 67868
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int mn = 2;
	int mx = 3;
	if (A[N - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	else {
		int x;
		for (int i = N - 2; i >= 0; i--) {
			x = (mn / A[i]);
			for (int j = x - 3; j <= x + 3; j++) {
				if (j*A[i] >= mn) {
					mn = j*A[i];
					break;
				}
			}
			x = (mx / A[i]);
			for (int j = x + 3; j >= x - 3; j--) {
				if (j*A[i] <= mx) {
					mx = j*A[i] + A[i] - 1;
					break;
				}
			}
			//cerr << i << " " << mn << " " << mx << endl;
			if (mn > mx) {
				cout << -1 << endl;
				return 0;
			}
		}
		
	}
	cout << mn << " " << mx << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+5;
string s;
int main()
{
    ft
    ll t,i,j,n,m,l=0,r,p,q,ss=0;
    cin>>n;
    m=(n/11)*2;
    if((n%11)>=7)
    {
        m+=2;
    }
    else if((n%11)>0)
    {
        m++;
    }
    cout<<m<<"\n";
    return 0;
}



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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int x, y;
	cin >>  x >> y;

	for(int i = 0; i <= x; i++){
		if(2 * i + 4 * (x - i) == y){
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	cout<<n*180-360<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <complex>
#define rep(i, b) for(int i = 0; i < (b); i++)
#define repi(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i >= (b); i--)
#define ALL(u) (u).begin(), (u).end()
#define INF 100000000

using namespace std;
typedef long long ll;

int main(){
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int a = 0; a*a <= n; a++){
				for(int b = a; b*b <= n; b++){
						for(int c = b; c*c <= n; c++){
								for(int d = c; d*d <= n; d++){
									if(a*a + b*b + c*c + d*d == n) cnt++;
								}
						}
				}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

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

  vector<int> a(n);
  for (auto &i : a) cin >> i;

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

  int ok = n, ng = -1;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    bitset<5000> dp;
    dp[0] = true;

    for (int i = 0; i < n; ++i) {
      if (i == mid) continue;
      dp |= dp << a[i];
    }

    bool izryt = false;
    for (int i = max(0, K - a[mid]); i < K; ++i) {
      if (dp[i]) izryt = true;
    }

    if (izryt) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
}


Measured memory_bytes: 256