akhauriyash/Code-Regression huggingface dataset:
M[39];O(i,d){printf("%d",M[0]);for(;i<=d;i++)printf(" %d",M[i]);puts("");}D(n,d){for(M[d]=(d>0&&M[d-1]<n)?M[d-1]:n;M[d]>0;M[d]--)n>M[d]?D(n-M[d],d+1):O(1,d);}main(n){for(;scanf("%d",&n),n;)D(n,0);exit(0);}

Measured memory_bytes: 612
#include <stdio.h>
#include<string.h>
         
int main(void) 
{int a,i,b=0;char s[200001],t[200001];
scanf("%s",s);
scanf("%s",t);
a = strlen(s);
for(i=0;i<a;i++){
    if(s[i]!=t[i]){b++;}
    }
printf("%d",b);
return 0;
}

Measured memory_bytes: 2116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, k, d; cin >> x >> k >> d;
    // if (x >= 0 && x - k * d >= 0) cout << abs(x - k * d) << "\n";
    // else if (x < 0 && k * d + x <= 0) cout << abs(x + k * d) << "\n";
    // else if (x >= 0) {
    //     int kk = x / d;
    //     x -= kk * d; k -= kk;
    //     cout << abs(x - (k % 2) * d) << "\n";
    // } else {
    //     int kk = abs(x) / d;
    //     x += kk * d; k -= kk;
    //     cout << abs(x + (k % 2) * d) << "\n";
    // }
    x = abs(x);
    ll kk = x / d;
    if (kk >= k) {
        cout << abs(x - k * d) << "\n";
    } else {
        x -= kk * d; k -= kk;
        cout << abs(x - (k % 2) * d) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a,b;cin>>a>>b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}


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

int n, m, q;
int ans = 0;
vector<int> a, b, c, d;

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    void dfs(vector<int> A);
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;

}

void dfs(vector<int> A){
    if(A.size() == n+1){
        int now = 0;
        rep(i, q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    // rep(i, A.size()){
    //     cout << A[i] << " ";
    // }
    // cout << endl;
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

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

/*
floor(t): 実数t以下の最大の整数
floor(A * x / B) - A * floor(x / B)の最大値を求める
U = floor(A * x / B), V = A * floor(x / B)とすると、どちらも単調増加する
三分探索が使えそう?
x = 0, x = Nを両端とする
*/

long long calc(long long x, long long a, long long b)
{
	return (floor((double)a * x / b) - a * floor((double)x / b));
}

int	main(void)
{
	long long a, b, n;
	cin >> a >> b >> n;
	long long left = 0;
	long long right = n;
	while (abs(right - left) > 2)
	{
		long long left_middle = left + (abs(right - left) / 3);
		long long right_middle = right - (abs(right - left) / 3);
		//cout << left << " " << left_middle << " " << right_middle << " " << right << endl;
		if (calc(left_middle, a, b) > calc(right_middle, a, b)) right = right_middle;
		else left = left_middle;
	}
	long long ans = 0;
	for (long long value = left; value <= right; value++) ans = max(ans, calc(value, a, b));
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    int s = (int)sqrt(N);
    cout << s * s << endl;
    return 0;
}

Measured memory_bytes: 256
while (x,y,z = gets.split)

a = x.to_i
op = y
b = z.to_i

if op =="?"
    break
    end

if op == "+"
    puts a + b
    end

if op == "-"
    puts a - b
    end

if op == "*"
    puts a * b
    end

if op == "/"
    puts a / b
    end

end


Measured memory_bytes: 6864
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {

	int max = -1;
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		ans += t;
		if (max < t) max = t;
	}

	cout << ans - max / 2 NL;

	return 0;
}



Measured memory_bytes: 256
let n = int (stdin.ReadLine())
let d, x = stdin.ReadLine().Split() |> fun x -> int x.[0], int x.[1]
printfn "%d" (([for _ in 1..n -> int (stdin.ReadLine())] |> List.collect (fun x -> [[1..x..d] |> List.length]) |> List.sum) + x)

Measured memory_bytes: 12112
N,K=map(int,input().split())
S=list(input())
T=[int(a) for a in S]
U=[]

if N==1:
  U=[ [T[0],1] ]
else:
  tmp=T[0]
  cnt=1
  for i in range(1,N):
    if i==N-1:
      if T[i]==T[i-1]:
        cnt+=1
        U.append([tmp,cnt] )
      else:
        U.append([tmp,cnt] )
        U.append([T[i],1])
    else:
      if T[i]==T[i-1]:
        cnt+=1
      else:
        U.append([tmp,cnt] )
        tmp=T[i]
        cnt=1

summ=0
for j in range(len(U)):
  summ += U[j][1]
  U[j][1]=summ
if U[0][0]==0:
  U.insert(0,[1,0])
  U.insert(0,[0,0])
else:
  U.insert(0,[0,0])

#print(U)
maxi=0
  
for p,q in enumerate(U):
  if q[0]==1:
    pass
  else:
    right=min(p+K*2+1,len(U)-1)
    diff=U[right][1]-U[p][1]
    maxi=max(diff,maxi)
    #print(p,right,diff)
print(maxi)

Measured memory_bytes: 17960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 13;
const ll FMOD = 1e9 + 7;
 
namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }
 
    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}
 
using namespace Modop;
 
string s;
 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s;
    reverse(s.begin(), s.end());
    map<ll, ll> cnts;
    
    ll cur = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] != '?') {
            cur += modMul(modExp(10, i), (s[i] - '0')); cur %= MOD;
        } else {
            if (cnts.empty()) {
                for (int digit = 0; digit < 10; ++digit) {
                    ll tmp = modMul(modExp(10, i), digit); tmp %= MOD;
                    
                    ++cnts[tmp];
                }
            } else {
                ll toAdd[13] = { 0 };
                for (int digit = 0; digit < 10; ++digit) {
                    ll tmp = modMul(modExp(10, i), digit); tmp %= MOD;
                    
                    if (tmp) {
                        for (auto i : cnts) 
                            toAdd[(i.first + tmp) % 13] += i.second;
                    }
                }
                for (int j = 0; j < 13; ++j) 
                    cnts[j] = (cnts[j] + toAdd[j]) % FMOD;
            }
        }
    }
 
    // Don't just use cnts[5], use whatever is correct for what cur is
    // ll tot = 1;
    // for (auto i : cnts) {
        // cout << i.first << ' ' << i.second % FMOD << '\n';
        // tot *= i.second;
    // }
    ll fin;
    if (cur <= 5) fin = 5 - cur;
    else {
        fin = 13 - cur + 5;
    }
    if (cur == 5) cout << max(1ll, cnts[fin]);
    else cout << cnts[fin] % FMOD;
}


Measured memory_bytes: 3788
def main():
  import sys
  input = sys.stdin.readline
  mod=pow(10,9)+7
  x,y=map(int,input().split())
  ans=0
  if (2*y-x)%3!=0 or  (2*x-y)%3!=0:
    print(0)
    exit()
  a,b=(2*y-x)//3,(2*x-y)//3
  n,r=(a+b),a
  fact=[0]*(n+1)
  inv=[0]*(n+1)
  factinv=[0]*(n+1)
  fact[0],fact[1]=1,1
  inv[1]=1
  factinv[0],factinv[1]=1,1
  for i in range(2,n+1):
    fact[i]=(fact[i-1]*i)%mod
    inv[i]=mod-(inv[mod%i]*(mod//i))%mod               
    factinv[i]=(factinv[i-1]*inv[i])%mod      
  def cmb(n,r,mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
  print(cmb(n, r, mod)) 
      
if __name__ == '__main__':
    main()

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

int main() {
  u32 X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<u64> A(X), B(Y), C(Z);
  ArrayInput(A);
  ArrayInput(B);
  ArrayInput(C);
  sort(A.begin(), A.end(), greater<u64>());
  sort(B.begin(), B.end(), greater<u64>());
  sort(C.begin(), C.end(), greater<u64>());
  priority_queue<u64, vector<u64>, greater<u64>> Res;
  for (u32 i = 0; i < X; ++i) {
    bool flagX = false;
    for (u32 j = 0; j < Y; ++j) {
      bool flagY = false;
      for (u32 k = 0; k < Z; ++k) {
        if (Res.size() >= K) {
          u64 tmp = Res.top();
          Res.pop();
          if (tmp > A[i] + B[j] + C[k]) {
            Res.push(tmp);
            flagY = (k == 0) ? true : false;
            break;
          } else {
            Res.push(A[i] + B[j] + C[k]);
          }
        } else {
          Res.push(A[i] + B[j] + C[k]);
        }
      }
      if (flagY) {
        flagX = (j == 0) ? true : false;
        break;
      }
    }
    if (flagX) break;
  }
  vector<u64> Ans(K);
  for (auto itr = Ans.rbegin(); itr != Ans.rend(); ++itr) {
    *itr = Res.top();
    Res.pop();
  }
  for (u32 i = 0; i < K; ++i) {
    cout << Ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
using System;
					
public class Program
{
	public static void Main()
	{
		string s = Console.ReadLine();
		int num = 0;
		
		for(int i = 0; i < s.Length; i++)
		{
			if(s[i].ToString() == "+"){
				num++;
				
			}else{
				num--;
			}
		}
		
		Console.WriteLine (num);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
vector<int> divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) res.push_back(n / i);
    }
  }
  sort(begin(res), end(res));
  return res;
}
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 1;
  ll mx = accumulate(begin(a), end(a), 0);
  auto div = divisor(mx);
  for (auto d : div) {
    ll cnt = 0;
    vector<int> phase(n);
    for (int i = 0; i < n; i++) {
      phase[i] = a[i] % d;
      cnt += phase[i];
    }
    sort(begin(phase), end(phase));
    ll sum = accumulate(begin(phase), begin(phase) + n - cnt / d, 0LL);
    if (sum <= k) ans = max(ans, (ll)d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 200000
#define NIL -1

typedef struct Node{
    int parent;
    int left;
    int right;
}node;
 
node tree[N];
 
void preOrder(int u){
    if(u == NIL){
        return; 
    }
    
    printf(" %d", u);
    preOrder(tree[u].left);
    preOrder(tree[u].right);
}

void inOrder(int u){
    if(u == NIL){
        return;
    }
    
    inOrder(tree[u].left);
    printf(" %d", u);
    inOrder(tree[u].right);
    
    return;
}

void postOrder(int u){
    if(u == NIL){
        return;
    }
    
    postOrder(tree[u].left);
    postOrder(tree[u].right);
    printf(" %d", u);
    
    return;
}


int main(){
    int n, i, j, left, right, node, rooti;

    for(i = 0; i < N; i++){
        tree[i].parent = NIL;
        tree[i].left = NIL;
        tree[i].right = NIL;
    }

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d %d %d", &node, &left, &right);
        tree[node].left = left;
        tree[node].right = right;
        if(left != NIL){
            tree[left].parent = node;
        }
        if(right != NIL){
            tree[right].parent = node;
        }
    }
    for(i = 0; i < n; i++){
        if( tree[i].parent ==  NIL ){
            rooti = i;
        }
    }
        
    printf("Preorder\n");
    preOrder(rooti);

    printf("\nInorder\n");
    inOrder(rooti);

    printf("\nPostorder\n");
    postOrder(rooti);

    printf("\n");

    return 0;
}

Measured memory_bytes: 2960
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll N;
	cin >> N;
	vll a, b;
	fori(i, 1, N + 1) {
		fori(j, i + 1, N + 1) {
			if (N % 2 == 1) {
				if (i + j != N) a.push_back(i), b.push_back(j);
			}
			else {
				if (i + j != N + 1) a.push_back(i), b.push_back(j);
			}
		}
	}

	cout << a.size() << endl;
	rep(i, a.size()) cout << a[i] << " " << b[i] << endl;
}

Measured memory_bytes: 384
N = int(input())
List = list(map(int,input().split()))

def make1d(n):
  lst = []
  for i in range(n):
    lst.append(0)
  return lst

def attend(n, lst):
  res = make1d(n)
  for i in range(n):
    res[lst[i]-1] = i+1
  return res

print(*attend(N, List))

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

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int lcnt=0,rcnt=0;
	for(int i=0;i<n;++i) {
		if(s[i]==')') {
		    if(rcnt) --rcnt;
			else ++lcnt;
		} else ++rcnt;
	}
	string t;
	for(int i=0;i<lcnt;++i) t+='(';
	s=t+s;
	rcnt=0;
	for(int i=0;i<s.size();++i) {
		if(s[i]==')'&&rcnt) --rcnt;
		else ++rcnt;
	}
	for(int i=0;i<rcnt;++i) s+=')';
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0;
    int cnt = 0;
    int ans = 1;
    int A = 0;
    for (int i = 1; i <= N; i++) {
      cnt = 0;
      A = i;
      while (A % 2 == 0) {
        A = A / 2;
        cnt++;
      }
      if (cnt > max) {
        ans = i;
        max = cnt;
      }
    }
    System.out.println(ans);
  }
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector< vector< ll > > Pat; // 最初が i で、最後が j の数のパターン数

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

    cin >> N;

    Pat.assign(10, vector<ll>(10, 0) );

    for(int i = 1; i <= N; ++i) {
        string s = to_string(i);
        int i_h = s[0] - '0';
        int i_t = s[s.length()-1] - '0';
        Pat[i_h][i_t]++;
    }

    ll ans = 0;
    for(int i = 1; i <= 9; ++i) {
        for(int j = 1; j <= 9; ++j) {
            ans += Pat[i][j] * Pat[j][i];
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    map<int, int> wyst;
    vector<int> a;
    int odp = 0;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if (wyst.find(x) == wyst.end())
            wyst[x] = 1;
        else
            ++wyst[x];
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    for (int i = (int) a.size() - 1; i >= 0; --i)
    {
        int d;
        if (__builtin_popcount(a[i]) == 1)
        {
            d = a[i];
            if (wyst[d] >= 2)
            {
                ++odp;
                wyst[d] -= 2;
            }
        }
        else
        {
            d = 1;
            while (d < a[i])
                d *= 2;
            d = d - a[i];
            if (wyst[a[i]] != 0 && wyst.find(d) != wyst.end() && wyst[d] != 0)
            {
                ++odp;
                --wyst[a[i]];
                --wyst[d];
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 11808
X, N = map(int, input().split())
if N == 0:
    input()
    P = []
else:
    P = list(map(int, input().split()))

d = 0
while True:
    if X - d not in P:
        print(X - d)
        break
    if X + d not in P:
        print(X + d)
        break
    d += 1

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans = 0;
    ll X; cin >> X;
    ll st = 100;
    while(st < X){
        st += st/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
const double EPS=1e-8;
const double PI=acos(-1);
const int N=105;
int n;double x[N],y[N],z[N];
bool vis[N];
struct Node {
    double x,y;int id;
    Node(double x=0,double y=0,int id=0):x(x),y(y),id(id){}
    bool operator < (const Node &b) const {
        if(x!=b.x) return x<b.x;
        return y<b.y;
    }
    Node operator - (const Node &b) {
        return Node(x-b.x,y-b.y);
    }
    double det(const Node &b) {
        return x*b.y-y*b.x;
    }
    double dot(const Node &b) {
        return x*b.x+y*b.y;
    }
    double dis() {
        return sqrt(x*x+y*y);
    }
}point[N],ans[N];
int solve(int num) {
    std::sort(point,point+num);
    int k=0;
    for(int i=0;i<num;i++) {
        while(k>1&&(ans[k-1]-ans[k-2]).det(point[i]-ans[k-1])<EPS) k--;
        ans[k++]=point[i];
    }
    for(int i=num-2,t=k;~i;i--) {
        while(k>t&&(ans[k-1]-ans[k-2]).det(point[i]-ans[k-1])<EPS) k--;
        ans[k++]=point[i];
    }
    return k;
}
double res[N];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lf%lf",&point[i].x,&point[i].y),point[i].id=i;
    int num=solve(n)-1;
    for(int i=0;i<n;i++) res[i]=0;
    if(num==2) res[ans[0].id]=res[ans[1].id]=0.5;
    else {
        double tmp;
        for(int i=0;i<num;i++) {
            tmp=(ans[i]-ans[(i-1+num)%num]).dot(ans[i]-ans[(i+1)%num]);
            tmp=acos(tmp/(ans[i]-ans[(i-1+num)%num]).dis()/(ans[i]-ans[(i+1)%num]).dis());
            res[ans[i].id]=(PI-tmp)/PI/2;
        }
    }
    for(int i=0;i<n;i++) printf("%.12f\n",res[i]);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  ll n;cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)a[i]=0;
  for(ll i=0;i<n-1;i++){
    ll hoge;cin>>hoge;
    a[hoge-1]++;
  }
  for(ll i=0;i<n;i++){
    cout<<a[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5192
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //数値入力する
            string[] input_1 = Console.ReadLine().Split();
            string[] input_2 = Console.ReadLine().Split();
            int m1 = int.Parse(input_1[0]);
            int m2 = int.Parse(input_2[0]);

            //r*rを出力
            if(m1 == m2)
                Console.WriteLine("0");
            else
            {
                Console.WriteLine("1");
            }
                
        }
    }

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

ll dp[110][310];

ll w[110],v[110];

int main(void){
	ll n,limit;
	cin >> n >> limit;

	rep(i,n) cin >> w[i] >> v[i];

	rep(i,110)rep(j,310) dp[i][j]=-1;
	dp[0][0]=0;

	rep(i,n){
		rrep(j,n)rep(cw,310){
			if(dp[j][cw]==-1) continue;
			const ll aw=w[i]-w[0];
			if(dp[j+1][cw+aw]==-1) dp[j+1][cw+aw]=dp[j][cw]+v[i];
			chmax(dp[j+1][cw+aw],dp[j][cw]+v[i]);
		}
	}

	ll ans=0;

	rep(i,110)rep(j,310){
		if(dp[i][j]==-1) continue;
		if(i*w[0]+j>limit) continue;
		chmax(ans,dp[i][j]);
	}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    string s;cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define u_map                 unordered_map<ll,ll>
#define n_map                 map<ll,ll>
#define n_pair                pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define frr(i,j,k)           for(int i=j; i<k; i++)
#define frp(i,j,k)           for(int i=j; i>=k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define in(t)                 scanf("%lld",&t);
#define out(t)                printf("%lld\n",t);
#define inputarr(a,n)        for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n)        for(int i=0;i<n;++i) cout<<a[i]<<" "
#define mem(a)              memset(a,0,sizeof(a))
#define int_max     INT_MAX64
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
ll ans=0;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<pair<int,int>>vs;
    ll mx=0;
    frr(i,0,n){
        ll a,b;
        cin>>a>>b;
        vs.pb(make_pair(b,a));
    }
    ll dp[n+1][k+1];
    mem(dp);
    for(int i=0;i<=n;++i){
        frr(j,0,k+1){
            if(i==0||j==0)dp[i][j]=0;
            else if(j>=vs[i-1].second){
              dp[i][j]=max(dp[i-1][j],dp[i-1][j-vs[i-1].second]+vs[i-1].first);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
           // cout<<dp[i][j]<<" ";
        }
       // cout<<endl;
     }
     cout<<dp[n][k]<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


bool moveX(LL i, LL j, string& S) {
    while (i < j) {
        if (S[i + 1] == '#' && S[i + 2] == '#') {
            return false;
        }
        if (S[i + 2] == '.') i += 2;
        else i++;
    }
    return true;
}


int main() {
    LL N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    if (C < D) {
        if (moveX(B - 1, D - 1, S)) {
            if (moveX(A - 1, C - 1, S)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } else {
        LL k;
        for (k = B - 1; k <= D - 1; ++k) {
            if (S[k - 1] == '.' && S[k] == '.' && S[k + 1] == '.') {
                break;
            }
        }
        if (k < D) {
            if (k == B - 1 || moveX(B - 1, k, S)) {
                S[k] = '#';
                if (moveX(A - 1, C - 1, S)) {
                    if (moveX(B - 1, D - 1, S)) {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
        }
	}
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  set<ll> st;
  ll aaa;
  rep(i,n){
    cin >> aaa;
  st.insert(aaa);
  }
  pri(st.size());






  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c;
            int d;
            int e;
            int g;
            e = a;
            g = b;
            while (a % b != 0) {
                c = a;
                a = b;
                b = c % b;
            }
            System.out.print(b);
            d = e/b * g;
            System.out.print(" ");
            System.out.println(d);
        }
    }
}
        
           
            

            

            
       
    

        
      
    




Measured memory_bytes: 26124
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;



int main() {
	vector<int> a;
	int n, m,ans=0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int j;
		cin >> j;
		a.push_back(j);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < m; i++) {
		ans += a[i];
	}
	cout << ans << endl;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    bool ans = true;
    IN(string, s);
    REP(i, s.length()){
        if ((i%2==0)&&(s[i]=='L')) {
            ans = false;
        }else if ((i%2==1)&&(s[i]=='R')) {
            ans = false;
        }
    }
    Yes(ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,a,b,x,y;
	scanf("%d %d %d %d %d",&n ,&a ,&b ,&x ,&y);
	while(1){
		n--;
		if(a>0) a-=x;
		if(b>0) b-=y;
		if(a<=0 && b<=0) break;
	}
	printf("%d\n",n);
return 0;
}

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

int main() {

int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;

int ans= h2*60+m2-k-h1*60-m1;
cout<<ans<<endl;



}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3636
n,m=map(int, input().split())
value=sorted(list(map(int,input().split())))[::-1]
weight=[0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    for j in value:
        if i + weight[j] < n+1:
            dp[i+weight[j]] = max(dp[i+weight[j]],dp[i]*10+j)
print(dp[n])

Measured memory_bytes: 14708
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;
    cin >> N;
    VI V(N);
    REP(i,N)
    {
        int l, r;
        cin >> l >> r;
        V[i] = r - l + 1;
    }
    cout << accumulate(ALL(V),0) << endl;
  
    return 0;
}



Measured memory_bytes: 256
n = int(input())
l = [int(entry) for entry in input().split()]


def check(a, b, c):
    return (a + b) > c and (b + c) > a and (a + c) > b


count = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if check(l[i], l[j], l[k]):
                    count += 1
print(count)


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> L;
    for (int i=0; i<N; i++) {
        int temp;
        cin >> temp;
        L.push_back(temp);
    }

    int max = *max_element(L.begin(), L.end());
    L.erase(max_element(L.begin(), L.end()));
    int other_max = accumulate(L.begin(), L.end(), 0);
    if (max < other_max) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

int main() {
  int N,H;
  cin >> N>>H;
  vector<int> a(N);
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
    cin >> b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int count =0;
  for(int i=0;i<N;i++){
    if(b[i]<a[N-1]) break;
    if(H<=0) break;
    H -= b[i];
    count++;
  }
  //cout << count << endl;
  while(H>0){
    H -= a[N-1];
    count ++;
  //  cout << H << endl;
  }
  cout << count << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)1e5 + 5;
int A[MAX_N], sign[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, p=0, m=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]>0) p++, sign[i] = 1;
        else if(A[i]<0) m++, sign[i] = -1;
    }
    if(p==0){
        int idx = distance(A, max_element(A, A+N));
        sign[idx] = 1;
    }
    else if(m==0){
        int idx = distance(A, min_element(A, A+N));
        sign[idx] = -1;
    }

    int ans = 0;
    queue<int> P, M;
    for(int i=0;i<N;i++){
        if(sign[i]==1) ans += A[i], P.push(A[i]);
        else ans -= A[i], M.push(A[i]);
    }
    vector<int> X, Y;
    int cur = M.front(); M.pop();
    while(P.size()>1){
        X.push_back(cur), Y.push_back(P.front());
        cur -= P.front();
        P.pop();
    }
    X.push_back(P.front()), Y.push_back(cur);
    cur = P.front() - cur;
    while(!M.empty()){
        X.push_back(cur), Y.push_back(M.front());
        cur -= M.front();
        M.pop();
    }
    printf("%d\n", ans);
    for(int i=0;i<N-1;i++) printf("%d %d\n", X[i], Y[i]);
    return 0;
}

Measured memory_bytes: 4084
s=set()
N,M=map(int,input().split())
for i in range(M):
    a,b=map(int,input().split())
    s.add((a,b))

for i in range(N):
    if((1,i)in s and (i,N) in s):
        print("POSSIBLE")
        exit()
    
print("IMPOSSIBLE")

Measured memory_bytes: 37516
n = int(input())
cnt = [ int(1e9) for i in range(26) ]
for i in range(n):
    s = input()
    nw = [ 0 for j in range(26) ]
    for j in s:
        nw[ord(j) - ord('a')]+=1
    for j in range(26):
        cnt[j] = min( cnt[j], nw[j] )
ans = ""
for i in range(26):
    if cnt[i] != int(1e9):
        ans += chr(i+97) * int(cnt[i])
print(ans)


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


// 0-origin BIT
template <typename T>
class BIT {
public:
	vector<T> data;
	int n;
	BIT() {}
	BIT(int n_) {
		n = n_;
		data.assign(n, T(0));
	}
	// v[a] += w
	void add(int a, T w) {
		for (int x = a; x < n; x |= x + 1) data[x] += w;
	}
	// sum of v[i] for i in [0, a)
	T sum(int a) {
		T ret = 0;
		for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
			ret += data[x];
		}
		return ret;
	}
};


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

	vector<pair<int, int>> pairs(n);
	for(int i=0;i<n;i++) {
		int a;
		cin >> a;
		pairs[i].first = a;
		pairs[i].second = i;
	}
	sort(pairs.begin(), pairs.end());
	reverse(pairs.begin(), pairs.end());

	BIT<ll> bit(n);
	ll ans = 0;
	for(int i=0;i<n;i++) {
		if(i - 1 >= 0 && pairs[i].first != pairs[i - 1].first) {
			int j = i - 1;
			while(j >= 0 && pairs[j].first == pairs[i - 1].first) {
				bit.add(pairs[j].second, 1);
				j--;
			}
		}
		ll left = bit.sum(pairs[i].second);
		ll right = bit.sum(n) - left;
		ans += min(left, right);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 4340
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] point = new int[N];
		
		for (int i=0; i<Q; i++) {
			point[sc.nextInt()-1]++;
		}
		for (int i=0; i<N; i++) {
			System.out.println(K-Q+point[i]>0 ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 53652
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <algorithm>
using namespace std;

typedef pair<int, int> pii;

const int INF = (int)2e9;
const double PI = acos(-1.0);
int N;
pii S, G;
vector<pii> W;

void input_data(void) {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	S = make_pair(x1, y1);
	G = make_pair(x2, y2);
	if (x1 > x2)
		swap(S, G);
	int min_x = S.first;
	int max_x = G.first;
	int min_y = min(y1, y2);
	int max_y = max(y1, y2);
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		if ((a >= min_x && a <= max_x) && (b >= min_y && b <= max_y))
			W.push_back(make_pair(a, b));
	}
	N = W.size();
}

int get_w_count(void) {
	if (N == 0)
		return 0;
	if (S.second > G.second)
		sort(W.begin(), W.end(), greater<pii>());
	else
		sort(W.begin(), W.end());
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		A[i] = W[i].second;

	vector<int> dp(N, INF);
	for (int i = 0; i < N; ++i)
		*lower_bound(dp.begin(), dp.end(), A[i]) = A[i];
	int cnt = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	return cnt;
}

int main(void) {
	input_data();

	int dx = G.first - S.first;
	int dy = abs(G.second - S.second);
	int s = dx + dy;
	int k = get_w_count();
	int p = k;
	int q = 0;
	if (k == min(dx, dy) + 1) {
		p = k - 1;
		q = 1;
	}
	double dst = 100.0 * s;
	double sht = (20.0 - 5.0 * PI) * p;
	double lng = (10.0 * PI - 20.0) * q;
	double ans = dst - sht + lng;

	cout << fixed << setprecision(15) << ans << '\n';
	return 0;
}


Measured memory_bytes: 3824
num = int(input())
a, b, c = 0, 0, 0
for i in range(num):
  d, e, f = map(int, input().split())
  times = d - a
  distance = (e-b) + (f-c)
  if times>=distance and times%2 == distance%2:
    continue
  else:
    print("No")
    exit()
print("Yes")


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

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

for i in range(61):

    z = 0
    o = 0
    now = 2 ** i

    for j in A:

        if j & now == 0:
            z += 1
        else:
            o += 1

    ans += now * (z * o)
    ans %= 10 ** 9 + 7

print (ans)


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int a , b , c , d , e , f;
	
	cin >> a >> b >> c >> d >> e >> f;
	vi dp(101010 , 0);
	dp[100 * a] = 1;
	dp[100 * b] = 1;
	
	for(int i = min(a , b) * 100 ; i < 10100 ; ++i){
		if(dp[i]){
			dp[i + 100 * a] = 1;
			dp[i + 100 * b] = 1;
		}
	}
	
	vi sug(100100 , 0);
	rep(i , 1000){
		rep(j , 1000){
			if(c * i + d * j < 100100){
				sug[c * i + d * j] = 1;
			}	
		}
	}
	
	ll den1 = -20;
	ll den2 = 1;
	ll ans2= 0 , ans1 = f >= min(a,b) * 100 ? min(a,b)*100 : 0 ;
	
	rep(i , 50000){
		if(sug[i] == 0)continue;
		int need_w = ceil(1.0 * i / e * 100.0);
		int p = -1;

		repf(j , need_w, f + 1){
			if(dp[j]){
				p = j;
				break;
			}
		}
		if(p == -1)continue;
		if(i + p > f)continue;
		ll cur1 = 100 * i;
		ll cur2 = p + i;
		
		if(cur1 * den2 >= den1 * cur2){
			ans1 = p + i;
			ans2 = i;
			den1 = cur1;
			den2 = cur2;
		}
	}
	cout << ans1 << " " << ans2 << nl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
vector<P> vl;
set<ll> sl;

int main() {
	cin >> n;
	for (ll i = 0; i*i <= 20000; i++) {
		for (ll j = i; i*i + j*j <= 20000; j++) {
			if (i == 0 && j == 0)continue;
			vl.push_back({ i,j });
			sl.insert(i*i + j*j);
		}
	}
	rep(i, n) {
		ll p, q;
		cin >> p >> q;
		ll cnt = 0;
		ll sq = p*p + q*q;
		rep(j, vl.size()) {
			ll num = vl[j].first*vl[j].first + vl[j].second*vl[j].second;
			if (sq%num == 0) {
				ll d = sq / num;
				if (sl.find(d) != sl.end()) {
					//cout << "!" << vl[j].first << " " << vl[j].second << endl;
					cnt += 4;
				}
			}
		}
		//cout << " " << cnt << endl;
		if (cnt != 8)cout << "C" << endl;
		else cout << "P" << endl;
	}
}


Measured memory_bytes: 3276
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
    print(0)
else:
    X.sort()
    diffs = []
    for i in range(1, M):
        diffs.append(X[i] - X[i - 1])
    diffs.sort()
    ans = 0
    for i in range(M - N):
        ans += diffs[i]
    print(ans)

Measured memory_bytes: 13968