akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
int W, H;
int F, M, O;
int[][] G;

bool input() {
    scanf("%d %d", &W, &H);
    if (W == 0 && H == 0) return false;
    scanf("%d %d %d", &F, &M, &O);
    G = new int[][](H, W);
    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            scanf("%d", &G[i][j]);
        }
    }
    return true;
}

const INF = (1<<28);

int[][][][] Cache; 
static this() {
    Cache = new int[][][][](10, 10, 1 << 10, 50 + 1);
}

int dfs(int y, int x, int used, int roxy) {
    if (roxy <= 0) return INF;
    if (y == H - 1) return 0;
    if (roxy <= 1) return INF;
    if (Cache[y][x][used][roxy] >= 0) return Cache[y][x][used][roxy];
    int Ret = INF;
    if (G[y + 1][x] >= 0) {
        Ret = min(Ret, dfs(y + 1, x, 1 << x, min(M, roxy - 1 + G[y + 1][x])));
    } else {
        Ret = min(Ret, dfs(y + 1, x, 1 << x, roxy - 1) - G[y + 1][x]);
    }
    if (0 <= x - 1 && x - 1 < W) {
        if (used & (1 << (x - 1))) {
            Ret = min(Ret, dfs(y, x - 1, used, roxy - 1));
        } else {
            if (G[y][x - 1] >= 0) {
                Ret = min(Ret, dfs(y, x - 1, used | (1 << (x - 1)), min(M, roxy - 1 + G[y][x - 1])));
            } else {
                Ret = min(Ret, dfs(y, x - 1, used | (1 << (x - 1)), roxy - 1) - G[y][x - 1]);
            }
        }
    }
    if (0 <= x + 1 && x + 1 < W) {
        if (used & (1 << (x + 1))) {
            Ret = min(Ret, dfs(y, x + 1, used, roxy - 1));
        } else {
            if (G[y][x + 1] >= 0) {
                Ret = min(Ret, dfs(y, x + 1, used | (1 << (x + 1)), min(M, roxy - 1 + G[y][x + 1])));
            } else {
                Ret = min(Ret, dfs(y, x + 1, used | (1 << (x + 1)), roxy - 1) - G[y][x + 1]);
            }
        }
    }
    //[y, x, used, roxy].writeln;
    return Cache[y][x][used][roxy] = Ret;
}

void solve() {
    foreach (i; 0 .. 10) foreach (j; 0 .. 10) foreach (k; 0 .. (1 << W)) foreach (l; 0 .. 50 + 1) Cache[i][j][k][l] = -1;
    int Ans = INF;
    if (O <= 1) {
        writeln("NA");
        return;
    }
    foreach (int i; 0 .. W) {
        if (G[0][i] >= 0) {
            Ans = min(Ans, dfs(0, i, 1 << i, min(M, O - 1 + G[0][i])));
        } else {
            Ans = min(Ans, dfs(0, i, 1 << i, O - 1) - G[0][i]);
        }
    }
    writeln(Ans > F ? "NA" : Ans.to!string);
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 31936
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<double,double> pdd;
typedef pair<string,int> psi;
const int MOD = 1e9 + 7;

const int N = 200001;

int n;
string s;

int freq[200],cur[200];

int main(int argc , char *args[]) {
   // freopen("input.txt","r",stdin);
    cin >> n;
    memset(freq,-1,sizeof freq);
    for (int k = 0; k < n; ++k){
        cin >> s;
        memset(cur,0,sizeof cur);
        for (int j = 0 ; j < s.size(); ++j){
            cur[s[j]]++;
        }
        for (int i = 'a' ; i<= 'z'; ++i){
            if(freq[i] == -1)
                freq[i] = cur[i];
            freq[i] = min(freq[i],cur[i]);
        }
    }  
    for (char i = 'a'; i <= 'z'; ++i){
        for(int atm = 0 ; atm < freq[i];atm++){
            printf("%c", i);
        }
    }
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 50;
int n;
ll a[maxn];
map<ll, ll> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a, a + n);
    ll gcd = a[0];
    for(int i = 1;i < n;i++){
        gcd = __gcd(gcd, a[i]);
    }
    bool ok = true;
    for(int i = 0;i < n;i++){
        ll now = a[i];
        ll sq = sqrt(a[i]);
        for(ll j = 2;j <= sq;j++){
            if(now % j == 0LL){
                if(mp[j] || mp[now / j]){
                    ok = false;
                    break;
                }
                mp[j] = 1;
                mp[now / j] = 1;
            }
        }
        mp[now] = 1;
        if(!ok) break;
    }
    if(ok) cout << "pairwise coprime\n";
    else if(gcd == 1LL) cout << "setwise coprime\n";
    else cout << "not coprime\n";
    return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#define gap cout<<endl;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define INF 1<<30
#define present(c,x) ((c).find(x) != (c).end())

int main(){

int n;
cin>>n;
std::vector<int> v(n);
fo(i,n) cin>>v[i];
set<int> st;
fo(i,n) st.insert(v[i]);
if(sz(st)==sz(v)) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
using namespace std;
bool white[50][50],black[50][50],fre[50][50];
int main(){
	int w,h;
	char z;
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			white[i][j]=false;
			black[i][j]=false;
			fre[i][j]=true;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>z;
			if(z=='W'){
				fre[i][j]=false;
				white[i][j]=true;
			}
			if(z=='B'){
				fre[i][j]=false;
				black[i][j]=true;
			}
		}
	}
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	while(true){
		bool cha=false;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fre[i][j]==true){
				for(int k=0;k<4;k++){
					if(i+dy[k]>=0&&i+dy[k]<h&&j+dx[k]>=0&&j+dx[k]<w){
						if(white[i+dy[k]][j+dx[k]]==true){
							if(white[i][j]==false)
								cha=true;
							white[i][j]=true;
						}
						if(black[i+dy[k]][j+dx[k]]==true){
							if(black[i][j]==false)
								cha=true;
							black[i][j]=true;
						}
					}
				}
				}
			}
		}
		if(cha==false)
			break;
	}
	int wans=0,bans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fre[i][j]==true){
				if(white[i][j]==true)
					wans++;
				if(black[i][j]==true)
					bans++;
				if(white[i][j]==true&&black[i][j]==true)
					wans--,bans--;
			}
		}
	}
	cout<<bans<<" "<<wans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    d = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    d.sort()
    md=d[-1]
    count=0
    for i in range(1,md+1):
        c=bisect_left(d,i)
        if N-c==c:
            count+=1
    print(count)





if __name__ == "__main__":
    main()

Measured memory_bytes: 90972
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
#最後にdecimal にして2で割る
p = list(map(lambda x :x+1,p))

ret = sum(p[0:k])
cur = ret
for i in range(k,n):
    cur = cur - p[i-k] +p[i]
    ret = max(ret,cur)
print(ret/2)

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

num = [[0 for j in range(10)]for i in range(10)]
for i in range(1,N+1):
    NN = i
    kouho = []
    while NN>=1:
        kouho.append(int(NN%10))
        NN = NN/10
    if len(kouho) == 0:
        continue
    
    low_bit = int(kouho[0])
    high_bit = int(kouho[-1])
    
    if (not low_bit or not high_bit):
        continue
    num[low_bit][high_bit] += 1
ans = 0


for i in range(1,10):
    for j in range(1,10):
        ans += num[i][j] * num[j][i]
print(ans)
    


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    
    int n = 0;
    
    int d = 1000;
    for(int i = 0;i < s.size();i++){
        n += (s[i] - '0') * d;
        d /= 10;
    }
    int a = n / 100;
    int b = n % 100;
    
    if((1 <= a && a <= 12) && (1 <= b && b <= 12)){
        cout << "AMBIGUOUS" << endl;
    }else if(1 <= a && a <= 12 && (b < 1 || 12 < b)){
        cout << "MMYY" << endl;
    }else if((a < 1 || 12 < a) && 1 <= b && b <= 12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN

    int n;cin>>n;
    vector<vector<pair<ll,ll>>> e(n);
    REP(i,n-1){
        ll u,v,w; cin>>u>>v>>w;
        u--; v--;
        e[u].push_back(make_pair(v,w));
        e[v].push_back(make_pair(u,w));
    }
    vll visited(n); REP(i,n) visited[i]=0;
    vll color(n); REP(i,n) color[i]=0;
    stack<int> s; s.push(0);

    while(!s.empty()){
        int now = s.top(); 
        s.pop();
        visited[now]=1;
        for(auto it: e[now]){
            int v = it.first; int w = it.second;
            if(!visited[v]){
                color[v] = (color[now]+w) % 2;
                s.push(v);
            }
        }
    }
    
    REP(i,n) cout<<color[i]<<endl;
    return 0;
}

Measured memory_bytes: 9472
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n,i,a[100],s;
    while(1){
        n=in();
        if(!n)break;
        rep(i,n)a[i]=in();
        sort(a,n);
        s=0;
        for(i=1;i<n-1;i++)s+=a[i];
        print(s/(n-2));
    }
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define dbg(x)                cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
////////////////////////

int main()
{
	int n; scanf("%d",&n);
	string s; cin>>s;
	int k; scanf("%d",&k);
	char c=s[k-1];
	for(int i=0; i<n ; i++){
		if(c!=s[i])
			s[i]='*';
	}
	cout<<s<<endl;
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}


Measured memory_bytes: 256
#include <stdio.h>

int count;

int push(int *a,int num,int n){
	if(a[num-1]==2){
		count++;
		return;
	}else if(count==n){
		count=-1;
		return;
	}else if(count<n||a[num-1]!=2){
		++count;
		push(a,a[num-1],n);
	}
}

int main(){
	int n;
	scanf("%d\n",&n);
	int a[n];
	for(int i=0;i<n;++i)
	{
		scanf("%d\n",&a[i]);
	}
	push(a,1,n);
	printf("%d",count);
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c&&a<=c) 
		cout << "YES";
	else
		cout << "NO";
	
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n;
int a[N];
int b[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = 0, r = n - 1;
    int k = 1;
    for (int i = n - 1; i >= 0; --i) {
        if (k) {
            b[l++] = a[i];
        } else {
            b[r--] = a[i];
        }
        k = 1 - k;
    }
    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5220
#include <iostream>
#include <cstring>

using namespace std;

int main(void) {
  while (true) {
    int field[21][21]; // ?????£???????????????????¨??????§?¨?
    int N; // ??????????????°
    int M; // ??????????????°
    int positionX = 10; // ????????????????????????x??§?¨?
    int positionY = 10; // ????????????????????????y??§?¨?
    memset(field, 0, sizeof(field));

    cin >> N;
    if (N == 0) {
      break;
    }
    for (int i=0; i<N; i++) {
      int x, y;
      cin >> x >> y;
      field[y][x] = 1;
    }

    cin >> M;
    for (int i=0; i<M; i++) {
      char direction;
      int distance;
      cin >> direction >> distance;
      switch (direction) {
      case 'N':
        for (int j=0; j<=distance; j++) {
          field[positionY+j][positionX] = 0;
        }
        positionY += distance;
        break;
      case 'E':
        for (int j = 0; j <= distance; j++) {
          field[positionY][positionX+j] = 0;
        }
        positionX += distance;
        break;
      case 'S':
        for (int j = 0; j <= distance; j++) {
          field[positionY-j][positionX] = 0;
        }
        positionY -= distance;
        break;
      case 'W':
        for (int j = 0; j <= distance; j++) {
          field[positionY][positionX-j] = 0;
        }
        positionX -= distance;
        break;
      }
    }

    bool ans = true;
    for (int i = 0; i < 21; i++) {
      for (int j = 0; j < 21; j++) {
        if (field[i][j] == 1) {
          ans = false;
        }
      }
    }
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3068
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))

for n in A:
    if n % 2 == 0:
        if not (n % 3 == 0 or n % 5 == 0):
            print('DENIED')
            exit(0)

print('APPROVED')


Measured memory_bytes: 38644
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 1:
    print(10**(n-1))
    sys.exit()
if m == 0 and n == 1:
    print("0")
    sys.exit()
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();

    	int p = a*b;

    	if (p%2==0) {
    		System.out.println("Even");
    	} else {
    		System.out.println("Odd");
    	}

    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
long long a[200010];

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%lld", &(a[i]));
	}
	
	long long total = 0;
	long long lastNum = a[0];
	for (int i = 0 ; i < n ; i++) {
		if (lastNum > a[i]) {
			long long diff = lastNum - a[i];
			total = total + diff;
		} else if (lastNum < a[i]) {
			lastNum = a[i];
		}
	}
	
	printf("%lld\n", total);

	return 0;
}




Measured memory_bytes: 3292
(* O(n) *)
open Hashtbl
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let h = create n
let _ =
  Array.iter (fun a -> try ignore @@ find h a; remove h a with _ -> add h a 1) a_s;
  length h |> Printf.printf "%d\n"

Measured memory_bytes: 7936
N = int(input())
A = list(map(int,input().split()))
# print(A)

# bar length
BarLen = sum(A)
BarHalf = BarLen / 2
# print(BarLen, BarHalf)

# culc nearest point from half
c_sum = 0
for a in A:
    if c_sum + a == BarHalf:
        n_point = 0
        break
    elif c_sum + a > BarHalf:
        d_minus = BarHalf - c_sum
        d_plus = c_sum + a - BarHalf
        n_point = min(d_minus, d_plus)
        break
    else:
        c_sum += a

print(int(n_point/0.5))


Measured memory_bytes: 26220
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int l,r,ans;
vector<int> v;
int main(){
	ans=99999999;
	cin>>l>>r;
	for(int i=l;i<=r&&i-l<2019;i++)
	{
		if(i%2019==0)
		{
			cout<<0;
			return 0;
		}
		v.push_back(i%2019);
	}
	for(int i=0;i<v.size()-1;i++)
		for(int j=i+1;j<v.size();j++)
			ans=min(ans,(v[i]*v[j])%2019);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		if (B * 2 < A) {
			System.out.println(A - B * 2);
			return;
		} else {
			System.out.println("0");
		}
	}
}

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

int p[1000001];
long long co[1000001];
int a[1000001];
int b[2][1000001];

int main (){
  int n,m;
  cin >>n>>m;
  for(int i=1;i<=m;i++) cin >> p[i];
  for(int i=1;i<n;i++){
    cin >> a[i]>>b[0][i]>>b[1][i];
    co[i] = 0;
  }

  for(int i=1;i<m;i++){
    if(p[i]<p[i+1]){
      co[p[i]]++;
      co[p[i+1]]--;
    }else {
      co[p[i]]--;
      co[p[i+1]]++; 
    }
  }
  for(int i=2;i<n;i++) co[i] +=co[i-1];
  long long summin=0;
  for(int i=1;i<n;i++){
    summin+=min((long long)co[i]*a[i],(long long)co[i]*b[0][i]+b[1][i]);
  }
  cout <<summin<<endl;
  return 0;
}

Measured memory_bytes: 15880
#include <stdio.h>
int main(void){
  int cars[101];
  int i;
  
  for(i=1;scanf("%d",&cars[i])!=EOF;i++){
      if(cars[i]==0){
          printf("%d\n",cars[i-1]);
          i-=2;
      }
  }
  
   return 0;
}



Measured memory_bytes: 2064
def main():
    n, m = map(int, input().split())
    a = set([int(input()) for _ in range(m)])

    ansls = [0]*(n+1)
    #big = 10**9 + 7

    if 0 not in a:
        ansls[0] = 1
    if 1 not in a:
        ansls[1] = 1

    for i in range(2, n+1):
        if i not in a:
            ansls[i] = (ansls[i-2] + ansls[i-1])%(10**9 + 7)
    
    print(ansls[-1])
    
if __name__ == "__main__":
    main()

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

int w, h;
char c;

int main() {
	cin >> w >> h >> c;
    
for(int i = 0; i < h; i++){
  for(int j = 0; j < w; j++){
char d = '.';
if(i*(i- h+1) == 0 && j*(j-w+1) ==0)
d = '+';
else if(i*(i- h+1) == 0)
d = '-';
else if(j*(j-w+1) ==0)
d = '|';
else if(i == h/2 && j == w/2)
d = c;

    cout << d;
}
cout << endl;
}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n;
    cin>>n;
    string s;
    ll maxi=-1000000;
    cin>>s;
    
    for(ll i = 1;i<n;i++){
        ll a[30]={},b[30]={};
        rep(j,i) a[(ll)(s.at(j)-'a'+1)]++;
        for(ll k=i;k<n;k++) b[(ll)(s.at(k)-'a'+1)]++;
        ll c=0;
        rrep(m,30) if(a[m]>=1 && b[m]>=1) c++;
        if(c>maxi) maxi=c;
    }
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int d[2][4]={0},t,i,j,*p;
	for(i=0;i<20;i++)
	{
		scanf("%d",&t);
		for(j=0,p=&d[i/10][0];j<3;j++,p++)
			if(*p<t)
				t^=*p^=t^=*p;
	}
	for(i=0;i<6;i++)
		d[i/3][3]+=d[i/3][i%3];
	printf("%d %d\n",d[0][3],d[1][3]);
	return 0;
}

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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 all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  rep(i, N){
    cin >> l.at(i);
  }
  sort(all(l));
  reverse(all(l));
  int len = 0;
  rep(i, K){
    len += l.at(i);
  }
  cout << len << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns        #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE MultiWayIf          #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Monad.State
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List
import qualified Data.Vector.Unboxed   as VU

main :: IO ()
main = do
  [n,w] <- readLnAsListWith unconsInt
  wvs <- readLnAsUVecWith2Tuple unconsInt n

  print $ VU.maximum $ solve n w wvs



solve :: Int -> Int -> VU.Vector (Int,Int) -> VU.Vector Int
solve !n !w !wvs = go 0 (VU.replicate (w+1) 0)
  where go !m !wvec
          | m == n = wvec
          | otherwise =
              let (!wt,!vt) = wvs VU.! m
              in go (m+1) $ VU.generate (w+1) $ \i ->
                if i - wt < 0
                then wvec VU.! i
                else max (wvec VU.! i) (vt + wvec VU.! (i-wt))

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecWith :: VU.Unbox a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector a)
readLnAsUVecWith !st !n = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- example: 1D tuple vector
readLnAsUVecWith2Tuple :: VU.Unbox a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector (a,a))
readLnAsUVecWith2Tuple !st !n = VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1)) <$> readLnAsUVecWith st 2


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    cout << (n * 800) - (n / 15) * 200 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int X,Y,Z,K;
	cin>>X>>Y>>Z>>K;
	vector<ll> A(X);
	vector<ll> B(Y);
	vector<ll> C(Z);
	FDS(i,X){
	    cin>>A[i];
	}
	FDS(i,Y){
	    cin>>B[i];
	}
	FDS(i,Z){
	    cin>>C[i];
	}
	VSORT(A);
	VSORT(B);
	VSORT(C);
	vector<ll> AB(X*Y);

    FDS(i,X){
		FDS(j,Y){
			AB[X*i+j]=(A[i]+B[j]);
		}
	}	
    VSORT(AB);
    VREV(AB);
	VREV(C);
	vector<ll> S(K);
	ll nn=min(K,X*Y);
	FDS(i,nn){
		S[i]=AB[i];
	}
	FDS(i,K){
	   // cout<<S[i]<<endl;
	}
	vector<ll> ans(K*Z);
	FDS(i,K){
		FDS(j,Z){
			ans[Z*i+j]=S[i]+C[j];
			//cout<<Z*i+j<<endl;
		}
	}
    VSORT(ans);
    VREV(ans);	
	FDS(i,K){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 31616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    t = n // k
    r = t ** 3
    if k % 2 == 0:
        k //= 2
        tt = n // k
        if tt % 2 == 1:
            r += (tt//2+1) ** 3
        else:
            r += (tt//2) ** 3

    return r


print(main())


Measured memory_bytes: 7752
import java.util.Scanner;

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

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 1;
			while (cnt <= h) {
				cnt *= 2;
			}

			System.out.println(cnt - 1);
		}
	}
}


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

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<endl;
    }
    else if(a<=5)
    {
        cout<<"0"<<endl;
    }
    else{
        cout<<b/2<<endl;
    }
}


Measured memory_bytes: 3508
s = list(input())
k = int(input())

substring = []
for i in range(len(s)):
  for j in range(i, min(len(s), i + k)):
    if not("".join(s[i:j + 1]) in substring):
      substring.append("".join(s[i:j + 1]))

substring.sort()
print(substring[k - 1])


Measured memory_bytes: 4072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		sc.close();
		
		String seven = Integer.toString(A);
		if(seven.contains("7")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35700
var n,ans,max,x,i:longint;
begin 
	read(n);
	ans:=0;max:=0;
	for i:=1 to n do 
	begin 
		read(x);
		ans:=ans+x;
		if x>max then max:=x;
	end;
	ans:=ans-max div 2;
	write(ans);
end.

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define INF 9999999
using namespace std;
typedef pair<int,int> P;
int d[10][1000];
int ab[10][1000];
int n;
int sx,sy,g;
int dx[3] = {0,1,2};
int bfs();
int main(){
  while(1){
    for(int i=0;i<2;i++){
      for(int j=0;j<n;j++){
	ab[i][j] = 0;
      }
    }
    int ans = INF;
    int res = INF;
    cin >> n;
    if(n == 0)break;
    g = n-1;
    for(int i=0;i<2;i++){
      for(int j=0;j<n;j++){
	cin >> ab[i][j];
      }
    }
    sx = 0;
    sy = 0;
    for(int i=0;i<2;i++){
      if(ab[sx][sy] == 1){
	while(ab[sx][sy+1] == 1){
	  sy++;
	}
      }
      res = bfs();
      if(res < ans){
	ans = res;
      }
      sx = 1;
      sy = 0;
    }
    if(ans == INF)cout << "NA" << endl;
    else cout << ans << endl;
  }
}
int bfs(){
  int nx,ny;
  queue <P> qu;
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      d[i][j] = INF;
    }
  }
  qu.push(P(sx,sy));
  d[sx][sy] = 0;
  while(!qu.empty()){
    P p = qu.front();
    qu.pop();
    if(p.second == g)break;
    if(p.first == 0)nx = p.first + 1;
    else if(p.first == 1)nx = p.first - 1;
    for(int i=0;i<3;i++){
      ny = p.second + dx[i];
      if(ab[nx][ny] == 1){
	while(ab[nx][ny+1] == 1){
	  ny ++;
	}
      }
      else if(ab[nx][ny] == 2){
	while(ab[nx][ny] == 2){
	  ny--;
	}
      }
      if(0 <= ny && ny <=n-1 && ab[nx][ny] != 2 && d[nx][ny] == INF){
	qu.push(P(nx,ny));
	d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  return min(d[0][g],d[1][g]);
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int A,B,K;

  cin >> A >> B >> K ;

  int count=0,ans;

  int i = max(A,B);

  for(i;i>=1;i--){
    if(A%i==0&&B%i==0) count++;

    if(count==K){ans = i; break;}
  }

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

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

using namespace std;
string s;

int main() {
    cin >> s;
    int len = s.size();
    int i = 0;
    for (i = 0; i < len; i++)
        if (s[i] == 'C')
            break;
    for (int j = i; j < len; j++)
        if (s[j] == 'F') {
            cout << "Yes";
            return 0;
        }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, p[101];

int main(){
    cin >> n;
    REP(i, n)cin >> p[i];
    sort(p, p + n);
    int ans = 0;
    REP(i, n - 1)ans += p[i];
    ans += p[n - 1]/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 1100000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

int n, m, k;
vector<PII> G[MAX];
map<PII, int> L;
int U[MAX];
int V[MAX];
int C[MAX];
deque<int> Q;
int R[MAX];

void add(int u, int v, int c)
{
  U[k] = u;
  V[k] = v;
  C[k] = c;

  PII t = MP(u, c);

  if (L.find(t) != L.end())
  {
    int id = L[t];
    G[k].PB(MP(id, 0));
    G[id].PB(MP(k, 0));
  }

  G[k].PB(MP(k^1, 0));

  L[t] = k;

  G[k].PB(MP(2*m+v, 1));
  G[2*m+u].PB(MP(k, 0));

  ++ k;
}

int main()
{
  cin >> n >> m;
  FOR (i,0,m)
  {
    int u, v, c;
    scanf("%d %d %d", &u, &v, &c);
    -- u;
    -- v;

    add(u, v, c);
    add(v, u, c);
  }

  FOR (i,0,m+m+n)
    R[i] = INF;

  R[m+m] = 0;
  Q.push_back(m+m);

  while (!Q.empty())
  {
    int v = Q.front();
    Q.pop_front();

    FOR (i,0,SZ(G[v]))
    {
      int to = G[v][i].first;
      int c = G[v][i].second;

      if (R[to] > R[v] + c)
      {
        R[to] = R[v] + c;
        if (c == 0) Q.push_front(to);
        else Q.push_back(to);
      }
    }
  }

  int res = INF;

  FOR (i,0,m+m)
    if (V[i] == n-1)
      res = min(res, R[i]);

  cout << (res >= INF ? -1 : (res+1)) << endl;

  
  return 0;
}


Measured memory_bytes: 80256
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while (true) {
                        int N = sc.nextInt();
                        if (N == 0) {
                                break;
                        } else if(N == 1){
                                System.out.println("deficient number");
                                continue;
                        }
                        long num = 0;
                        for (int i = 1; i < Math.sqrt(N); i++) {
                                if (N % i == 0) {
                                        num += i;
                                        num += N / i;
                                }
                        }
                        if (Math.sqrt(N) * Math.sqrt(N) == N) {
                                num += Math.sqrt(N);
                        }
                        num -= N;
                        if (num == N) {
                                System.out.println("perfect number");
                        } else if(num < N) {
                                System.out.println("deficient number");
                        } else {
                                System.out.println("abundant number");
                        }
                }
        }
}

Measured memory_bytes: 26868
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var W = Number(inputs[0]);
    var H = Number(inputs[1]);
    var x = Number(inputs[2]);
    var y = Number(inputs[3]);
    var r = Number(inputs[4]);

    var x0 = W - x - r;
    var x1 = W - x + r;
    var y0 = H - y - r;
    var y1 = H - y + r;

    if ((x0 >= 0 && x1 <= W) && (y0 >= 0 && y1 <= H)) {
        console.log('Yes');
    } else {
        console.log('No');
    }







});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15564
import math
K = int(input())

if K < 10:
    print(K)
    exit()
cnt = 9
number_list = [str(i) for i in range(1, 10)]

while True:
    new_number_list = []
    for number in number_list:
        if number[-1] == '0':
            new_number_list.append(number + '0')
            new_number_list.append(number + '1')
        elif number[-1] == '1':
            new_number_list.append(number + '0')
            new_number_list.append(number + '1')
            new_number_list.append(number + '2')
        elif number[-1] == '2':
            new_number_list.append(number + '1')
            new_number_list.append(number + '2')
            new_number_list.append(number + '3')
        elif number[-1] == '3':
            new_number_list.append(number + '2')
            new_number_list.append(number + '3')
            new_number_list.append(number + '4')
        elif number[-1] == '4':
            new_number_list.append(number + '3')
            new_number_list.append(number + '4')
            new_number_list.append(number + '5')
        elif number[-1] == '5':
            new_number_list.append(number + '4')
            new_number_list.append(number + '5')
            new_number_list.append(number + '6')
        elif number[-1] == '6':
            new_number_list.append(number + '5')
            new_number_list.append(number + '6')
            new_number_list.append(number + '7')
        elif number[-1] == '7':
            new_number_list.append(number + '6')
            new_number_list.append(number + '7')
            new_number_list.append(number + '8')
        elif number[-1] == '8':
            new_number_list.append(number + '7')
            new_number_list.append(number + '8')
            new_number_list.append(number + '9')
        elif number[-1] == '9':
            new_number_list.append(number + '8')
            new_number_list.append(number + '9')
    cnt += len(new_number_list)
    if cnt >= K:
        print(new_number_list[-(cnt-K+1)])
        exit()
    number_list = new_number_list


Measured memory_bytes: 15636
a=int(input())
b=[input().split() for i in range(a)]
c=0
for i in range(a):
  if b[i][1]=="JPY":
    c=c+int(b[i][0])
  if b[i][1]=="BTC":
    c=c+float(b[i][0])*380000
print(c)

Measured memory_bytes: 9028
#include <iostream>
        #include<vector>
        #include<algorithm>
        #define rep(i,n) for (int i = 0; i < (n); ++i)
        using namespace std;
        typedef long long ll;
        #define P pair<int,int>;
         
        const int M = 1000005;
         
        int main() {
          int n;
          cin >> n;
          vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
		sort(a.begin(),a.end());
		vector<int> b(M);
		int num=0;
		int c=1;
		for(int i=0;i<n;i++)
		{
			if(i<n-1 && a[i]==a[i+1])
			{
				c++;
				continue;
			}
			for(int j=a[i];j<=1000000;j+=a[i]){
				b[j]+=c;
			}
			c=1;
			 }
			 
			 for(int i=0;i<n;i++)
			 {
			 	if(b[a[i]]>1) num++;
				  }    
				  cout<<n-num<<endl;
				  return 0; 
    		         
				 
				 
}

Measured memory_bytes: 7620
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    map<string, int> arr;
    int n;
    cin >> n;
    int maxn = 0;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        arr[s]++;
    }
    
    for(auto it : arr){
        maxn = max(maxn,it.second);
    }
    
    for(auto it : arr){
        if(it.second == maxn){
            cout << it.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int n; vector<int>v;
long long dp[100005];
/*long long solve(int i) {
	if (i > n)return 1e9;
	if (i == n)return v[0];
	if (i == n-1)return abs(v[i]-v[n-1]);
	if (i == n-2)return abs(v[i]-v[n-2]);
	long long& ret = dp[i];
	if (ret!=1e9)return ret;
	long long ret = 2e9;
	ret=min(solve(i + 1) + abs(v[i] - v[i + 1]),solve(i + 2) + abs(v[i] - v[i + 2]));
	return ret;
}*/
int main() {
	int n; cin >> n;
	vector<int>v(n + 1);
	for (int i = 1; i <= n; i++)cin >> v[i];
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
		if (i > 2)dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
	}
	cout << dp[n];
	
}

Measured memory_bytes: 1408
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a*b%2==0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}

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

int main(){
    int d,ans;
    
    while(cin >> d){
        ans=0;
        for(int i=0; i<600; i+=d){
            ans+=pow(i,2)*d;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import scala.io.StdIn

object Main {
  val position: Vector[Int] = Vector()
  def main(args: Array[String]): Unit = {
    val a = StdIn.readInt()
    val b = StdIn.readInt()
    val c = StdIn.readInt()
    val d = StdIn.readInt()
    val e = StdIn.readInt()
    val k = StdIn.readInt()
    if (e - a <= k) {
      println("Yay!")
    } else {
      println(":(")
    }
  }
}


Measured memory_bytes: 25416
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
#include<string>
#include<deque>
#include<map>
#include<cmath>
#include<stack>
#include<vector>
#include<queue>
#include<cstdlib>
using namespace std;
#define lck_max(a,b)((a)>(b)?(a):(b))
#define lck_min(a,b)((a)<(b)?(a):(b))
typedef long long LL;
const int maxn=1e6+7;
const int mod=998244353;
LL hash[maxn];
char s[maxn];
struct hh{
    LL first,second;
}t;
inline void Hash(){
    hash[0]=1;
    for(LL i=1;i<=maxn-1000;i++)hash[i]=hash[i-1]*13%mod;
}
inline void change(LL len){
    for(LL i=0;i<len;i++){
        if(s[i]=='b') {s[i]='d';continue;}
        if(s[i]=='d') {s[i]='b';continue;}
        if(s[i]=='q') {s[i]='p';continue;}
        if(s[i]=='p') {s[i]='q';continue;}
    }
}
int main(){
    Hash();
    scanf("%s",s);
    LL len=strlen(s);
    for(LL i=0;i<len;i++)t.first=(t.first+s[i]*hash[i])%mod;
    change(len);
    for(LL i=len-1;~i;i--)t.second=(t.second+s[i]*hash[len-i-1])%mod;
    if(t.first==t.second) puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
  int d,t,s;
  cin >> d >> t >> s;
  int dis = t*s;
  if (dis >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI stp,edp;
VI dir;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,l,t;
  cin>>n>>l>>t;
  stp.resize(n);
  dir.resize(n);
  in totl=0;
  forn(i,n){
    cin>>stp[i]>>dir[i];
    if(dir[i]==1){
      ++totl;
      edp.PB((stp[i]+t)%l);
    }
    else{
      --totl;
      edp.PB(((stp[i]-t)%l+l)%l);
    }
  }
  in chtotcor=totl*t;
  sort(all(edp));
  in chi=0;
  forv(i,stp){
    chi+=(edp[i]-stp[i]);
  }
  chtotcor-=chi;
  chtotcor%=n*l;
  chtotcor+=n*l;
  chtotcor%=n*l;
  assert(chtotcor%l==0);
  in cofs=chtotcor/l;
  forn(i,n)
    cout<<edp[(i+cofs)%n]<<"\n";
  
  return 0;
}


Measured memory_bytes: 3700