akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cstring>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
int main()
{
	string a,b;
	cin>>a>>b;
	b.erase(b.end()-1);
	if(strcmp(a.c_str(),b.c_str())==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 


int main(){
    ll n;cin >> n;
    if(n>=30)cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 3620
def B():
    NM=list(map(int,input().split()))
    A=list(map(int,input().split()))
    
    sum_A=sum(A)
    ans_list=list(filter(lambda x: x>=sum_A*(1/(4*NM[1])), A))
    
    if len(ans_list)>=NM[1]: print('Yes')
    else : print('No')
        
        
if __name__=='__main__':
    B()

Measured memory_bytes: 39816
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
void solve(){
	ll n;
	cin>>n;
	ll A[n+1]={0}, ans= 0;
	map<ll, ll>m;
	rep(i,1,n+1){
		cin>>A[i];
		A[i] += A[i-1];
		m[A[i]]++;
	}
	for(auto it = m.begin(); it != m.end(); it++)
		ans += ((it->y)*(it->y-1))/2;
	if(m.find(0) != m.end()) ans+=m.find(0)->y;
	cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int max(int a, int b, int c);

int main(){
    int n;
    std::cin >> n;
    std::string str1;
    std::string str2;
    for(int i=0;i<n;i++){
        std::cin >> str1;
        std::cin >> str2;
        int size1 = str1.size();
        int size2 = str2.size();
        int dp[size1+1][size2+1];
        dp[0][0] = 0;
        for(int j=0;j<=size1;j++){
            dp[j][0] = 0;
        }
        for(int j=0;j<=size2;j++){
            dp[0][j] = 0;
        }

        for(int j=1;j<=size1;j++){
            for(int k=1;k<=size2;k++){
                if(str1[j-1]==str2[k-1]){
                    dp[j][k] = max(dp[j-1][k],dp[j-1][k-1] + 1,dp[j][k-1]);
                }else{
                    dp[j][k] = max(dp[j-1][k],dp[j-1][k-1],dp[j][k-1]);
                }
            }
        }

        std::cout << dp[size1][size2] << std::endl;
    }
    return 0;
}

int max(int a, int b, int c){
    if(a>b){
        if(a>c){
            return a;
        }else{
            return c;
        }
    }else{
        if(b>c){
            return b;
        }else{
            return c;
        }
    }
}


Measured memory_bytes: 7060
import itertools
n = int(input())
l = list(range(1,n+1))

p = tuple(map(int,(input().split())))
q = tuple(map(int,(input().split())))

p1 = list(itertools.permutations(l, n))
pcount = 0
qcount = 0
#print(p1,p,q)
ans = abs(p1.index(p) - p1.index(q))
print(ans)
 
    
    



Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
string s;
cin>>s;
for(int i=0;i<n;i++){
	if(i==(k-1))cout<<char(tolower(s[i]));
	else cout<<s[i];
	
}
}

Measured memory_bytes: 384
#include <stdio.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int h, w;

    scanf ( "%d%d", &h, &w );
    if ( h == 0 && w == 0 ) break ;

    for ( i = 0; i < h; ++i )
    {
      for ( j = 0; j < w; ++j )
      {
        putchar ( ( i + j ) % 2 ? '.' : '#' );
      }
      puts ( "" );
    }
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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 TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0 ; i < s.length(); i++){
        if(s[i] == 'R') ans = 1;
    }
    for(int i = 0 ; i < s.length() - 1; i++){
        if(s[i] == 'R' && s[i+1] == 'R') ans = 2;
    }
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    S = input()

    # 出力
    if S[2] == S[3] and S[4] == S[5]:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 5672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int changeMin = n;
		int change=0;

		for (int i=0; i<n; i++){
			if (i == 0){
				for (int j=1; j<n; j++){
					if (s.charAt(j) == 'E'){
						change++;
					}
					changeMin = change;
				}
			} else {
				if (s.charAt(i-1) == 'W'){
					change++;
				}
				if (s.charAt(i) == 'E'){
					change--;
				}
				changeMin = Math.min(changeMin, change);
			}
		}
		System.out.println(changeMin);
	}
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	set <int> ls[n];
	int u,v;
	for (int i=0;i<m;i++){
	    cin>>u>>v;
	    u--;
	    v--;
	    ls[u].insert(v);
	    ls[v].insert(u);
	}
	int ans=0;
	int vis[n];
	for (int i=0;i<n;i++) vis[i]=0;
	for (int i=0;i<n;i++){
	    if(vis[i]==0){
	        int cnt=0;
	        queue <int> q;
	        q.push(i);
	        vis[i]=1;
	        cnt++;
	        while (!q.empty()){
	            int u=q.front();
	            q.pop();
	            for (auto v : ls[u]){
	                if(vis[v]==0){
	                    q.push(v);
	                    vis[v]=1;
	                    cnt++;
	                }
	            }
	        }
	        ans=max(ans,cnt);
	    }
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 32836
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
using namespace std;


int main(void){
	long long int r,D, x2000;

	cin >> r>>D>>x2000;
  for (int i = 0; i < 10; i++){
    x2000 = r * x2000 - D;
    cout << x2000 << endl;
}
	return 0;
}


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

int main() {
  int N;			//入力値
  int orgN;
  int digitN = 0;	//入力値の桁数
  int TotalN = 0;	//入力値の各桁の和
  int tmp;
  
  cin >> N;
  orgN = N;
  
  //入力値の桁数を計算
  for(int i = 1; (N / i) > 0; i = 10 * i){
    ++digitN;
    tmp = i;
   }
  
  //debug
//  cout << "digitN=" << digitN << endl;    
//  cout << "tmp=" << tmp << endl;   
  
  //1桁の数字ならハーシャッド数確定
  if ( digitN == 1){
    TotalN = N;
    cout << "Yes" << endl;
  }
  else{
    
    //Nの各桁の数字の和を求める
    while(tmp > 0){

      //debug
//      cout << "tmp=" << tmp << endl;

      TotalN = TotalN + (N / tmp);
	  N = N % tmp;
      tmp = tmp / 10;
      
      //debug
//      cout << "TotalN=" << TotalN << endl;
//      cout << "N=" << N << endl;
    }
    
    if ( (orgN % TotalN) == 0){
	    cout << "Yes" << endl;
    }
	else{
	    cout << "No" << endl;      
    }
  }

}


Measured memory_bytes: 3580
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = -1
for i in range(3):
    if a[i].count(-1) == 3:
        print('Yes')
        exit()
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        print('Yes')
        exit()
if a[0][0] == a[1][1] == a[2][2] == -1:
    print('Yes')
    exit()
if a[0][2] == a[1][1] == a[2][0] == -1:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3188
n = int(input())
s = input()
E = [0] * n
W = [0] * n
if s[0] == "E":
    E[0] += 1
else:
    W[0] += 1
for i in range(1, n):
    if s[i] == "E":
        a = 1
    else:
        a = 0
    E[i] = E[i - 1] + a
    W[i] = W[i - 1] + 1 - a

num = float("inf")
for i in range(n):
    if i == 0:
        num = min(num, E[n - 1] - E[i])
    elif i == n - 1:
        num = min(num, W[i - 1])
    else:
        num = min(num, E[n - 1] - E[i] + W[i - 1])

print(num)


Measured memory_bytes: 27124
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();
		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = scan.nextInt();
			}
		}
		int out = 0;
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				double distance = 0;
				for(int k = 0; k < d; k++) {
					distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				}
				distance = Math.sqrt(distance);
				if(distance % 1 == 0) out++;
			}
		}
		System.out.println(out);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


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

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, sum = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
                cin >> a[i];
                sum += a[i];
	}
        int lsum = 0, ans = INT_MAX;
        for(int i = 0; i < n; i++) {
                lsum = lsum + a[i];
                ans = min(ans, abs(sum - 2 * lsum));
        }
        cout << ans;
	return 0;
}


Measured memory_bytes: 256
import collections

def resolve():
    '''
    code here
    '''
    s = collections.deque([item for item in input()])
    que = collections.deque()

    while s:
        try:
            temp = s.popleft()
            if temp == 'B':
                que.pop()
            else:
                que.append(temp)
        except:
            pass

    print(''.join(list(que)))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9308
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
    if i == 0:
        ans += b[i]
    else:
        ans += b[i]
        if a[i]-a[i-1] == 1:
            ans += c[a[i-1]-1]
print(ans)


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

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            String input = in.readLine();

            String[] inputs = input.split("\\s+");

            int a = Integer.parseInt(inputs[0]);
            int b = Integer.parseInt(inputs[1]);
            int c = Integer.parseInt(inputs[2]);

            System.out.println(a < b && b < c ? "Yes" : "No");
        } catch (IOException ex) {
            // no op
        }
    }
}


Measured memory_bytes: 24472
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t H, N;
    std::cin >> H >> N;

    int64_t sum = 0;

    for (int64_t i = 0; i < N; ++i) {
        int64_t A;
        std::cin >> A;
        sum += A;
    }

    if (sum >= H) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
INF = 10 ** 20

full_move1_memo = [None] * 16
full_move2_memo = [None] * 16

def full_move1(n):
  if n == 1:
    return 2
  if full_move1_memo[n]:
    return full_move1_memo[n]
  a = full_move1(n - 1) * 3 + 2
  full_move1_memo[n] = a
  return a

def full_move2(n):
  if n == 1:
    return 2
  if full_move2_memo[n]:
    return full_move2_memo[n]
  a = full_move1(n - 1) * 2 + 2
  full_move2_memo[n] = a
  return a

def half_move(n):
  if n == 1:
    return 1
  if full_move1_memo[n - 1]:
    return full_move1_memo[n - 1] + 1
  return full_move1(n - 1) + 1

def solve():
  while True:
    n, m = map(int, input().split())
    if not n:
      break

    lst = [list(map(int,input().split()))[1:] for _ in range(3)]
    inds = [-1 for i in range(n)]

    for i in range(3):
      for j in lst[i]:
        inds[j - 1] = i
    
    ans = INF
    for p in [0, 2]:
      rec = 0
      for i in range(n):
        pi = inds[i]
        if abs(pi - p) == 2:
          rec += full_move2(n - i)
        elif abs(pi - p) == 1:
          rec += half_move(n - i)
          p = (p + 2) % 4
      if rec < ans:
        ans = rec

    if ans <= m:
      print(ans)
    else:
      print(-1)

solve()


Measured memory_bytes: 5612
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long x = Long.parseLong(sc.next());
    long y = 100;
    int i = 0;
    while (!(y >= x)) {
      i++;
      y *= 1.01d;
    }
    pw.println(i);
  }
}


Measured memory_bytes: 35800
a,b,c,d=gets.split.map &:to_i
e=a<c ? 0:1
f=b<d ? 0:1
h=[?R,?L]
g=[?U,?D]
m=(c-a).abs
l=(d-b).abs
a,b,c,d=[g[f],g[1-f],h[e],h[1-e]]
puts a*l+c*m+b*l+d*m+d+a*l+a+c*m+c+b+c+b*l+b+d*m+d+a

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

int main(){
	string s;
	cin >> s;
	int N = s.size();
	vector<ll> a(N+1);
	vector<ll> b(N+1);
	
	ll count = 0;
	a[0] = 0;
	b[0] = 0;
	
	rep(i,N){
		if(s[i] == '<'){
			count++;
			a[i+1] = count;
		}
		if(s[i] == '>'){
			count = 0;
			a[i+1] = count;
		}
	}
	
	reverse(s.begin(),s.end());
	
	count = 0;
	rep(i,N){
		if(s[i] == '>'){
			count++;
			b[i+1] = count;
		}
		if(s[i] == '<'){
			count = 0;
			b[i+1] = count;
		}
	}
	
	reverse(b.begin(),b.end());
	
	vector<int> ans(N+1);
	ll sum = 0;
	rep(i,N+1){
		ans[i] = max(a[i],b[i]);
		sum += ans[i];
	}
	
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 10628
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	if (A>8 || B>8){
		cout<<":("<<endl;
		return 0;
	}
	if (A+B<=16){
		cout<<"Yay!"<<endl;
		return 0;
	}
	cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

int run(std::vector<int> vec, int level, boost::multi_array<int, 2>& result)
{
	if (vec.size() == 2)
	{
		result[vec[0]][vec[1]] = result[vec[1]][vec[0]] = level;
		return level;
	}
	if (vec.size() == 3)
	{
		result[vec[0]][vec[1]] = result[vec[1]][vec[0]] = level;
		result[vec[1]][vec[2]] = result[vec[2]][vec[1]] = level;
		result[vec[2]][vec[0]] = result[vec[0]][vec[2]] = level + 1;
		return level + 1;
	}
	std::vector<int> group[2];
	int g = 0;
	for (auto index : vec)
	{
		group[g].emplace_back(index);
		g = 1 - g;
	}
	for (auto a : group[0])
	{
		for (auto b : group[1])
		{
			result[a][b] = result[b][a] = level;
		}
	}
	return std::max(run(std::move(group[0]), level + 1, result), run(std::move(group[1]), level + 1, result));
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto i : boost::irange(0, N))
	{
		vec[i] = i;
	}
	boost::multi_array<int, 2> result(boost::extents[N][N]);
	auto level = run(std::move(vec), 1, result);
	for (int i : boost::irange(0, N))
	{
		for (int j : boost::irange(i + 1, N))
		{
			std::cout << result[i][j] << " ";
		}
		std::cout << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 1536
n, m = map(int, input().split())
g = [set() for _ in range(n)]
group_ids = [0] * n

while m:
    s, t = map(int, input().split())
    g[s].add(t)
    g[t].add(s)
    m -= 1


def search(s, gid):
    global g, group_ids
    queue = set(g[s])
    group_ids[s] = gid

    while queue:
        i = queue.pop()
        if not group_ids[i]:
            group_ids[i] = gid
            queue.update(g[i])


gid = 1
for i in range(n):
    if group_ids[i]:
        continue
    search(i, gid)
    gid += 1

q = int(input())
while q:
    s, t = map(int, input().split())
    gs, gt = group_ids[s], group_ids[t]
    print('yes' if gs and gt and gs == gt else 'no')
    q -= 1

Measured memory_bytes: 40680
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

int main()
{
    IOS
    string s,t;
    int n;
    cin>>n;
    string u="";
    cin>>s>>t;
    REP(i,n)
    {
        u+=s[i];
        u+=t[i];
    }
    cout<<u<<endl;
}   

Measured memory_bytes: 256
##13日後のやつを10日後に
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)
last=[-1]*26

ss=0
for i in range(d):
    ind=-1
    smx=-10**10
    for j in range(26):
        ssj=ss+s[i][j]-c[j]*min(10,d-i-1)
        for k in range(26):
            if k!=j:
                ssj-= c[k]*(i-last[k]+min(10,d-i-1))
        if smx<ssj:
            smx=ssj
            ind=j
    last[ind]=i
    ss+=s[i][ind]
    for k in range(26):
        if k!=ind:
            ssj-= c[k]*(i-last[k])
    print(ind+1)








Measured memory_bytes: 74504
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

def kaijo(n):
  if n <= 0:
    return 0
  else:
    ret = 1
    for i in range(n):
      ret *= (i+1)
    return ret

num_p, num_q = 0, 0
done = []
for i in range(N):
  num = 0
  for j in range(len(done)):
    if done[j] < P[i]:
      num += 1
    else:
      pass
  #num_p += kaijo(N-(i+1)-num) * (P[i] - 1)
  num_p += kaijo(N-(i+1)) * (P[i] - num)
  done.append(P[i])

done = []
for i in range(N):
  num = 0
  for j in range(len(done)):
    if done[j] < Q[i]:
      num += 1
    else:
      pass
  num_q += kaijo(N-(i+1)) * (Q[i] - num)
  done.append(Q[i])

print(abs(num_p - num_q))


Measured memory_bytes: 3064
#include <iostream>

int main() {
	int N; long long D; std::cin >> N >> D;
	long long x, y;
	int count{ 0 };
	for (auto i{ 0 }; i < N; ++i) {
		std::cin >> x >> y;
		if (x * x + y * y <= D * D) ++count;
	}
	std::cout << count << std::endl;

	return 0;
}


Measured memory_bytes: 3632
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()
  l.sort()

  ans=l[0]
  for x in l[1:]:
    ans*=x

    if ans>10**18:
      return -1

  return ans

# main()
print(main())


Measured memory_bytes: 24128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	cin>>n>>k;
	ll h[200020];
	for(int i=0; i<n; i++){
		cin>>h[i];
	}
	sort(h, h+n);
	ll ans=0;
	for(int i=0; i<n-k; i++){
		ans+=h[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int n,t[105],m,p,x,sum;
	while(~scanf("%d",&n)){
		sum = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d",&t[i]);
			sum += t[i];
		}
		scanf("%d",&m);
		for(int i = 1;i <= m;i++){
			scanf("%d %d",&p,&x);
			printf("%d\n",sum - t[p] + x);
		}
	}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
#include <bitset>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, K;
int nums[5009];
bitset<8192> L[5009], R[5009];
ll LT[5009], RT[5009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    rep(i,N) cin>>nums[i];
    
    L[0][0]=1;
    R[N+1][0]=1;
    rep(i,N){
        bitset<8192> T=L[i];
        T<<=nums[i];
        L[i+1]=L[i]|T;
        if(L[i].count()!=T.count()) L[i+1][8191]=1;
        LT[i+1]=LT[i]+nums[i];
    }
    rrep(i,N-1){
        bitset<8192> T=R[i+2];
        T<<=nums[i];
        R[i+1]=R[i+2]|T;
        if(R[i+2].count()!=T.count()) R[i+1][8191]=1;
        RT[i+1]=RT[i+2]+nums[i];
    }
    
    int ret=0;
    rep(i,N){
        ll LB=max(0,K-nums[i]);
        ll RB=K-1;
        deque<int> AA,BB;
        rep(x,8192) if(R[i+2][x]) AA.push_back(x);
        int hoge=1;
        rep(x,8192) if(L[i][x]){
            ll LB2=LB-x, RB2=RB-x;
            while(AA.size()&&AA.back()>=LB2) BB.push_front(AA.back()), AA.pop_back();
            while(BB.size()&&BB.back()>RB2) BB.pop_back();
            if(BB.size()){
                hoge=0;
                break;
            }
        }
        ret+=hoge;
    }
    cout1(ret);
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int iu=1e6;
const int M=iu+1;
const int N=2e5+1;
int n;
ll a[N];
ll f[M];
ll u[M];
ll s1[M],s2[M];
ll pw(ll x,ll y){
	if(y==0) return 1;
	if(y%2) return x*pw(x,y-1)%mod;
	ll res=pw(x,y/2);
	return res*res%mod;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		s1[a[i]]=(s1[a[i]]+a[i])%mod;
		s2[a[i]]=(s2[a[i]]+a[i]*a[i])%mod;
	}
	ll ans=0;
	for(int i=1; i<=iu ;i++){
		u[i]=(u[i]+pw(i,mod-2))%mod;
		for(int j=i+i; j<=iu ;j+=i){
			s2[i]=(s2[i]+s2[j])%mod;
			s1[i]=(s1[i]+s1[j])%mod;
			u[j]-=u[i];
		}
		ans=(ans+u[i]*(s1[i]*s1[i]%mod-s2[i]))%mod;
		ans=(ans+mod)%mod;
	}
	cout << ans*(mod+1)/2%mod << '\n';
	
}

Measured memory_bytes: 26880
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl; else cout << b - a << endl;
}


Measured memory_bytes: 256
int M[10000][720],C[10000],T[10000];
int main(r,q,t,u,m,s){
	for(;scanf("%d%d",&r,&q),r;){
		memset(M,0,7200000*4);
		memset(T,0xff,10000*4);
		for(scanf("%d",&r);r;r--){
			scanf("%d%d%d%d",&t,&m,&m,&s);
			if(T[m]==-1)T[m]=t-540;
			if(s)C[m]++;
			else{
				C[m]--;
				if(!C[m]){
					for(q=T[m];q<t-540;q++)M[m][q]=1;
					T[m]=-1;
				}
			}
		}
		for(scanf("%d",&q);q;q--){
			scanf("%d%d%d",&t,&u,&m);
			for(r=0;t<u;t++)
				if(M[m][t-540])r++;
			printf("%d\n",r);
		}
	}
	return 0;
}

Measured memory_bytes: 27000
n = int(input())
trng = [0]+list(map(int,input().split()))+[0]
vlim = [0]+list(map(int,input().split()))+[0]
n += 2
smt = sum(trng)
table = [[-1 for i in range(smt*2+1)] for j in range(n)]
acc = 0
for i in range(n):
  if i == 0:
    for j in range(smt*2+1):
      table[i][j] = j/2
  elif i == n-1:
    for j in range(smt*2+1):
      table[i][j] = smt-table[0][j]
  else:
    v = vlim[i]
    t = trng[i]
    for j in range(acc):
      table[i][j] = v+(acc-j)/2
    for j in range(acc,acc+t*2+1):
      table[i][j] = v
    acc += t*2
    for j in range(acc+1,smt*2+1):
      table[i][j] = v+(j-acc)/2
ans = 0
ansls = list(zip(*table))
for arr in ansls:
  ans += min(arr)*0.5
print(ans)

Measured memory_bytes: 154248
#include <iostream>

bool is_complete(int*);

int solve(int *, int);
void rot(int*, int);

int min(int*);
void swap(int&, int&);

int main(){
	int N;
	int **p;
	std::cin >> N;
	p = new int*[N];
	for(int i=0; i<N; i++){
		p[i] = new int[30];
		for(int j=0; j<30; j++)
			std::cin >> p[i][j];
	}
	for(int i=0; i<N; i++)
		std::cout << solve(p[i], 0) << std::endl;
}

bool is_complete(int* p){
	int cmp=p[0];
	for(int i=0; i<30; i++){
		if(i == 9)
			cmp = p[9];
		else if(i == 12)
			cmp = p[12];
		else if(i == 15)
			cmp = p[15];
		else if(i == 18)
			cmp = p[18];
		else if(i == 21)
			cmp = p[21];
		else if(cmp != p[i])
			return false;
	}
	return true;
}

int solve(int *p, int cnt){
	if(cnt == 9 || is_complete(p))
		return cnt;
	int ans[4];
	for(int i=0; i<4; i++){
		rot(p, i);
		if(is_complete(p))
			ans[i] = cnt+1;
		else
			ans[i] = solve(p, cnt+1);
		rot(p, i);
	}
	return min(ans);
}

void rot(int* p, int dir){
	if(dir == 0){
		swap(p[6], p[21]);
		swap(p[7], p[22]);
		swap(p[8], p[23]);
		swap(p[9], p[11]);
		swap(p[12], p[17]);
	}else if(dir == 1){
		swap(p[0], p[27]);
		swap(p[1], p[28]);
		swap(p[2], p[29]);
		swap(p[18], p[20]);
		swap(p[14], p[15]);
	}else if(dir == 2){
		swap(p[0], p[23]);
		swap(p[3], p[26]);
		swap(p[6], p[29]);
		swap(p[15], p[17]);
		swap(p[9], p[20]);
	}else{
		swap(p[2], p[21]);
		swap(p[5], p[24]);
		swap(p[8], p[27]);
		swap(p[12], p[14]);
		swap(p[11], p[18]);
	}
}

int min(int* a){
	int ans = a[0];
	for(int i = 1; i<4; i++)
		if(ans > a[i])
			ans = a[i];
	return ans;
}

void swap(int& a, int& b){
	int tmp = a;
	a = b;
	b = tmp;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    int n,p[110],dp[101][101];
    cin >> n;
    for (int i = 1;i <= n;i++) {
        cin >> p[i - 1] >> p[i];
        dp[i][i] = 0;
    }
    for (int l = 2; l <= n;l++) {
        for (int i = 1;i <= n - l + 1;i++) {
            int j = i + l - 1;
            dp[i][j] = (1 << 21);
            for (int k = i; k <= j - 1;k++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << dp[1][n] << endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010], B[200010];
    cin >> N;
    rep(i,0,N) cin >> A[i] >> B[i];
    ll ans = INF;
    ll sum = 0;
    rep(i,0,N){
        sum += A[i];
        if(A[i] > B[i]){
            ans = min(ans, B[i]);
        }
    }
    if(ans == INF){
        print(0);
    }else{
        print(sum - ans);
    }

    
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, K; cin >> N >> K;
    int cnt = 0;
    while(N > 0){
        N /= K;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;

int main() {
	ll n;
	string s;
	cin >> n;
	cin >> s;
	int c = 0;
	for (ll i = 0; i < n-1; i++)
	{
		if (s[i] == s[i + 1])c++;
	}
	cout << n - c;

}

Measured memory_bytes: 512
# https://atcoder.jp/contests/abc053/tasks/arc068_a
# C - X: Yet Another Die Game
import math
n = int(input().split()[0])

c = math.floor(n / 11) * 2

if n % 11 == 0:
    pass
elif n % 11 <= 6:
    c += 1
elif n % 11 > 6:
    c += 2

print(int(c))


Measured memory_bytes: 3060
#include<stdio.h>

int partition(int a[], int p, int r){
	int i = p - 1;
	int x = a[r];
	for (int j = p; j < r; j++){
		if (a[j] <= x){
			i++;
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
	int tmp = a[i+1];
	a[i+1] = a[r];
	a[r] = tmp;
	return i+1;
}

int main(){
	int n;
	scanf("%d", &n);
	int A[1000000];
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	int c = partition(A, 0, n-1);
	for (int i = 0; i < n; i++){
		if (i == c) printf("[");
		printf("%d", A[i]);
		if (i == c) printf("]");
		if (i < n-1) printf(" ");
	}
	printf("\n");
}


Measured memory_bytes: 3020
import java.util.*;
public class Main {

	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), Q = sc.nextInt();
		int section[][] = new int[M][2];
		for(int i=0;i<M;i++) {
			section[i][0]= sc.nextInt() - 1; //L
			section[i][1]= sc.nextInt() - 1; //R
		}
		int queries[][] = new int[Q][2];
		for(int i=0;i<Q;i++) {
			queries[i][0] = sc.nextInt() - 1;
			queries[i][1] = sc.nextInt() - 1 ;
		}
		sc.close();
		
		
		int sectionTable[][] = new int[N][N];
		for(int i=0;i<M;i++) {
			int l = section[i][0];
			int r = section[i][1];
			sectionTable[l][r] += 1;
		}
		
		//二次元累積和
		int sum [][] = new int[N][N];
		sum[0][0]=sectionTable[0][0];
		for(int i=0;i<N-1;i++) {
			sum[i+1][0] = sum[i][0]+sectionTable[i+1][0];
			sum[0][i+1] = sum[0][i]+sectionTable[0][i+1];
		}
		
		for(int l = 0;l<N-1;l++) {
			for(int r = 0;r<N-1;r++) {
				sum[l+1][r+1] = sum[l][r+1] + sum[l+1][r] - sum[l][r] + sectionTable[l+1][r+1];
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<Q;i++) {
			int ql = queries[i][0];
			int qr = queries[i][1];
			int ans = 0;
			if(ql==0) ans = sum[qr][qr];
			else ans = sum[qr][qr]-sum[qr][ql-1]-sum[ql-1][qr] + sum[ql-1][ql-1];
			sb.append(ans + "\n");
		}
		
		System.out.println(sb.toString());
		
	}
}

Measured memory_bytes: 163112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

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

	cout << max(0, c - (a - b)) << endl;

}

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

int main() {
int A,B,C,X;
cin>>A>>B>>C>>X;
int res;
  
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        int total =500*a+100*b+50*c; //合計
        if (total==X)++res;
      }
    }
  }
  cout<<res<<endl;
        
}

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

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> a(n), l(n), r(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    l[0] = a[0];
    for (int i = 1; i < n; i++) {
        l[i] = gcd(l[i-1], a[i]);
    }
    r[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--) {
        r[i] = gcd(r[i+1], a[i]);
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = max(ans, r[1]);
        } else if (i == n-1) {
            ans = max(ans, l[n-2]);
        } else {
            ans = max(ans, gcd(l[i-1], r[i+1]));
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 > 21) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

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


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

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

        vector<vector<ll> > dp(n + 1, vector<ll>(2, 0));
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j ^ (a[i] & 1)] += dp[i][j];
            }
        }
        cout << dp[n][p] << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    go;
    int a,b;
    cin>>a>>b;
    if(a<b)
        while(b--)
        cout<<a;
    else
        while(a--)
        cout<<b;
    return 0;
}


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

using namespace std;
const long long mod = 1e9+7;

int main(){
	int N, M;
	cin >> N >> M;
	vector<int>oks(N+1, true);
	
	for(int i=0; i<M; ++i){
		int a;
		cin >> a;
		oks[a] = false;
	}
	vector<long long int>dp(N+1, 0);
	dp[0] = 1;
	if(oks[1]==true) dp[1] = 1;
	for(int i=2; i <=N; i++){
		if(oks[i]==true){
			dp[i]=(dp[i-1]+dp[i-2])%mod;
		}
	}

	cout << dp[N] << endl;


}


Measured memory_bytes: 1408
N,M = list(map(int,input().split()))
AB = []
for i in range(N):
    tempA,tempB = list(map(int,input().split()))
    AB.append([tempA,tempB])
AB = sorted(AB,key=lambda x:x[0])

pon = 0
cost = 0
cnt = 0

while pon < M:
    for i in range(AB[cnt][1]):
        if pon < M:
            cost += AB[cnt][0]
            pon += 1
        else:
            break
    cnt += 1

print(cost)

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


int main() {
  unsigned long long h;
  int k = 0;
  unsigned long long ans = 1;
  cin >> h;
  while (h > 0) {
    h = h>>1;
    k += 1;
    ans *= 2;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


N, K = MI()
AB = [tuple(MI()) for _ in range(N)]
AB.sort()

cnt = 0
for a, b in AB:
    if K <= cnt + b:
        print(a)
        exit(0)
    cnt += b


Measured memory_bytes: 56348
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;
int i, j, k;
long long ans = 0;
int main() {
	int N;
	cin >> N;
	int A[100001];
	rep(i, N) {
		int tmp;
		cin >> tmp;
		A[tmp] = i;
	}
	for (i = 1; i <= N; i++) {
		cout << A[i]+1 << " ";
	}
	return 0;
}

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

long long N, K;
vector<long long> sumV(100001);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

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

  if(a + b == c || b + c == a || c + a == b){
    cout << "Yes" <<endl;
  } else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 1024