akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    a = LI()
    a.sort()
    x = list(set(a))
    if len(x) > 3:
        print("No")
        return
    d = defaultdict(int)
    for i in a:
        d[i] += 1
    if len(x) == 3:
        x1 = d[x[0]]
        x2 = d[x[1]]
        x3 = d[x[2]]
        if ((x[0] ^ x[1] ^ x[2]) == 0) and (x1 == x2 == x3):
            print("Yes")
        else:
            print("No")
    elif len(x) == 2:
        x1 = d[0]
        x2 = d[x[1]]
        if x1 * 2 == x2:
            print("Yes")
        else:
            print("No")
    elif len(x) == 1:
        if x[0] == 0:
            print("Yes")
        else:
            print("No")
    return

#B
def B():
    n, m = LI()
    if m % 2:
        print(-1)
        return
    edg = [[] for _ in range(n)]
    ins = defaultdict(int)
    c = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
        ins[a] += 1
        ins[b] += 1
    dag = [[] for _ in range(n)]
    q = deque()
    q.append((0, -1))
    for i in edg[0]:
        q.append((i, 0))
    while q:
        now, per = q.pop()
        if per == -1:
            continue
        if c[now]:
            pass
        
    for d in dag:
        if len(d) % 2:
            print(-1)
            return
    for num, d in enumerate(dag):
        for x in d:
            print(num + 1, x + 1)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 58992
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> h(n);
    rep(i, n){
        cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<int>());
    long long tot = 0;
    for(int i = k; i < n; i++){
        tot += h[i];
    }
    cout << tot << endl;
    return 0;
}

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

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nq = in.readLineAsIntArray();
        final int N = nq[0];
        final int Q = nq[1];
        final String S = in.readLine();

        int[] countAc = new int[N];
        countAc[0] = 0;
        for(int i=1; i<N; i++){
            countAc[i] = countAc[i - 1];
            if(S.charAt(i-1) == 'A' && S.charAt(i) == 'C'){
                countAc[i] += 1;
            }
        }

        for(int i=0; i<Q; i++){
            int[] lr = in.readLineAsIntArray();
            int l = lr[0];
            int r = lr[1];
            System.out.println(countAc[r - 1] - countAc[l - 1]);
        }
    }




    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 49668
#include<bits/stdc++.h>
#define watch(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(), x.end()
#define rep(n) for(int i = 0; i < n; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
using namespace std;


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

    vector<int> a(n), b(n), c(n);
    vector<vector<int>> dp(n, vector<int>(3));

    for(int i = 0; i < n; i++)
        cin>>a[i]>>b[i]>>c[i];

    dp[0] = { a[0], b[0], c[0] };

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

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

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    rep(i, INF) {
        if(i % 2 == 0) {
            C -= B;
            if(C <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            A -= D;
            if(A <= 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3636
A,B,AB,X,Y=map(int,input().split())
ANS=0
if A + B >= AB * 2:
  if min(X,Y) == X:
    # X < Y
    ANS = AB * X * 2
    R = Y - X if Y - X > 0 else 0
   
    if B <= AB * 2:
      ANS += B * R
    else:
      ANS += AB * 2 * R
  else:
    # X > Y
    ANS = AB * Y * 2
    R = X - Y if X - Y > 0 else 0
    if A <= AB * 2:
      ANS += A * R
    else:
      ANS += AB * 2 * R
else:
  ANS = A * X + B * Y
print(ANS)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1],s=0;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		ar[i]=ar[i]%mod;
		s=(s+ar[i])%mod;
	}

	ll an=0;
	for(i=1;i<=n;i++){
		s=(s-ar[i]+mod)%mod;
		an=(an%mod+(s*ar[i])%mod)%mod;
	}
	cout<<an<<endl;
	return 0;	
}

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

rl_cnt = 0
for s1,s2 in zip(s[:-1],s[1:]):
    if s1 == 'R' and s2 == 'L':
        rl_cnt += 1

left_happy = 1 if s[0] == 'R' else 0
right_happy = 1 if s[-1] == 'L' else 0

first_happy = n - rl_cnt*2 -2 + left_happy + right_happy
# print(first_happy)
if k <= rl_cnt:
    ans = first_happy + k*2
else:
    rem = k-rl_cnt
    ans = first_happy + rl_cnt*2 + min(rem, 2-left_happy+right_happy)

print(min(ans,n-1))

Measured memory_bytes: 73636
strings = input().split(' ')
A = int(strings[0])
B = int(strings[1])

i = min(A,B)
m = max(A,B)
n = min(A,B)
while 1:
    mt = n
    n = m % n
    m = mt
    if n == 0:
        break
if m != 0:
    print(A*B//m)
else:
    print(A*B)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N,P;
	cin>>N>>P;
	ll sumb = 0;
	vector<ll> vs;
	rep(i,N){
		ll w,b;
		cin>>w>>b;
		sumb += b;
		vs.pb(P*b+(100-P)*w);
	}
	sort(all(vs),greater<ll>());
	ll sum = 0;
	rep(i,N){
		sum += vs[i];
		if(sum >= P*sumb){
			cout<<i+1<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    vector <int> a(3);
    forn (i, 0, 3)
        cin >> a[i];
    int ans = INT_MAX;
    forn (i, 0, 3)
        forn (j, i + 1, 3)
             ans = min(ans, a[i] + a[j]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char **argv)
{
  int h1, w1, h2, w2;
  scanf("%d %d\n", &h1, &w1);
  scanf("%d %d\n", &h2, &w2);
  printf("%d\n", (h1-h2)*(w1-w2));
  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = x / 500;
        int b = (x - a*500)/5;
        System.out.print(1000*a+5*b);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int coin(llong me,double k){
    int i;
    for(i=16;i>=-1;i--){
        if(k/me > 1<<i){
            break;
        }
    }
    return i+1;
}

int main(){
    double n,k,ans=0.0;
    cin >> n >> k;
    if(n>=k){
        for(llong i=1;i<k;i++){
            ans += 1/(double)(1<<coin(i,k));
        }
        for(llong i=k;i<=n;i++) ans += 1;
        ans *= 1/n;
    }else{
        for(llong i=1;i<=n;i++){
            ans += 1/(double)(1<<coin(i,k));
        }
        ans *= 1/n; 
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

def main():
  rev = False
  s = deque(input())
  q = int(input())
  query = tuple(input() for i in range(q))

  for i in range(q):
    temp = query[i].split()
    if int(temp[0]) == 1:
      rev = not rev
    else:
      if (int(temp[1]) == 1 and (not rev)) or (int(temp[1]) == 2 and rev):
        s.appendleft(temp[2])
      else:
        s.append(temp[2])

  if rev:
    s.reverse()

  print(''.join(s))

if __name__ == '__main__':
  main()


Measured memory_bytes: 21176
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long N = long.Parse(Console.ReadLine());
            var P = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long count = 0;
            long min = 10000000000;
            for(var i=0;i<N;i++){
                if(min>P[i]){
                    min = P[i];
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    } 
}

Measured memory_bytes: 31836
program main
integer :: ans = 0
character*100 :: s
read(*,*)s
s = trim(s)
do i = 1,len(s)
if (mod(i,2)==1) then
if (s(i:i) == 'L') ans = 1
else
if (s(i:i) == 'R') ans = 1
end if
end do
if (ans == 0) then
write(*,*)'Yes'
else
write(*,*)'No'
end if
end program

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

int main()
{
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else{
        rep(i, 0, a.size()){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


int main()
{
  string a,b; cin >> a >> b;
  int j = 0;
  if(a.length() < b.length()){
    j = 2;
    goto end;
  }else if(a.length() > b.length()){
    j = 1;
    goto end;
  }else{
    rep(i,a.length()){
      if(a[i] - '0'< b[i]-'0'){
        j = 2;
        goto end;
      }else if(a[i] - '0'> b[i]-'0'){
        j = 1;
        goto end;
      }
    }
  }

  end:
  if(j == 0) cout << "EQUAL";
  else if(j == 1) cout << "GREATER";
  else if(j == 2) cout << "LESS";
    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int,input().split())
l = []
r = []
for i in range(m):
    line = list(map(int,input().split()))
    l.append(-line[0])
    r.append(line[1])
heapq.heapify(l)
heapq.heapify(r)
l_max = - heapq.heappop(l)
r_min = heapq.heappop(r)
if l_max > r_min:
    print(0)
else:
    print(r_min-l_max+1)

Measured memory_bytes: 72536
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int x,y,z,a,b;	//椅子、人幅、隙間
	
	cin >> x >> y >> z;
	
	a = x / (y + z);
	b = x % (y + z);
	if(b < z) a--;
	
	cout << a;
	
	return 0;
	
}


Measured memory_bytes: 256
N , K = map(int,input().split())
d = [0]*K
A = [0]*K
for i in range(K):
  d[i] = int(input())
  A[i] = list(map(int,input().split()))
people = []
for i in range(K):
  for j in range(len(A[i])):
    people.append(A[i][j])
num = set(people)
print(N - len(num))


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

const int V=100005;
vector<int> to[2*V];
bool visited[2*V];
vector<int> cnt(2);

void dfs(int i)
{
    if (visited[i]) return;
    visited[i] = true;
    cnt[i/V]++;
    for (auto next: to[i]) dfs(next);
}

int main()
{
    int n;
    cin >> n;
    rep(i,n)
    {
        int x, y;
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    ll ans = 0;
    rep(i, V*2)
    {
        if (visited[i]) continue;
        cnt = {0, 0};
        dfs(i);
        ans += (ll) cnt[0] * cnt[1];
    }
    ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 10240
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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












ll POW(ll n, ll m, ll p){
    ll res = 1, x = n;
    for(ll i = m; i > 0; i >>= 1){
        if(i & 1){
            res *= x;
            res %= p;
        }
        x *= x;
        x %= p;
    }
    return res;
}



const ll table_size = 200005;
ll fact[table_size], finv[table_size], inv[table_size];

// 前処理
void make_table(ll mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll comb(ll n, ll r, ll mod){
    if(n < r || n < 0 || r < 0) return 0;
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}

ll mod_inv(ll x){
    return POW(x, MOD - 2, MOD);
}


int main(){
    make_table(MOD);
    
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    
    ll ans = 0;
    for(ll m = n; m < 2 * n; m++){
        ll x = (comb(m - 1, n - 1, MOD) * 
               ((POW(a * mod_inv(a + b) % MOD, n, MOD) * POW(b * mod_inv(a + b) % MOD, m - n, MOD) % MOD) +
                (POW(b * mod_inv(a + b) % MOD, n, MOD) * POW(a * mod_inv(a + b) % MOD, m - n, MOD) % MOD)) % MOD) % MOD;
        ll y = ((m * 100 % MOD) * mod_inv(a + b)) % MOD;
        ans += x * y % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<cstdio>

using namespace std;

int main()
{
	double d;
	while(scanf("%lf",&d)!=EOF)
	{
		if(d<=48.00)
		{
			printf("light fly\n");
		}
		else if(d<=51.00)
		{
			printf("fly\n");
		}
		else if(d<=54.00)
		{
			printf("bantam\n");
		}
		else if(d<=57.00)
		{
			printf("feather\n");
		}
		else if(d<=60.00)
		{
			printf("light\n");
		}
		else if(d<=64.00)
		{
			printf("light welter\n");
		}
		else if(d<=69.00)
		{
			printf("welter\n");
		}
		else if(d<=75.00)
		{
			printf("light middle\n");
		}
		else if(d<=81.00)
		{
			printf("middle\n");
		}
		else if(d<=91.00)
		{
			printf("light heavy\n");
		}
		else
		{
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,S;
  cin>>N>>S;
  int fans=-1;
  int qw;
  if(N==S)fans=N+1;
  for(int i=2;i*i<=N&&fans==-1;i++){
    int ans=0;
    int x=N;
    while(x){
      ans+=x%i;
      x/=i;
    }
    if(ans==S)fans=i;
    qw=i;
  }
  if(fans==-1){
    int mk=N/(qw+1);
    for(int i=mk;i>0&&fans==-1;i--){
      int am=N%(N/(i+1)+1);
      if((am+i-S)%i==0&&((am+i-S)/i)>=0&&S-i>=0)fans=N/(i+1)+1+(am+i-S)/i;
    }
  }
  cout<<fans<<endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;

struct UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind(int _size) : data(_size, -1) {}
	
	bool unite(int _x, int _y) {
		_x = root(_x); _y = root(_y);
		if (_x != _y) data[_x] += data[_y]; data[_y] = _x;
		return _x != _y;
	}
	
	bool same(int _x, int _y) { return root(_x) == root(_y); }
	
	int root(int _x) { return data[_x] < 0 ? _x : data[_x] = root(data[_x]); }
	
	int size(int _x) { return -data[root(_x)]; }
};

int N, Q, p[100010];
char q[100010];
int mark[100010], v[100010];
lint anc[100010];

void solve() {
	UnionFind uf(N);
	
	for_(i,0,N) if (!mark[i]) uf.unite(p[i], i);
	
	lint ans = 0;
	
	for_rev(i,Q-1,0) {
		if (q[i] == 'M') {
			--mark[ v[i] ];
			if (!mark[ v[i] ]) uf.unite(p[ v[i] ], v[i]);
		} else {
			ans += uf.root(v[i]) + 1;
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (scanf("%d %d", &N, &Q), N) {
		for_(i,1,N) {
			scanf("%d", &p[i]); --p[i];
		}
		
		minit(mark, 0);
		mark[0] = 1;
		
		for_(i,0,Q) {
			scanf("%s %d", &q[i], &v[i]); --v[i];
			if (q[i] == 'M') ++mark[ v[i] ];
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 2888
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int N = si();
  std::vector<ll> a(N);
  ll mini=1e9+7,result=-10;
  for (size_t i = 0; i < N; i++) {
    cin >> a[i];
  }
  VSORT(a);
  if(N==2) {
    result = a[1];
    cout << result << endl;
    return 0;
  }

  std::vector<ll> ret0;
	for(ll i=1 ; i*i<=a[0] ; ++i)
	{
		if(a[0]%i == 0)
		{
			ret0.push_back(i);
			if(i!=1 && i*i!=a[0])
			{
				ret0.push_back(a[0]/i);
			}
		}
	}
  ret0.push_back(a[0]);

  std::vector<ll> ret1;
	for(ll i=1 ; i*i<=a[1] ; ++i)
	{
		if(a[1]%i == 0)
		{
			ret1.push_back(i);
			if(i!=1 && i*i!=a[1])
			{
				ret1.push_back(a[1]/i);
			}
		}
	}
  ret1.push_back(a[1]);
  VSORT(ret0);VSORT(ret1);
  // cout << ret0.size()-1 << endl;
  for (int i = ret0.size()-1; i >= 0; i--) {
    // cout << i << endl;
    int count=0;
    for (size_t j = 1; j < N; j++) {
      if(a[j]%ret0[i]) {
        count++;
        if(count == 2) {
          break;
        }
      }
    }
    // cout << ret0[i] << " : " << count << endl;
    if(count!=2) {
      result = ret0[i];
      // cout << result << endl;
      break;
    }
  }

  for (int i = ret1.size()-1; i >= 0; i--) {
    int count = 0;
    // cout << "OK" << endl;
    for (size_t j = 2; j < N; j++) {
      if(a[j]%ret1[i]) {
        count = 1;
        break;
      }
    }
    if(count!=1) {
      result = max(result,ret1[i]);
      break;
    }
  }
  // for (size_t i = 0; i < ret1.size(); i++) {
  //   cout << ret1[i] << endl;
  // }
  // for (size_t i = 0; i < ret0.size(); i++) {
  //   cout << ret0[i] << endl;
  // }
  cout << result << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

using ll = long long;

ll Sn(ll n) {
  ll k = 0;
  while(n > 0) {
    k += n % 10;
    n /= 10;
  }
  return k;
}

int main() {
  ll n;
  cin >> n;
  ll k = Sn(n);
  if (n % k == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;

}


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

int main(){
  int N;
  cin >> N;
  double p = 0;
  
  if(N % 2 == 0){
    p = (double)1/2;
    //cout << p << endl;
  }else{
    p = (double)(N+1) / (2*N);
  }
  
  cout << fixed << setprecision(10);
  cout << p << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
    ll a,b,c,d,x,y,z;
    cin >> a >> b >> c >> d;
    x = b/c - (a-1)/c;
    y = b/d - (a-1)/d;
    ll LCM = c*d/__gcd(c,d);
    z = b/(LCM) - (a-1)/(LCM);
    
    ll ans = (b - a + 1) - (x + y - z);
    cout << ans << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [0] + list(accumulate(list(map(int, input().split()))))
b = [0] + list(accumulate(list(map(int, input().split()))))
ans = 0

for i in range(n + 1):
    j = bisect_right(b, k - a[i])
    if a[i] + b[j - 1] <= k:
            ans = max(ans, i + (j - 1))
    
print(ans)

Measured memory_bytes: 128512
(()->begin
  n,m,q = readline() |> split |> x->parse.(Int,x)
  arr = fill([], q)
  for i in 1:q
    arr[i] = readline() |> split |> x->parse.(Int,x)
  end

  function dfs(n, m)
    result = []
    function dfs_walk(arr)
      if (length(arr) == n + 1)
        push!(result, arr[2:end])
        return;
      end
      push!(arr, arr[end])
      while (arr[end] <= m)
        dfs_walk(copy(arr))
        arr[end] += 1
      end
    end
    dfs_walk([1])
    return result
  end
  max = 0
  for comb in dfs(n, m)
    tmp = 0
    for (a,b,c,d) in arr
      if comb[b] - comb[a] == c
        tmp += d
      end
    end
    if tmp > max
      max = tmp
    end
  end
  println(max)
end)()


Measured memory_bytes: 231652
# D - Binomial Coefficients

import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
    
idx = bisect.bisect_left(a, a[-1]//2)
tmp = float("inf")

try:
    if idx != n-1:
        tmp = abs(a[idx]-a[-1]/2)
        ans = [a[-1], a[idx]]
    if abs(a[idx-1] - a[-1]/2) < tmp:
        tmp = abs(a[idx-1] - a[-1]/2)
        ans = [a[-1], a[idx-1]]
    if abs(a[idx+1] - a[-1]/2) < tmp and idx+1 != n-1:
        ans = [a[-1], a[idx+1]]
except IndexError:
    pass

print(*ans)

Measured memory_bytes: 14056
#include <stdio.h>


int main()
{
  int a, b, d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a/b;
  r = a%b;
  f = (double)a/(double)b;

  printf("%d %d %f\n", d, r, f);

  return 0;
}



Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<"   "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<"   "<<#y<<" "<<y<<"   "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define sz(x)	(ll)x.size()
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
//#define endl '\n'
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
    ll n;cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    ll count=0;
    ll max=0;
    for(ll i=0;i<n;i++){
        if(arr[i]>max)
        max=arr[i];
       if(arr[i]<max){
        count+=max-arr[i];
       }
    }
    cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 5172
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

s = ri()
summ = 0
for i in s:
    summ+=int(i)
if summ%9 == 0:
    Yes()
else:
    No()

Measured memory_bytes: 74832
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main(){
	//freopen("in.txt", "r", stdin);
	string s;
	cin >> s;
	int a[26] = {};
	rep(i, len(s)) a[s[i] - 'a'] ++;
	rep(i, 26) if(a[i] & 1){
		puts("No");
		return 0;
	} 
	
	puts("Yes");
	
	return 0;
}


Measured memory_bytes: 256
def main():
    n,cc=[int(i) for i in input().split()]
    rec=[]
    for i in range(n):
        s,t,c=[int(k) for k in input().split()]
        rec.append([float(s),float(t),c])
    slot=[[float(-1),-1] for i in range(cc)]
    rec.sort(key=lambda rec:rec[0])
    for r in rec:
        for k,s in enumerate(slot):
            tmp=0
            if s[1]!=r[2]:
                #チャンネルが違う
                tmp=r[0]
                r[0]=r[0]-0.5
            if s[0]<=r[0]:
                s[0]=r[1]
                s[1]=r[2]
                break
            r[0]=tmp
    print(len([i for i in slot if i[0]!=-1 and i[1]!=-1]))

if __name__=='__main__':
    main()


Measured memory_bytes: 19804
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,k; cin >>n>>k;
  vector<ll> p(n);
  rep(i,n)cin >>p[i];
  ll sum=0;
  sort(all(p));
  rep(i,k)sum+=p[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3692
listA = []
list_number = []
for i in range(3):
    list_number.append(list(map(int,input().split())))
listA.append([min(list_number[0]),min(list_number[1]),min(list_number[2])])
b1 = min(list_number[0][0],list_number[1][0],list_number[2][0])
b2 = min(list_number[0][1],list_number[1][1],list_number[2][1])
b3 = min(list_number[0][2],list_number[1][2],list_number[2][2])
listA.append([b1,b2,b3])
for i in range(3):
    list_number[i] = list(map(lambda x:x-listA[0][i],list_number[i]))
for j in range(3):
    B = set([list_number[0][j],list_number[1][j],list_number[2][j]])
    if len(B) == 1:
        pass
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;


int main() {
  string s, t; cin >> s; cin >> t;
  long long start = 0;
  long long ans = 0;
  string s2 = s + s;
  long long s_len = s.length();

  for (char c: t) {
    size_t found = s2.find(c, start);
    if (found == string::npos) {
      cout << -1 << endl;;
      return 0;
    }
    // cout << found << " " << c << endl;
    ans += (int)found - start + 1;
    start = (int)found + 1;
    if (start >= s_len) {
      start -= s_len;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
'use strict'

let Main = (input) => {
  let v = []
  v[0] = input.substr(0,1)
  v[1] = input.substr(1,1)
  v[2] = input.substr(2,1)
  let count = 0
  for(let i=0; i <= v.length-1; i++){
    if(v[i] == '1') count++
  }
  console.log(count)
}

Main(require("fs").readFileSync("/dev/stdin","utf8"))

Measured memory_bytes: 11468
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>
#include <utility>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> days { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
  string s;
  cin >> s;
  int idx = 0;
  for (int i = 0; i < days.size(); ++i) {
    if (days[i] == s) {
      idx = i;
      break;
    }
  }
  idx = (idx + 1) % days.size();
  int res = 1;
  while (days[idx] != "SUN") {
    idx = (idx + 1) % days.size();
    ++res;
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 256
n=int(input())
strli=[]
for i in range(n):
    li=list(input())
    strli.append(li)

strs=[]
for i in range (n):
    strli[i].sort()
    strs.append("".join(strli[i]))

cnt = {}
for i in range(n):
    if strs[i] in cnt:
        cnt[strs[i]] += 1
    else:
        cnt[strs[i]] = 1
ans = 0
for i in cnt:
    if cnt[i] >= 2:
        ans += int(cnt[i] * (cnt[i] -1) /2)

print(ans)

Measured memory_bytes: 40684
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int D, N;
	cin >> D >> N;

	if (D == 0)
	{
		if (N == 100) cout << 101 << endl;
		else cout << N << endl;
	}
	else if (D == 1)
	{
		if (N == 100) cout << 10100 << endl;
		else cout << N * 100 << endl;
	}
	else if(D == 2)
	{
		if (N == 100) cout << 1010000 << endl;
		else cout << N * 10000 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll p[300010];
ll q[300010];

int main(){
    int n1;
    cin >> n1;
    int n = 3*n1;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    priority_queue<ll>pq2;
    priority_queue<ll,vector<ll>,greater<ll> >pq;
    ll s = 0;
    for(int i=0;i<n;i++){
        if(i<n1){
            pq.push(a[i]);
            s += a[i];
            p[i] = s;
        }else{
            ll x = pq.top();
            if(x>a[i]){
                p[i] = s;
            }else{
                s-=x;
                pq.pop();
                s+=a[i];
                pq.push(a[i]);
                p[i] = s;
            }
        }
    }
    s = 0;
    for(int i=0;i<n;i++){
        if(i<n1){
            pq2.push(a[n-1-i]);
            s += a[n-1-i];
            q[n-1-i] = s;
        }else{
            ll x = pq2.top();
            if(x<a[n-1-i]){
                q[n-1-i] = s;
            }else{
                s-=x;
                pq2.pop();
                s+=a[n-1-i];
                pq2.push(a[n-1-i]);
                q[n-1-i] = s;
            }
        }
    }
    // rep(i,n){
    //     cerr  << p[i] << " ";
    // }
    // cerr << endl;
    
    // rep(i,n){
    //     cerr  << q[i] << " ";
    // }
    // cerr << endl;
    ll mx = -(1LL<<60);
    for(int i=n1-1;i<n-n1;i++){
        mx = max(mx,p[i]-q[i+1]);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 9460
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
X = list(map(int, input().split()))


def solve():
    ans = 0

    if N >= M:
        ans = 0
    else:
        x = sorted(X)
        diff_x = [0]*(M-1)
        for i in range(1, M):
            diff_x[i-1] = x[i] - x[i-1]

        diff_x = sorted(diff_x, reverse=True)
        ans = sum(diff_x[N-1:])
    return ans


print(solve())


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e9;

int n;

int main() {
   // 入力:
   cin >> n;
   vec<int> a(n);
   rep (i, n) { cin >> a[i]; }
   // 初期化
   vec<int> dp(n+1);
   fill(all(dp), INF);
   dp[0] = -1;

   repp (i, 1, n+1) {
      vec<int>::iterator ite = lower_bound(all(dp), a[i-1]);
      if (ite != a.end()) *ite = a[i-1];
   }
   int res = 0;
   rep (i, n+1) {
      if (dp[i] != INF) res = i;
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 3604
n,m=map(int,input().split())

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

X.sort()

C=[]
for i in range(m-1):
    c=abs(X[i+1]-X[i])
    C.append(c)

if(n>=m):
    print(0)
else:
    C.sort()
    sum_c=0
    for j in range(len(C)-n+1):
        sum_c+=C[j]
    print(sum_c)

Measured memory_bytes: 13960
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans = 0;
	string w;
	cin >> w;
	for (int i = 0; i < w.size(); i++)
	{
		if (isupper(w[i]))
		{
			w[i] = tolower(w[i]);
		}
	}
	string t;
	while (true)
	{
		cin >> t; 
		if (t == "END_OF_TEXT")break;

		for (int j = 0; j < t.size(); j++)
		{
			if (isupper(t[j]))
			{
				t[j] = tolower(t[j]);
			}
		}

		if (t == w){
			ans++;
		}
	}



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

Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  string str;
  int num[200005]={0};
  vector<int>right;
  vector<int>left;
  
  cin>>str;
  for(int i=0;i<str.size()-1;i++){
    if(str[i]=='R'&&str[i+1]=='L'){
      right.push_back(i);
    }else if(str[i]=='L'&&str[i+1]=='R'){
      left.push_back(i);
    }
  }
  left.push_back(str.size()-1);

  int border=0;
  for(int i=0;i<right.size();i++){
    for(int j=right[i];j>=border;j-=2){
      num[right[i]]++;
    }
    for(int j=right[i];j<=left[i];j+=2){
      num[right[i]]++;
    }
    num[right[i]]--;

    for(int j=right[i]+1;j>=border;j-=2){
      num[right[i]+1]++;
    }
    for(int j=right[i]+1;j<=left[i];j+=2){
      num[right[i]+1]++;
    }
    num[right[i]+1]--;
    
    border=left[i]+1;
  }

  for(int i=0;i<str.size()-1;i++){
    cout<<num[i]<<' ';
  }
  cout<<num[str.size()-1]<<endl;
  return(0);
}

Measured memory_bytes: 1916
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	}
}

Measured memory_bytes: 98676
package main

import (
	"fmt"
)

func main() {
	var K int
	fmt.Scan(&K)

	first := -1
	A := 7
	for i := 1; i <= K; i++ {
		A = A % K
		if A%K == 0 {
			first = i
			break
		}
		A = A*10 + 7
	}

	fmt.Println(first)
}

Measured memory_bytes: 1792