akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	map<int, int>mp;
	vector<int>a(N); rep(i, 0, N) { cin >> a[i]; mp[a[i]]++; }
	int d = *max_element(all(a));
	int r = (d + 1) / 2;
	int cnt = 0;
	bool f = true;
	for (auto p : mp) {
		if (p.first < r)f = false;
		if (p.first > r and p.second < 2)f = false;
	}
	dump(mp[r]);
	if (d % 2 == 0 and mp[r] != 1)f = false;
	if (d % 2 == 1 and mp[r] != 2)f = false;
	for (int i = d; i > r; i--) {
		if (mp[i] < 2)f = false;
	}
	if (f) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int k, x;
   cin >> k >> x;
   if(500*k>=x) out("Yes");
   else out("No");
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MAXN = 101010;
typedef long long int LL;
int n, k;
int q[MAXN], p[MAXN];
long long int ans;
int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i ++){
        p[i] = n / i;
        q[i] = n % i;
    }
 
    if(k == 0){
        printf("%lld", (LL)n * (LL)n);
        return 0;
    }
 
    for(int i = 1; i <= n; i ++){
        if(i <= k)
            continue;
        ans += (LL)(i - k) *  p[i];
        ans += q[i] >= k ? q[i] - k + 1 : 0;
    }
    printf("%lld", ans);
 
}


Measured memory_bytes: 896
import numpy as np
MOD = 10**9+7

N, K = map(int, input().split())
A = np.zeros([N, N], dtype='int64')
for i in range(N):
    *A[i], = map(int, input().split())

def dot_MOD(x1, x2, MOD):
    ret = np.zeros((x1.shape[1],x2.shape[0]), dtype='int64')
    for i in range(x1.shape[0]):
        for j in range(x2.shape[1]):
            ret[i][j] = np.mod(x1[i,:] * (x2[:,j][np.newaxis:]), MOD, dtype='int64').sum()
    ret %= MOD
    return ret

ans = np.eye(N, dtype='int64')
while K:
    if K&1:
        ans = dot_MOD(ans,A,MOD)
    A = dot_MOD(A, A, MOD)
    K >>= 1
print(np.mod(ans.sum(), MOD, dtype='int64'))

Measured memory_bytes: 27316
def su(a,s,K):
    for i in range(1,K+1):
        for j in range(len(s)-i+1):
            a.add(s[j:j+i])
    a = sorted(a)
    return(a)
    
s = input()
K = int(input())
a = set([])
a = su(a,s,K)
print(a[K-1])

Measured memory_bytes: 4464
b = require('fs').readFileSync('/dev/stdin');

charA = 65, charZ = 90, chara = 97, charz = 122;

for (i = 0; i < b.length; i++) {
	c = b.readUInt8(i);
	if (c < charA) ; // void
	else if (c <= charZ) b.writeUInt8(c + (chara - charA), i);
	else if (c < chara) ; // void
	else if (c <= charz) b.writeUInt8(c - (chara - charA), i);
	else ; // void
}

console.log(b.toString().trim());

Measured memory_bytes: 15856
N = int(input())
B = [int(i) for i in input().split(' ')]
A = [0]*(N)
for i,a in enumerate(B):
    if i == 0: #index最初
        A[i] = a
        A[i+1] = a
    else:#二番目以降
        if B[i-1] < B[i]:
            A[i+1] = a
        else:
            A[i] = a
            A[i+1] = a

print(sum(A))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

const int MAX = 2000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

    vector<int> a(n);
    int kisu = 0, gusu = 0;
    
    REP(i, n) {
        cin >> a[i];
        if(a[i] % 2 == 0) gusu++;
        else kisu++;
    }

    if(kisu % 2 != 0) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
    return 0;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()
dp1 = set()
dp2 = set()
dp3 = [0]*1000
s2 = int(S[0])
s3 = int(S[1])
for i in range(N-2):
    s1, s2 = s2, s3
    s3 = int(S[i+2])
    dp1.add(s1)
    for m in dp1:
        dp2.add(m*10+s2)
    for n in dp2:
        dp3[n*10+s3] = 1
print(sum(dp3))


Measured memory_bytes: 41580
N,M=map(int,input().split())
ans=0
digit=[-1]*N
for i in  range(M):
    s,c=map(int,input().split())
    if digit[s-1]>=0 and digit[s-1]!=c:
        ans=-1
        break
    if s==1 and c==0 and N!=1:
        ans=-1
        break
    else:
        digit[s-1]=c

if ans!=-1:
    if N==1:
        ans+=max(0,digit[0])
    else:
        ans+=max(1,digit[0])*(10**(N-1))
    for j in range(1,N):
        if digit[j]!=-1:
            ans+=digit[j]*(10**(N-j-1))


print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
public class Main {
 
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
 
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
 
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
 
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        }  
    }
 
    public static void main(String[] args) throws IOException {
 
        FastReader s= new FastReader();
 
        int n = s.nextInt();
 
        int count = 1;
        boolean found = false;
        
        for (int i = 1; i < 10; i++) {
        	if (found == false) {
        		for (int j=count;j<10;j++) {
        			if (i * j == n) {
        				found = true;
        				break;
        			}
        		}
        	} else {
        		break;
        	}
        }
        
        if (found == true)
        	System.out.println("Yes");
        else {
        	System.out.println("No");
        }
 
    }
}

Measured memory_bytes: 25320
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;
using R=double;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0;j<=i;++j){
 if(j==0 or j==i){
 C[i][j]=1LL;
 }else{
 C[i][j]=(C[i-1][j-1]+C[i-1][j]);
 }
 }
 }
 }

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

 const int NMAX=50;
 ll v[NMAX];

 for(int i=0;i<N;++i){
 cin >> v[i];
 }

 comb_table(N);
 sort(v,v+N);
 reverse(v,v+N);

 R max_average=0.0;
 for(int i=0;i<A;++i){
 max_average+=v[i];
 }
 max_average/=A;

 int a_th_val_num=0,a_th_val_pos=0;
 for(int i=0;i<N;++i){
 if(v[i]==v[A-1]){
 a_th_val_num++;
 if(i<A){
 a_th_val_pos++;
 }
 }
 }

 ll cnt=0LL;
 if(a_th_val_pos==A){
 for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
 cnt+=C[a_th_val_num][a_th_val_pos];
 }
 }else{
 cnt+=C[a_th_val_num][a_th_val_pos];
 }

 cout.precision(20);
 cout << fixed << max_average << endl;
 cout << cnt << endl;

 return 0;
 }


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

using namespace std;

int main(){

  int i,m,M,S,W;
  double N;
  const double PI=3.14159265358979323846;
  //cin>>S>>T;
  
  cin>>S>>W;
  //cin>>U;

  
  //  cout<<S<<endl;
  if(S>W){
  cout<<"safe"<<endl;
  }
  else{
    cout<<"unsafe"<<endl;
  }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int n;
string s;

bool sub(char c0, char c1) {
    bool f = false;
    vector<char> ans(n, ' ');
    ans[0] = c0;
    ans[1] = c1;
    for (int i=1; i<n; i++) {
        char na;
        if ((ans[i]=='S'&&s[i]=='o')||(ans[i]=='W'&&s[i]=='x'))
            na = ans[i-1]=='S'?'S':'W';
        else
            na = ans[i-1]=='S'?'W':'S';
        if (ans[(i+1)%n] != ' ' && ans[(i+1)%n] != na) {
            f = true;
            break;
        }
        ans[(i+1)%n] = na;
    }

    if (!f) {
        char na;
        if ((ans[0]=='S'&&s[0]=='o')||(ans[0]=='W'&&s[0]=='x'))
            na = ans[n-1]=='S'?'S':'W';
        else
            na = ans[n-1]=='S'?'W':'S';
        if (na == ans[1]) {
            for (auto i : ans) cout << i;
            cout << endl;
        }
        else f = true;
    }
    
    return !f;
}

int main() {
    cin >> n >> s;
    if (sub('S', 'S')) return 0;
    if (sub('S', 'W')) return 0;
    if (sub('W', 'S')) return 0;
    if (sub('W', 'W')) return 0;
    cout << -1 << endl;
}


Measured memory_bytes: 576
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String expr = s.nextLine();
		long answer = Long.parseLong(s.nextLine());
		long bobs = bobsAnswer(expr);
		long calc = calculate(expr);
		if (bobs == answer) {
			System.out.println(bobs == calc ? "U" : "L");
		} else {
			System.out.println(calc == answer ? "M" : "I");
		}
	}

	private static long calculate(String expr) {
		ArrayList<String> tokens = lex(expr);
		while(tokens.size() > 1) {
			boolean hasAst = false;
			for(int i = 0; i < tokens.size(); i++) {
				if (tokens.get(i).equals("*")) {
					long v = Long.parseLong(tokens.get(i-1)) * Long.parseLong(tokens.get(i+1));
					tokens.set(i, String.valueOf(v));
					tokens.remove(i+1);
					tokens.remove(i-1);
					hasAst = true;
					continue;
				}
			}
			if (hasAst) {
				continue;
			}
			long total = 0L;
			for(String token : tokens) {
				if ("+".equals(token)) {
					continue;
				}
				total += Long.parseLong(token);
			}
			return total;
		}
		return Long.parseLong(tokens.get(0));
	}

	private static ArrayList<String> lex(String expr) {
		ArrayList<String> tokens = new ArrayList<String>();
		String[] nums = expr.split("\\+|\\*");
		String[] symbol = expr.split("[0-9]+");
		for(int i = 1; i < symbol.length; i++) {
			tokens.add(nums[i-1]);
			tokens.add(symbol[i]);
		}
		tokens.add(nums[nums.length-1]);
		return tokens;
	}

	private static long bobsAnswer(String expr) {
		ArrayList<String> tokens = lex(expr);
		if (tokens.size() <= 1) {
			return Long.parseLong(tokens.get(0));
		}
		long total = Long.parseLong(tokens.get(0));
		for(int i = 1; i < tokens.size(); i+=2) {
			long next = Long.parseLong(tokens.get(i+1));
			if ("+".equals(tokens.get(i))) {
				total += next;	
			} else {
				total *= next;
			}
		}
		return total;
	}
	
}

Measured memory_bytes: 17320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define INT_MAX 2147483647

int main(void){
    int N;
    scanf("%d", &N);
    
    char W[100][11];
    char D[100][11];

    int i, j;

    for(i=0; i<N; i++) {
        scanf("%s", W[i]);
    }
    int vio = 0;
    for(i=0; i<N; i++) {
        if(i < N - 1 && W[i][strlen(W[i]) - 1] != W[i + 1][0]) {
            vio = 1;
        }
        for(j=i+1; j<N; j++) {
            if(strcmp(W[i], W[j]) == 0) {
                vio = 1;
            }
        }
    }

    if(vio == 1) {
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main (){
    long long int N; //test case
    long long int total=1;
    
    scanf("%lld",&N);
    long long int A[N]; //input nilainya
    
    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
    }
    for(int j=0;j<N;j++){
        if(A[j] == 0){  //mirip seperti ?: (ternary operator)
            printf("0"); //angka berapapun kalo dikali 0, hasilnya tetap 0
            return 0;
        }
    }
    for(int k=0;k<N;k++){
        if(A[k]<=1000000000000000000/total){
            total = total*A[k];
            // apakah angka yang dikalikan itu < 10^18
       // apakah input <= 10^18/total
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", total);
    
    
return 0;
}

Measured memory_bytes: 3936
#include<iostream>
#include<stdio.h>
#define MAX 200000
#define NIL -1
#define B -2
#define W -1
#define G 0
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

int d[MAX];
int p[MAX];
int color[MAX];
int n;
int u;
int k;

int c;
int vv;

queue <int> Q;
struct tre {
	int v;
	int weight;
};

tre b;

vector <tre> M[MAX];
void DIJKSTRA() {
	for (int i = 0; i < n; i++) {
		d[i] = 9000000;
		p[i] = NIL;
		color[i] = W;
	}
	d[0] = 0;
	color[0] = B;
	int s = 0;
	Q.pop();
	
	while (!Q.empty()) {
		
		for (int i = 0; i < M[s].size(); i++) {
			if (color[M[s][i].v] != B) {

				if (d[M[s][i].v] > d[s] + M[s][i].weight) {

					d[M[s][i].v] = d[s] + M[s][i].weight;
					p[M[s][i].v] = s;
					color[M[s][i].v] = G;
					

					  
				}
			}
		}
		int a = 0;
		int mini = MAX;
		for (int j = 0; j < n; j++) {

			if (color[j] == G) {
				if(mini>d[j]){
					a = j;
				}
				mini = min(mini, d[j]);
			}

		}
		s = a;
		color[a] = B;
		Q.pop();
	
	}

}
int main(){

	cin >> n;
	
	
	for (int i = 0; i < n; i++) {
		cin >> u; cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> vv >> c;
			b.v = vv;
			b.weight = c;
			M[u].push_back(b);
			
		}Q.push(i);
	}

	DIJKSTRA();
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 12468
N = int(input())
d = [[int(j) for j in input().split()] for i in range(N)]
ind = float('inf')
for i, (x,y,h) in enumerate(d):
    if h != 0:
        ind = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        x,y,h = d[ind]
        H = h + abs(x - cx) + abs(y - cy)
        l = [h == max(H - abs(x - cx) - abs(y - cy), 0) for j,(x,y,h) in enumerate(d) if j != ind]
        if all(l):
            print(cx,cy,H)
            exit()

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ary[]=new int[N+1];
		String ans="YES";
		int inc = 0;
		for(int i=1;i<=N;i++){
			ary[i]=sc.nextInt();
		}
		for(int i=1;i<=N;i++){
			if (i!=ary[i]) {
				inc = inc+1;
			}
		}
		if (inc==0||inc==2) {
			System.out.println(ans);
		}
		else{
		ans="NO";
		System.out.println(ans);}
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        Work[] ab = new Work[n];
        for (int i = 0; i < n; i++) {
            ab[i] = new Work(sc.nextLong(), sc.nextLong());
        }
        Arrays.sort(ab, (ab1, ab2) -> {
            return Long.compare(ab1.b, ab2.b);
        });
        long sum = 0;
        for (Work w : ab) {
            sum += w.a;
            if (sum > w.b) {
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }

    static class Work {
        long a;
        long b;

        public Work(long a, long b) {
            this.a = a;
            this.b = b;
        }
    }

}


Measured memory_bytes: 107252
#include <iostream>

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	
	if (n==3){
		cout << 2 << " " << 5 << " " << 63 << endl;
		return 0;
	}
	
	if (n<=10000){
		for(int i=1; i<=n-2; i++){
			cout << i*2 << " ";
		}
		if(n%2==0){
			cout << n-1 << " " << 3*(n-1) << endl;
			return 0;
		}else{
			cout << n-2 << " " << 3*(n-2) << endl;
			return 0;
		}
	}
	
	if (n%2==0){
		if (n<=14998){
			for(int i=1; i<=9998; i++) cout << i*2 << " ";
			for(int k=1; k<n-9998; k++) cout << 3*(2*k-1) << " ";
			cout << 3*(2*(n-9998)-1) << endl;
			return 0;
		}else if (n==15000){
			for(int i=1; i<=10001; i++) cout << i*2 << " ";
			for(int k=1; k<n-10001; k++) cout << 3*(2*k-1) << " ";
			cout << 3*(2*(n-10001)-1) << endl;
			return 0;
		}else{
			for(int i=1; i<=15000; i++) cout << i*2 << " ";
			for(int k=1; k<n-15000; k++) cout << 3*(2*k-1) << " ";
			cout << 3*(2*(n-15000)-1) << endl;
			return 0;
		}
	}else{
		if (n<=14999){
			for(int i=1; i<=9999; i++) cout << i*2 << " ";
			for(int k=1; k<n-9999; k++) cout << 3*(2*k-1) << " ";
			cout << 3*(2*(n-9999)-1) << endl;
			return 0;
		}else{
			for(int i=1; i<=14999; i++) cout << i*2 << " ";
			for(int k=1; k<n-14999; k++) cout << 3*(2*k-1) << " ";
			cout << 3*(2*(n-14999)-1) << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
s=input()
for i in range(2**3-1):
  x=''
  x=s[0]
  for j in range(3):
    if (i>>j)&1:
      x+='+-'
    else:
      x+='+'
    x+=s[j+1]
  ans=list(map(int,x.split('+')))
  if sum(ans)==7:
    break
p=str(ans[0])
for i in range(1,4):
  if ans[i]<0:
    p+=str(ans[i])
  else:
    p+='+'+str(ans[i])
print(p+'=7')

Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long int;

int solve_testcase() {
    int N, M, Q; cin >> N >> M >> Q;
    if(N == 0 and M == 0 and Q == 0) return 1;

    ll fullbit = (1LL << N) - 1;
    vector<ll> bits(M, fullbit);

    string pre(M, '0');
    for(int i=0; i<Q; i++) {
        string S, B; cin >> S >> B;
        ll bit = 0;
        for(int i=0; i<N; i++) {
            if(S[i] == '1') bit |= (1LL << i);
        }

        for(int i=0; i<M; i++) {
            if(pre[i] != B[i]) {
                bits[i] &= bit;
            }
            else bits[i] &= (fullbit - bit);
        }
        pre = B;
    }

    
    for(int i=0; i<M; i++) {
        int c = __builtin_popcountll(bits[i]);
        if(c != 1) cout << "?";
        else {
            int x = 0;
            for(x=0; x<N; x++) if(bits[i] >> x & 1) break;
            if(x < 10) cout << x;
            else cout << (char)('A' + (x - 10));
        }
    }
    cout << endl;

    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



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

int n;
vector<int> a;
map<int, int> cnts;
vector<vector<vector<double>>> DP;

int main()
{
	cin >> n;
	a.resize(n);
	int total = 0;
	// number of dishes with 0, 1, 2, 3 sushi in it
	cnts[0] = 0; cnts[1] = 0; cnts[2]; cnts[3] = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		total += a[i];
		cnts[a[i]]++;
	}

	//DP[i][j][k] is the expected number of operations needed  to clean up all dishes
	// i dishes has 1 pcs in it, j has 2 pcs in it, and k has 3 pcs in it

	DP.resize(cnts[1]+cnts[2]+cnts[3] + 1);
	for (int i = 0; i < cnts[1]+cnts[2]+cnts[3] + 1; i++)
	{
		DP[i].resize(cnts[2]+cnts[3]+1);
		for (int j = 0; j < cnts[2]+cnts[3] + 1; j++)
			DP[i][j].resize(cnts[3] + 1,0);
	}
	DP[0][0][0] = (double)0.0;

	for (int k = 0; k < cnts[3] + 1; k++)
	{
		for (int j = 0; j < cnts[2]+cnts[3]-k + 1; j++)
		{
			for (int i = 0; i < cnts[1]+cnts[2]+cnts[3]-j + 1; i++)
			{
				// dp[i][j][k] = i/n*dp[i-1][j][k]+j/n*dp[i+1][j-1][k]+k/n*dp[i][j+1][k-1]+(1-i/n-j/n-k/n)*dp[i][j][k]+1
				double tmp = 0;
				// cout << i << j << k << endl;
				tmp += 1;
				if (i > 0)
					tmp += ((double)i / n) * DP[i - 1][j][k];
				if (j > 0)
					tmp += ((double)j / n) * DP[i + 1][j - 1][k];
				if (k > 0)
					tmp += ((double)k / n) * DP[i][j + 1][k - 1];
				if(i+j+k!=0)
					DP[i][j][k] += ((double)n / ((double) i+j+k)) * tmp;
			}
		}
	}
	cout << setprecision(10) << DP[cnts[1]][cnts[2]][cnts[3]] << endl;
}

Measured memory_bytes: 219664
import math
A, B = map(int, input().split())
tmpa = math.floor(A / 0.08)
tmpb = math.floor(B / 0.1)
alst = []
blst = []

indexa = 0
while True:
    tmp = math.floor((tmpa + indexa) * 0.08)
    if tmp == A:
        alst.append(tmpa + indexa)
        indexa += 1
    elif tmp > A:
        break
    else:
        indexa += 1

indexb = 0
while True:
    tmp = math.floor((tmpb + indexb) * 0.1)
    if tmp == B:
        blst.append(tmpb + indexb)
        indexb += 1
    elif tmp > B:
        break
    else:
        indexb += 1
ans = -1
alst.sort()
blst.sort()
for i in alst:
    if blst.count(i) >= 1:
        ans = i
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int stoi(string s) {
  int ans = 0;
  for(int i = 0; i < s.length(); i++) {
    ans += (int)(s[i]-'0') * (int)pow(10.0, (int)(s.length() - i - 1));
  }
  return ans;
}

string _10to2(int n) {
  string s;
  if(n == 0) return "";
  if(n % 2 == 0) {
    s = "0";
  } else {
    s = "1";
  }
  return _10to2(n/2)+s;
}

string _10to2f(double f) {
  string s;
  if(f == 0.0) return "";
  f *= 2;
  if(f < 1.0) {
    s = "0";
  } else {
    s = "1";
    f -= 1.0;
  }
  return s+_10to2f(f);
}

int main() {
  while(1) {
    double n;
    cin >> n;
    if(n == -1.0) break;
    int r = (int)n;
    double f = n-r;
    string sr = _10to2(r);
    string sf = _10to2f(f);
    if(sr.length() <= 8 && sf.length() <= 4) {
      printf("%.8d.%.4d\n", stoi(sr), stoi(sf)*(int)pow(10.0, (int)(4-sf.length())));
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;

    print(b - a - k);
    
}


Measured memory_bytes: 3648
S = input()
N = len(S)
ans = 0
for l in range(N):
    for r in range(l+1, N+1):
        T = S[l:r]
        ok = True
        for c in T:
            if c not in 'ACGT':
                ok = False
                break
        if ok:
            ans = max(ans, r-l)
print(ans)


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

struct Dice {
	int num[6]; // top, bottom, front, back, right, left;
	static const int rd[3][4]; //?????¢??????
	
	Dice(int top, int bottom, int front, int back, int right, int left) {
		num[0] = top;		num[1] = bottom;
		num[2] = front;	num[3] = back;
		num[4] = right;	num[5] = left;
	}
	Dice(const Dice &d) {
		copy(d.num, d.num + 6, num);
	}
	
	bool operator == (const Dice &d) const {
		REP(i, 6) if (num[i] != d.num[i]) return false;
		return true;
	}
	
	bool operator < (const Dice &d) const {
		REP(i, 6) if (num[i] != d.num[i]) {
			return num[i] < d.num[i];
		}
		return false;
	}
	
	void X(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(0); }
	void Y(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(1); }
	void Z(int cnt = 1) { cnt %= 4; REP(i, cnt) rotate(2); }
	
	void rotate(int p) {
		int tmp = num[rd[p][0]];
		
		REP(i, 3) num[rd[p][i]] = num[rd[p][i + 1]];
		num[rd[p][3]] = tmp;
	}
	
	Dice unique() {
		Dice now = *this;
		
		Dice mi(*this);
		
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					if (now < mi) mi = now;
					now.X();
				}
				now.Y();
			}
			now.Z();
		}
		return mi;
	}
	
	void print() {
		REP(i, 6) printf("%d%c", num[i], i == 5 ? '\n' : ' ');
	}
};

const int Dice::rd[3][4] = {
	{2,1,3,0}, // x
	{2,4,3,5}, // y
	{0,5,1,4}, // z
};


Dice input() {
	int num[6];
	REP(i, 6) scanf("%d", num + i);
	return Dice(num[0], num[5], num[1], num[4], num[2], num[3]);
}

int main() {
	
	Dice d1 = input(); d1 = d1.unique();
	Dice d2 = input(); d2 = d2.unique();
	
	puts(d1 == d2 ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 3176
import itertools
# tempt
H,W,K=map(int,input().split())
S=[input() for _ in range(H)]

ans=1e4 # 10000(10**4)
for t in itertools.product([0,1],repeat=H-1):
    cnt=t.count(1)
    SW=[]
    tmp=[int(s) for s in S[0] ]
    
    for i, c in enumerate(t):
        if c:
            SW.append(tmp)
            tmp = [int(s) for s in S[i + 1]]
        else:
            tmp = [tmp[j] + int(S[i + 1][j]) for j in range(W)]
    SW.append(tmp)
    H_ = len(SW)
    sums = [0] * H_
    if max(itertools.chain.from_iterable(SW)) > K:
        continue
    for w in range(W):
        sumtmp = [sums[i] + SW[i][w] for i in range(H_)]
        if max(sumtmp) > K:
            cnt += 1
            sums = [SW[i][w] for i in range(H_)]
        else:
            sums = sumtmp
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    X = int(input())
    X -= 400
    print(8 - X//200)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9456
#include<stdio.h>

int main(){

   int a=0, b=0, c=0;     // define variable, 1<= a, b, c <=10000
   int Ans[3];                 // define answer list, Ans[0]<Ans[1]<Ans[2]

   scanf("%d %d %d", &a, &b, &c);      // input

   if (a<b){
       Ans[0] = a;
       Ans[1] = b;
    } else{
       Ans[0] = b;
       Ans[1] = a;
    }

    if (c<Ans[0]){
       Ans[2] = Ans[1];
       Ans[1] = Ans[0];
       Ans[0] = c;
    } else if(c>Ans[1]){
       Ans[2] = c;
    } else{
       Ans[2] = Ans[1];
       Ans[1] = c;
    }

    printf("%d %d %d\n", Ans[0], Ans[1], Ans[2]);
    return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,K,n1;cin>>N>>K;
    int A[100010];
    for(int i=1;i<=N;i++){
        cin>>A[i];
        if(A[i]==1)n1=i;
    }
    int ans=(n1-1)/(K-1)+(N-n1)/(K-1);
    if((n1-1)%(K-1)+(N-n1)%(K-1)>0&&(n1-1)%(K-1)+(N-n1)%(K-1)<=K-1)ans++;
    else if((n1-1)%(K-1)+(N-n1)%(K-1)>=K)ans+=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int n;
ll x;
vector<ll> patty(51),all(51);


ll burger_count(int n, ll x){
    if(x == 0) return 0;
    if(n == 0) return 1;
    if(x == 1) return 0;
    else if(1 < x && x <= all[n] + 1) return burger_count(n-1,x-1);
    else if(x == all[n] + 2) return patty[n] + 1;
    else if(all[n] + 2 < x && x <= 2 * all[n] + 2) return burger_count(n-1,x - all[n] - 2) + patty[n] + 1;
    else if(x == 2 * all[n] + 3) return 2 * patty[n] + 1;
}


int main(){
    cin >> n >> x;
    patty[1] = 1;
    all[1] = 1;
    for(int i = 1;i < 50;i++){
        patty[i+1] = 2 * patty[i] + 1;
        all[i+1] = 2 * all[i] + 3; 
    }

    cout << burger_count(n,x) << endl;;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import numpy as np
import math
import re

a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]

def f(t,s):
    if t==0:
        return 10**9
    l=min(s//(t*100),c[t][0])
    k=100*t*l
    if l==c[t][0]:
        k+=c[t][1]
    if k<s:
        l+=f(t-1,s-k)
    return min(l,f(t-1,s))
print(f(a,b))


Measured memory_bytes: 12708
MOD = 998244353
MAX = int(2e5 + 5)

fact = [0] * MAX
invFact = [0] * MAX


def bigmod(a, b):
	if b == 0:
		return 1
	ret = bigmod(a, b // 2)
	ret = (ret * ret) % MOD
	if b % 2 == 1:
		ret = (ret * a) % MOD
	return ret


def mod_inverse(a):
	return bigmod(a, MOD - 2)


def pre():
	global fact, invFact
	fact[0] = 1
	for i in range(1, MAX):
		fact[i] = (fact[i - 1] * i) % MOD
	invFact[MAX - 1] = mod_inverse(fact[MAX - 1])
	for i in range(MAX - 2, -1, -1):
		invFact[i] = (invFact[i + 1] * (i + 1)) % MOD


def ncr(nn, rr):
	if nn < 0 or nn < rr or rr < 0:
		return 0
	up = fact[nn]
	down = (invFact[rr] * invFact[nn - rr]) % MOD
	return (up * down) % MOD


pre()
n, m, k = map(int, input().split())

# for i in range(10):
# 	print(fact[i], end=" ")
# print()
# print(ncr(10 , 4))

ans = 0
for i in range(k + 1):
	tmp = m * bigmod(m - 1, n - 1 - i) * ncr(n - 1, i)
	tmp %= MOD
	ans = (ans + tmp) % MOD

print(ans)


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int f(int t)
{
  int res = 0;
  while (t > 9) {
    res += t % 10;
    t /= 10;
  }
  return res + t;
}

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

  CIN(N, A, B);
  int ans = 0;
  FOR(i, 1, N + 1) {
    int tmp = f(i);
    if (A <= tmp && tmp <= B) ans += i; 
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
n = int(input())
x,y,ans = [],[],0
for i in range(n):
    a,b = (int(i) for i in input().split())
    x.append((a,b))
    y.append((-a-b,i))
y.sort()
for i in range(n):
    if i%2: ans-=x[y[i][1]][1]
    else: ans+=x[y[i][1]][0]
print(ans)

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

int main(){
  int N, K;
  int kotae = 1;
  int add, multi;
  cin >> N >> K;


    for ( int i=0; i < N; i++){
      multi = kotae * 2;
      add = kotae + K;
      if ( add <= multi ){
        kotae = add;
      }
      else {
        kotae = multi;
      }
     }

   cout << kotae << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    P = [int(i)-1 for i in input().split()]
    XY = [[int(i)-1 for i in input().split()] for j in range(M)]

    par = [i for i in range(N)]
    rank = [1 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            x, y = y, x
        rank[x] += rank[y]
        par[y] = x

    def size(x):
        return rank[find_root(x)]

    for x, y in XY:
        unite(x, y)

    ans = 0
    for i, p in enumerate(P):
        if is_same_group(i, p):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95768
#include <stdio.h>

int main()
{
 int n,k;
  scanf("%d%d",&n,&k);
  
  int a[n];
  int i;
  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=k;i<n;i++){
    if(a[i+1-1]>a[i-k+1-1]){
      printf("Yes\n");
    }
    else
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2440
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int sum(int x){
  int wa=0;
  for(int i=1;i<=x;++i){
    wa+=i;
  }
  return wa;
}

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<double> p(N);
  vector<double> q(N);
 
  rep(i,N){
    cin>>p[i];
    q[i]=sum(p[i])/p[i];
  }
  
  double sum=0;
  
  for(int i=0;i<K;++i){
    sum+=q[i];
  }
  
  double ans=sum; 
  for(int i=K;i<N;++i){
    sum=sum+q[i]-q[i-K];
    ans=max(ans,sum);
  }
  
  cout<<fixed;
  cout<<setprecision(6)<<ans<<endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  long long int N, M;

  scanf("%lld%lld", &N, &M);

  if(N == M){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[3][100100];
long long dp[3][100100];

int main (){

cin >> n;
for (int i =0; i < n; i++)	
{
	cin >> a[0][i] >> a[1][i] >> a[2][i];
}

for (int i=0; i < 3; i++)
	dp[i][0]=a[i][0];

for (int i=1; i < n; i++)
{
	dp[0][i]=max(dp[1][i-1], dp[2][i-1])+a[0][i];
	dp[1][i]=max(dp[0][i-1], dp[2][i-1])+a[1][i];
	dp[2][i]=max(dp[1][i-1], dp[0][i-1])+a[2][i];


}
cout << max (max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);

return 0;

	
}

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

int main(){

  // int a, b, c, d, e, k;
  int a[5];
  int k;
  // cin >> a >> b >> c >> d >> e >> k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

  bool ans = true;


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

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

      if(abs(a[j] - a[i]) > k) ans = false;
      
    }

  }

  if(ans) cout << "Yay!" << endl;
  else cout << ":(" << endl;

}

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

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int ans = x;
	rep(i, n) {
		int a;
		cin >> a;
		ans += (d+a-1)/a;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x) {
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
#define GG {puts("No"); return 0;}
const int N=300010;
int n;
int a[N],b[N];
inline bool Check(int l,int r) {
	int lbd=0,rbd=0;
	for(int i=l;i<=r;i++) {
		if(b[i]<i) {
			// printf("%d\n",i);
			if(lbd>b[i] || (b[i]<l || b[i]>r)) return false;
			lbd=b[i];
		} else if(b[i]>i) {
			if(rbd>b[i] || (b[i]<l || b[i]>r)) return false;
			rbd=b[i];
		}
	}
	return true;
}
signed main() {
	read(n);
	for(int i=1;i<=n;i++)
		read(b[i]),a[i]=(b[i]==i);
	for(int i=2;i<n;i++) if(!a[i-1] && !a[i] && !a[i+1]) GG
	for(int i=1;i<=n;i++) {
		if(a[i]==0) {
			int now=1;
			int l=i,r=i;
			while((a[r]^now) && r<=n) ++r,now^=1;
			--r;
			if(!Check(l,r)) GG
			i=r;
		}
	}
	puts("Yes");
	return 0;
}
/*
5
5 2 1 4 3
*/

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

int main(){
  int X;
  cin >> X;
  int Now=0;
  int Ans=0;
  for(int i=1; i<=X; i++){
    Now+=i;
    if(Now>=X){
      Ans=i;
      break;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
def main():
    n, c, k = map(int, input().split())
    t = [None]*n
    for i in range(n):
        t[i] = int(input())
    t.sort()
    ans = 0
    l = 0
    x = t[0]+k
    for r in range(1, n):
        if x < t[r] or c < r-l+1:
            ans += 1
            l = r
            x = t[r] + k
        if r == n-1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

struct UF{
    int par[100001];
    UF() {rep(i,100001) par[i] = -1;}
    int root(int a) {
        if (par[a] < 0) return a;
        else return par[a] = root(par[a]);
    }
    int size(int a) {return -par[root(a)];}
    bool same(int x, int y) {return root(x) == root(y);}
    void unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (same(rx, ry)) return;
        if (size(rx) < size(ry)) par[ry] += par[rx], par[rx] = ry;
        else par[rx] += par[ry], par[ry] = rx;
    }
};

int n,m,k,ans[100000];
UF uf;

signed main() {
    cin >> n >> m >> k;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a,b);
        ans[a]--, ans[b]--;
    }
    rep(i,k) {
        int c,d;
        cin >> c >> d;
        --c, --d;
        if (uf.same(c,d)) ans[c]--, ans[d]--;
    }
    rep(i,n) cout << uf.size(i)+ans[i]-1 << " ";
    cout << endl;
}


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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] nums = new int['z' - 'a' + 1];
        int[] tmp = new int['z' - 'a' + 1];
        for (char c : sc.next().toCharArray()) {
            nums[c - 'a']++;
        }

        for (int i = 1; i < n; i++) {
            for (char c : sc.next().toCharArray()) {
                tmp[c - 'a']++;
            }

            for (int j = 0; j < 'z' - 'a' + 1; j++) {
                nums[j] = Math.min(nums[j], tmp[j]);
            }

            Arrays.fill(tmp, 0);
        }

        for (int i = 0; i < 'z' - 'a' + 1; i++) {
            for (int j = 0; j < nums[i]; j++) {
                System.out.printf("%c", 'a' + i);
            }
        }
        System.out.println();
    }
}


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

using namespace std;

int main()
{
  int i,j,k,cnt = 0;
  bool check = true;
  int n;
  cin >> n;
  int a[n],b[n],c[n-1];
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++) cin >> b[i];			
  for(i=0;i<n-1;i++) cin >> c[i];
  for(i=1;i<=n;i++)
  {
  	cnt += b[a[i-1]-1];
  	if(i != 1 && a[i-1]-a[i-2] == 1) cnt += c[a[i-1]-2];
  }
  cout << cnt;
  return 0;
  /*3
3 1 2
2 5 4
3 6*/
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=3030,mod=1e9+7;
int n;
ld p[N];
ld dp[N][N];

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;++i)cin>>p[i];
	dp[0][0]=1;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			dp[i+1][j+1]+=dp[i][j]*p[i];
			dp[i+1][j]+=dp[i][j]*(1-p[i]);
		}
	ld res=0;
	for(int i=n/2+1;i<=n;++i)res+=dp[n][i];
	cout<<setprecision(10)<<fixed<<res<<endl;
}


Measured memory_bytes: 145776
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> C(N, 0), S(N, 0), F(N, 0);
	for(int i=0; i<N-1; i++)
		cin >> C[i] >> S[i] >> F[i];

	vector<int> ret(N, 0);
	for(int i=0; i<N-1; i++){
		int t = S[i] + C[i];
		for(int j=i+1; j<N-1; j++){
			if(t > S[j]){
				if(t%F[j] == 0)
					t += C[j];
				else
					t += F[j] - t%F[j] + C[j];
			}
			else{
				t = S[j] + C[j];
			}
		}

		ret[i] = t;
	}

	for(auto t : ret)
		cout << t << endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){

  int h,w;

  while(true){
    cin >> h >> w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if( (i==0||i==h-1) || (j==0||j==w-1)){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout <<endl;
    }
    cout <<endl;
  }

}



Measured memory_bytes: 3060
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <int> conn[100050];
vector <int> son[100050];
int tus;
bool dchk[100050];
int lr[100050][2];
void DFS(int n) {
	dchk[n] = true;
	lr[n][0] = ++tus;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		son[n].push_back(it);
		DFS(it);
	}
	lr[n][1] = tus;
}
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}
	if (N % 2 == 1) return !printf("First\n");

	DFS(1);
	for (i = 1; i <= N; i++) {
		int c = 0;
		for (auto it : son[i]) if (lr[it][1] % 2 == lr[it][0] % 2) c++;
		if (c >= 2) return !printf("First\n");
	}
	return !printf("Second\n");
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<pair<long long, long long>> edge(N - 1);
  for(int i = 0; i < N - 1; i++){
    cin >> edge[i].first >> edge[i].second;
    if(edge[i].first > edge[i].second){
      swap(edge[i].first, edge[i].second);
    }
  }
  
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    ans += (long long)i * (N - i + 1);
  }
  
  for(int i = 0; i < N - 1; i++){
    ans -= edge[i].first * (N - edge[i].second + 1);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6432
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N;
	int *Player;
	int Field;
	string Yama;
	while(scanf("%d",&N),N!=0){
		Field=0;
		Player = new int [N];
		for(int i=0;i<N;i++)Player[i]=0;
		char Temp[101];
		scanf("%s",Temp);
		Yama=Temp;
		for(int i=0;i<100;i++){
			if(*(Yama.c_str()+i)=='M'){
				Player[i%N]++;
			}
			if(*(Yama.c_str()+i)=='S'){
				Field+=Player[i%N]+1;
				Player[i%N]=0;
			}
			if(*(Yama.c_str()+i)=='L'){
				Player[i%N]+=Field+1;
				Field=0;
			}
		}
		sort(Player,Player+N);
		for(int i=0;i<N;i++){
			printf("%d ",Player[i]);
		}
		printf("%d\n",Field);
	}
	return 0;
}

Measured memory_bytes: 1076
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Just brute force problems with small constraints

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int R = input.nextInt();
		int C = input.nextInt();
		boolean[][] vis = new boolean[R][C];
		String[] rows = new String[R];
		int x = 0;
		int y = 0;
		for (int j = 0; j < R; j++) {
			rows[j] = input.next();
		}
		while (true) {
			char cur = rows[y].charAt(x);
			vis[y][x]=true;
			if (cur=='#') {
				if (x+1<C&&rows[y].charAt(x+1)=='#') x++;
				else if (y+1<R&&rows[y+1].charAt(x)=='#') y++;
				else break;
			}else break;
		}
		boolean good=true;
		for (int r = 0; r < R; r++) {
			for (int c = 0; c < C;c++) {
				if (rows[r].charAt(c)=='#'&&!vis[r][c]) {
					good=false;
					break;
				}
			}
		}
		System.out.println(good?"Possible":"Impossible");
	}
}

Measured memory_bytes: 21716