akhauriyash/Code-Regression huggingface dataset:
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [l,r,d] = nexts(3);
  var ans = 0;
  for(var i = l; i <= r; i++)if(i % d === 0)ans++;
  return ans;
}

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

int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  unordered_set<ll> a;

  a.insert(A);
  a.insert(B);
  a.insert(C);
  cout << (a.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
ans=0
mod=10**9+7
A=[0 for i in range(K)]
for i in range(K,0,-1):
  l=pow(K//i,N,mod)
  a=2
  while a*i<=K:
    l-=A[a*i-1]
    a+=1
  ans+=l*i%mod
  ans%=mod
  A[i-1]=l
print(ans)

Measured memory_bytes: 75740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
using namespace __gnu_pbds;
ll a,b,c,d;
// Recursive function to return gcd of a and b
ll gcd(ll an, ll bn)
{
    if (bn == 0)
        return an;
    return gcd(bn, an % bn);
 
}
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
  //  freopen("in.txt","rt",stdin);
    cin>>a>>b>>c>>d;
    ll div1=a/c;
    ll div2=b/c;
    ll divC=div2-div1;
    if(a%c==0){
        divC++;
    }
    div1=a/d;
    div2=b/d;
    ll divD=div2-div1;
    if(a%d==0){
        divD++;
    }
    ll gcdNum=gcd(c,d);
    ll lcm=(c*d)/gcdNum;
 
    div1=a/lcm;
    div2=b/lcm;
    ll divLcm=div2-div1;
    if(a%lcm==0){
        divLcm++;
    }
    ll range=b-a+1;
    range-=divC;
    range-=divD;
    range+=divLcm;
    cout<<range<<endl;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  for (int i=0; i<N; i++){
    cin >> S;
    if (S=="Y"){
      cout << "Four" << endl;
      break;
    }
    else if ( i == N-1 && S != "Y"){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 3620
from bisect import bisect_left

n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)
b = list(reversed(a))

rs = [0] * n
rs[0] = a[0]
for i, x in enumerate(a[1:]):
    rs[i+1] = rs[i] + x

L = a[-1] * 2
H = a[0] * 2

while H - L > 1:
    M = (L + H) // 2
    count = 0
    for x in a:
       count += n - bisect_left(b, M - x)
    if count == m:
        L = M
        break
    elif count > m:
        L = M
    else:
        H = M

ans = 0
count = 0
for x in a:
    c = n - 1 -  bisect_left(b, L - x)
    count += c + 1
    if c >= 0:
        ans += rs[c] + x * (c+1)

print(ans - (count-m) * L)


Measured memory_bytes: 57228
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]

ans = x
for i in range(n):
    count = 1
    day = 1
    while day + a[i] <= d:
        day += a[i]
        count += 1
    ans += count

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

typedef pll P;

pll operator - (pll A,pll B){A.F-=B.F; A.S-=B.S; return A;}
pll operator + (pll A,pll B){A.F+=B.F; A.S+=B.S; return A;}

ll cross(pll a,pll b){return a.F*b.S-a.S*b.F;}

ll dot(pll a,pll b){return a.F*b.F+a.S*b.S;}

vector<P> convexhull(vector<P> pts){
  vector<P> ret;
  sort(pts.begin(),pts.end());
  pts.erase(unique(pts.begin(),pts.end()),pts.end());
  auto fnc=[&](){
             for(auto &I:pts){
               if(!ret.empty() && I==ret.back()){continue;}
               while(ret.size()>=2){
                 pll A=ret.back()-ret[ret.size()-2];
                 pll B=I-ret.back();
                 if(cross(A,B)<0){ret.pop_back(); continue;}
                 if(cross(A,B)==0 && dot(A,B)>0){ret.pop_back(); continue;}
                 break;
               }
               ret.push_back(I);
             }
           };
  fnc();
  reverse(pts.begin(),pts.end());
  fnc();
  if(ret[0]==ret.back() && ret.size()>1){ret.pop_back();}
  return ret;
}


int main(){
  ll N;
  cin>>N;
  vector<pll> A(N);
  cin>>A;
  vector<pll> con={{0,0}};
  vector<pll> nx;
  for(auto &I:A){
    nx=con;
    for(auto &J:con){
      nx.push_back(J+I);
    }
    con=convexhull(nx);
  }
  D ans=0;
  for(auto &I:con){
    ans=max<D>(ans,sqrt(I.F*I.F+I.S*I.S));
  }
  cout<<fixed<<setprecision(20)<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize =read();
    let p: Vec<usize> = read_vec();
    let mut ans = 1;
    let mut m: usize = p[0];

    for i in 0..n {
      if p[i] < m {
         ans += 1;
      }
      if p[i] < m {
         m = p[i];
      }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#-*-coding:utf-8-*-

def main():
    s = list(input())
    ans = []
    for i in s:
        if i == '0':
            ans.append('0')
        elif i == '1':
            ans.append('1')
        elif i == 'B':
            if len(ans) == 0:
                ans = []
            else:
                ans.pop()
    print(''.join(ans))

if __name__ == '__main__':
    main()

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int ans = 1;
    for (int i = 1; i < N; i++) {
        while (i < N && A[i - 1] == A[i]) i++;
        if (i >= N) break;
        if (A[i - 1] < A[i]) {
            while (i < N && A[i - 1] <= A[i]) i++;
        } else {
            while (i < N && A[i - 1] >= A[i]) i++;
        }
        if (i >= N) break;
        ans++;
    }

    cout << ans << endl;
}

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

int main() {
	long long int ans[86]={},N;
	cin>>N;
	ans[0]=2;
	ans[1]=1;
	for(int i=0;i<N+1;i++)
	{
		if(i>=2)ans[i]=ans[i-1]+ans[i-2];
	}
	cout<<ans[N];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pp pair<int,int>
#define fi first
#define se second
#define maxx 400012
#define ll long long
#define pb push_back
#define mp make_pair
#define lb lower_bound
const int mod=998244353;
using namespace std;

int n,temp;

int create(int num){
    int res=1;
    while(num--){
        res*=10;
    }
    return res;
}

int dem(int k){
    int res=0;
    while(k>0){
        res++;
        k/=10;
    }
    return res;
}

void input(){
//    freopen("TEST.INP","r",stdin);
//    freopen("TEST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    temp=dem(n);
//    int tam=create(5);
//    cout<<tam;
}

int main()
{
    input();
    ll res=0;
    for(int i=1;i<temp;i+=2){
        res+=create(i)-create(i-1);
    }
    if(temp%2==1){
        res+=n-create(temp-1)+1;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    def min2(x, y): return x if x <= y else y

    N = int(input())
    As = list(map(int, input().split()))

    if N == 0:
        if As[0] == 1:
            return 1
        else:
            return -1

    pow2 = 1
    pow2s = [pow2]
    for d in range(61):
        pow2 *= 2
        pow2s.append(pow2)
    pow2s += [pow2] * N
#    print('pow2s:', pow2s)

    maxV = min2(1, 1-As[0])
    maxVs = [maxV]
    for d in range(1, N+1):
        maxV = min2(maxV*2, pow2s[d]) - As[d]
        maxVs.append(maxV)
#    print('maxVs:', maxVs)

    numVs = [0] * (N+1)
    numVs[N] = As[N]
    for d in reversed(range(N)):
#        print('\n##### d:', d)
        numC2 = -(-numVs[d+1] // 2)
#        print('numC2:', numC2)
        if maxVs[d] < numC2:
            return -1
        num = min2(maxVs[d], numVs[d+1])
        numVs[d] = As[d] + num
#        print('As[d]:', As[d], '/ num:', num, '/ numVs[d]:', numVs[d])
        if numVs[d] > pow2s[d]:
            return -1

#    print('numVs:', numVs)
    return sum(numVs)


ans = solve()
print(ans)


Measured memory_bytes: 675816
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;
map < int , int > mp1, mp2 ;
int main ( ){
  scanf("%d",&n);
  for ( int i = 1; i <= n; i++ ) {
    int x ; scanf("%d",&x);
    if ( i &1 ) {
        mp1[x]++;
    }else {
    mp2[x]++;
    }
  }
  int mn = inf ;
   int mx1 = 0 , ixd = -1  , cnt = 0  ;
   for ( auto x : mp1 ) {

    if ( mx1  < x.S ){

       cnt = 1 ;
       ixd = x.F ;
       mx1 = x.S ;
    } else if ( mx1 == x.S){
      cnt++;
    }
   }
   int mx2 = 0 ;
   for ( auto x : mp2 ) {
    if ( mx2 < x.S ){
        if ( ixd == x.F && cnt == 1 ) continue;
        mx2 = x.S ;
    }

   }
     mx1 = (n/2) - mx1 ;
   mx2 = (n/2) - mx2 ;
   mn = min ( mn , mx1+mx2 );
   mx2 = 0 , ixd = -1  , cnt = 0  ;
   for ( auto x : mp2 ) {

    if ( mx2  < x.S ){

       cnt = 1 ;
       ixd = x.F ;
       mx2 = x.S ;
    } else if ( mx2 == x.S){
      cnt++;
    }
   }
    mx1 = 0 ;
   for ( auto x : mp1 ) {
    if ( mx1 < x.S ){
        if ( ixd == x.F && cnt == 1 ) continue;
        mx1 = x.S ;
    }

   }
   mx1 = (n/2) - mx1 ;
   mx2 = (n/2) - mx2 ;
   mn = min ( mn , mx1+mx2 );
   printf("%d",mn);
 return 0 ;
}


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

using namespace std;

typedef long long LL;

#define MAX_N 100005

int N;
LL M;
LL X[MAX_N];
int MAP[MAX_N], MAP2[MAX_N];
set<int> SET;

void input()
{
  cin >> N >> M;
  for (size_t i = 0; i < N; i++) {
    scanf("%lld", &X[i]);
  }
}

int main()
{
  input();

  for (size_t i = 0; i < N; i++) {
    MAP[X[i]%M]++;
    if(!SET.insert(X[i]).second){
      MAP2[X[i]%M]++;
      SET.erase(X[i]);
    }
  }

  LL ans = 0;
  for (int i = 1; i < (M+1)/2; i++) {
    LL tmp = min(MAP[i], MAP[M-i]);
    LL tmp2;
    LL L = (MAP[i] - MAP2[i]*2);
    if(tmp >= L)
      tmp2 = (MAP2[i]*2 - (tmp - L))/2;
    else
      tmp2 = MAP2[i];
    LL tmp3;
    L = (MAP[M-i] - MAP2[M-i]*2);
    if(tmp >= L)
      tmp3 = (MAP2[M-i]*2 - (tmp - L))/2;
    else
      tmp3 = MAP2[M-i];
    ans += tmp + tmp2 + tmp3;
    //cerr << tmp << " " << tmp2 << " " << tmp3 << endl;
  }
  ans += MAP[0]/2;
  if(M%2 == 0){
    ans += MAP[M/2]/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

//AOJ 0168

signed main(){
	int n;
	int dp[31] = { 0 };
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	rep(i, 3, 31) {
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	while (cin>>n && n) {
		cout << (dp[n] + 3649) / 3650 << endl;
	}
}

Measured memory_bytes: 1156
w, h, x, y = map(int, input().split())

if w == 1 and h == 1:
    print(str(0.5) + " " + str(0))
    exit()

print(str(int(w*h/2)) + " " , end="")
print(1 if w/2 == x and h/2 == y else 0)

Measured memory_bytes: 3060
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String top = r.readLine();
		boolean cpp = false;
		int score = 0;
		for (int j = 0; j < top.length(); j++) {
			if (cpp) {
				if (top.charAt(j) == 'g')
					score++;
				cpp = false;
			}
			else {
				if (top.charAt(j) == 'p')
					score--;
				cpp = true;
			}
		}
		System.out.println(score);
	}

}

Measured memory_bytes: 10964
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	string a, b;

	cin >> a >> b;

	if (a < b) {
		cout << "<" << endl;
	}
	else if(a > b) {
		cout << ">" << endl;
	}
	else {
		cout << "=" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
l_list = list(map(int, input().split()))

max_l = max(l_list)
l_list.pop(l_list.index(max_l))
sum_l_but_max = sum(l_list)

if max_l < sum_l_but_max:
    print('Yes')
else:
    print('No')
    

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

void solve(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 256
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())

    print(min(A*N, B))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","a",main)

Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Stack;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		Stack<Integer> st = new Stack<Integer>();
		
		while (true)
		{
			try
			{
				int num = sc.nextInt();
				
				if (num == 0)
				{
					System.out.println(st.pop());
				}
				else
				{
					st.push(num);
				}
			}
			catch (Exception e)
			{
				break;
			}
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
const int maxn = 55;
char grid[maxn][maxn];
int M(){
    int n, k;
    if(!(cin >> n >> k)) return 0;
    vector<int> x(n), y(n);
    for(int e = 0; e < n; e++)
        cin >> x[e] >> y[e];
    vector<int> xx, yy;
    for(int e = 0; e < n; e++)
        xx.push_back(x[e]), yy.push_back(y[e]);
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    xx.erase(unique(xx.begin(), xx.end()), xx.end());
    yy.erase(unique(yy.begin(), yy.end()), yy.end());
    vector<long long> res;
    for(int e = 0; e < xx.size(); e++){
        for(int f = e + 1; f < xx.size(); f++){
            for(int g = 0; g < yy.size(); g++){
                for(int h = g + 1; h < yy.size(); h++){
                    int cnt = 0;
                    for(int i = 0; i < n; i++){
                        if(xx[e] <= x[i] && x[i] <= xx[f] &&
                           yy[g] <= y[i] && y[i] <= yy[h]) cnt++;
                    }
                    if(cnt >= k){
                        long long aa = xx[f] - xx[e];
                        long long bb = yy[h] - yy[g];
                        res.push_back(aa * bb);
                    }
                }
            }
        }
    }
    sort(res.begin(), res.end());
    cout << res[0] << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 17644
from sys import stdin
from numpy import array
from collections import defaultdict
from heapq import heappush, heappop


def solve(row):
    readline = stdin.readline
    g = defaultdict(list)

    for i in range(10):
        c_i = list(map(int, readline().split()))
        for j in range(10):
            g[i].append((c_i[j], j))

    accm = [0]*10
    for r in range(row):
        a = list(map(int, readline().split()))
        a = array(a)
        for ai in a:
            if ai != -1:
                accm[ai] += 1

    to_1 = []
    for k in range(10):
        from_k = dijkstra(10, g, k)
        to_1.append(from_k[1])

    return sum([to_1[i] * accm[i] for i in range(10)])


def dijkstra(vertex, g, sp):
    d = [float('inf')] * vertex
    d[sp] = 0
    heap = [(d[sp], sp)]

    while heap:
        du, u = heappop(heap)
        for length, v in g[u]:

            if d[v] > du + length:
                d[v] = du + length
                heappush(heap, (d[v], v))
    return d


if __name__ == '__main__':
    row, _ = map(int, input().split())
    print(solve(row))


Measured memory_bytes: 12548
nk = input().split()
n = int(nk[0])
k = int(nk[1])
alist = [int(a) for a in input().split()]


bit_count = [{0: 0, 1: 0} for i in range(42)]
for i in range(42):
    for a in alist:
        b = a >> i
        b &= 1
        which = 0 if b == 1 else 1
        bit_count[i][which] += 1


def calc_pow_multiple(digit, selected):
    count = bit_count[digit][selected]
    ret = 1<<digit
    ret *= count
    return ret


def calc_maxsum(kk, digit):
    if digit < 0:
        return 0
    if kk == (1<<(digit + 1)) - 1:
        partsum_0 = calc_pow_multiple(digit, 0)
        partsum_1 = calc_pow_multiple(digit, 1)
        return max(partsum_0, partsum_1) + calc_maxsum(kk>>1, digit - 1)

    kkbit = kk >> digit
    kkbit &= 1

    if kkbit == 0:
        return calc_pow_multiple(digit, 0) + calc_maxsum(kk, digit - 1)

    sum_0 = calc_pow_multiple(digit, 0) + calc_maxsum((1<<digit) - 1, digit - 1)
    sum_1 = calc_pow_multiple(digit, 1) + calc_maxsum(kk, digit - 1)
    return max(sum_0, sum_1)


print(calc_maxsum(k, 41))


Measured memory_bytes: 14980
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = new int[5];
            for(var i = 0; i < 5; i++){
                x[i] = int.Parse(Console.ReadLine());
            }
            var k = int.Parse(Console.ReadLine());

            var flag = true;
            for(var i = 0; i < 4; i++){
                for(var j = i + 1; j < 5; j++){
                    if(x[j] - x[i] > k){
                        flag = false;
                    }
                }
            }

            Console.WriteLine(flag ? "Yay!" : ":(");
        }
    }
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<string, int> > res(N);
	vector<int> point(N);
	for (int i = 0; i < N; i++) {
		cin >> res[i].first >> res[i].second;
		point[i] = res[i].second;
	}

	sort(res.begin(), res.end());
	for (int i = 0; i < N; i++) {
		bool same = false;
		int begin = i;
		if (i == N - 1) {
			break;
		}
		while(res[i].first == res[i + 1].first) {
			same = true;
			i++;
			if (i == N - 1) {
				break;
			}
		}
		if (same) {
			for (int j = begin; j < i; j++) {
				for (int k = begin; k < i; k++) {
					if (res[k].second < res[k + 1].second) {
						int temp = res[k].second;
						string temp2 = res[k].first;
						res[k].first = res[k + 1].first;
						res[k].second = res[k + 1].second;
						res[k + 1].first = temp2;
						res[k + 1].second = temp;
					}
				}
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (res[i].second == point[j]) {
				cout << j+1 << endl;
				break;
			}
		}
	}




	return 0;
}

Measured memory_bytes: 256
args = list(map(int , input().split()))

count_5 = 0
count_7 = 0

for num in args:
    # print(num)
    if num == 5:
        count_5 += 1
    if num == 7:
        count_7 += 1

# print(count_5)
# print(count_7)

if count_5 == 2 and count_7 == 1:
    print('YES')
else:
    print('NO')

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> s(H, vector<char>(W));
  vector<int> flag(H);
  vector<int> flag_count(H);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s.at(i).at(j);
    }
    flag.at(i) = 0;
    flag_count.at(i)=0;
  }
  vector<vector<int>> ans(H, vector<int>(W));
  int count = 1;
  int space = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(j == 0){
        if(s.at(i).at(j) == '#'){
          ans.at(i).at(j) = count;
          count++;
        }else{
          ans.at(i).at(j) = count;
          space++;
        }
      }else{
        if(s.at(i).at(j) == '#'){
          ans.at(i).at(j) = count;
          count++;
        }else{
          ans.at(i).at(j) = ans.at(i).at(j-1);
          space++;
        }
      }
    }
    if(space == W) flag.at(i) = 1;
    space = 0;
  }
  
  for (int i = 0; i < H; i++) {
    if(flag.at(i) == 1){
      for(int k = i+1; k < H; k++){
        if(flag.at(k) == 0){
          for (int j = 0; j < W; j++) {
            ans.at(i).at(j) = ans.at(k).at(j);
          }
          flag.at(i) = 0;
          break;
        }
      }
    }
  }
  
  for (int i = H-1; i >= 0; i--) {
    if(flag.at(i) == 1){
      for(int k = i-1; k >= 0; k--){
        if(flag.at(k) == 0){
          for (int j = 0; j < W; j++) {
            ans.at(i).at(j) = ans.at(k).at(j);
          }
          flag.at(i) = 0;
          break;
        }
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << ans.at(i).at(j);
      if(j != W-1) cout << ' ';
    }
    cout << endl;
  }
  
}

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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 1e5+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;
                 
ll n, a[N], ans;
map <int, int> c;
int b[N];

int main () {        
	ios_base           
	cin >> n;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		b[i] = a[i];
		c[a[i]] = i % 2;
	}
	sort(b+1,b+1+n);
	for(int i = 1; i <= n; i ++){
	 if(c[b[i]] != i % 2) ans ++;
	}
	cout << ceil(ans/2);
	return 0; 
}
 


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int n;
string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	int x = 0, y = 0;
	for(int i = 0;  i < s.size(); i++){
		if(s[i] >= 'A' && s[i] <= 'M') y++;
		if(s[i] >= 'N' && s[i] <= 'Z') y--;
		if(s[i] >= 'a' && s[i] <= 'm') x++;
		if(s[i] >= 'n' && s[i] <= 'z') x--;
	}
	string ans;
	for(int i = 0; i < abs(x); i++){
		if(x >= 0) ans += 'a';
		else ans += 'n';
	}
	for(int i = 0; i < abs(y); i++){
		if(y >= 0) ans += 'A';
		else ans += 'N';
	}
	cout << ans.size() << endl;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3352
#include<stdio.h>

int main(){
	int inputSecond;
	scanf("%d", &inputSecond);
	int hour = inputSecond/3600;
	int minute = (inputSecond%3600)/60;
	int second = inputSecond%60;
	
	printf("%d:%d:%d\n", hour, minute, second);
	
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> itable(H,vector<char>(W));
    vector<int> del_column, del_row;
    for (int i = 0; i < H;  i++) {
        for (int j = 0; j < W; j++) {
            cin >> itable.at(i).at(j);
        }
    }

    for (int i = 0; i < H; i++) {
        bool flag = true;
        for (int j = 0; j < W; j++) {
            if(itable.at(i).at(j) != '.') {
                flag = false;
                break;
            }
        }
        if(flag) del_column.push_back(i);
    }
    for (int i = 0; i < W; i++) {
        bool flag = true;
        int j;
        for (j = 0; j < H; j++) {
            if(itable.at(j).at(i) != '.') {
                flag = false;
                break;
            }
        }
        if(flag) del_row.push_back(i);
    }
	
    for (int i = 0; i < H;  i++) {
        bool flag = false;
        for(int c : del_column){
            if (i == c) {
                flag = true;
                //cout << "flagtrue,i:" << i ;
                 break;
            }
        }
        if(flag) continue;
        for (int j = 0; j < W; j++) {
            bool flag = false;
            for(int r : del_row) {
                if(j == r) {
                    flag = true;
                    //cout << "flagtrue,j:" << j ;
                    break;
                }
            }
            if(flag) continue;
            cout << itable.at(i).at(j);

        }
      	cout << endl;
    }
}


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

	
int main() {
  int N;
  cin >> N;
   vector<int> V(N);
   vector<int> C(N);
  
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>C.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    if(V.at(i)>C.at(i)){
      sum+=V.at(i)-C.at(i);
    }
  }
   cout<<sum<<endl;
    return 0;
  }
  

Measured memory_bytes: 256
s = list(input())

ans = []

for i in range(len(s)):
	ans.append(0)
	j = i
	while s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T" :
		ans[i] += 1
		if j >= len(s) - 1:
			break
		else:
			j += 1
		
ans =sorted(ans, reverse = True)

print(ans[0])

Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Set<String> set = new TreeSet<>();
        String s = scanner.next();
        int k = scanner.nextInt();
        for(int i = 0; i < s.length(); i++){
            for(int j = 1; j <= k; j++){
                if(i+j <= s.length()){
                    set.add(s.substring(i,i+j));
                }
            }
        }
        int count = 1;
        for(String cur : set){
            if(count == k){
                System.out.println(cur);
            }
            count++;
        }
    }
}


Measured memory_bytes: 25556
let n, a, b, s = Scanf.scanf " %d %d %d %s" @@ fun a b c d -> a, b, c, d
let p, r = ref 0, ref 0
let _ = String.iter (fun c -> print_endline @@ if !p < a + b then if c = 'a' then (incr p; "Yes") else if c = 'b' then (incr r; if !r <= b then (incr p; "Yes") else "No") else "No" else "No") s

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main()
{
	bool foundp=0,foundw=0,foundy=0,foundg=0;
	int color=0;
	char a;
	int n,x;
	cin>>n;
	for(x=1;x<=n;x++)
	{
		cin>>a;
		if(foundp==0&&a=='P')
		{
			foundp=1;
			color++;
		}
		else if(foundw==0&&a=='W')
		{
			foundw=1;
			color++;
		}
		else if(foundy==0&&a=='Y')
		{
			foundy=1;
			color++;
		}
		else if(foundg==0&&a=='G')
		{
			foundg=1;
			color++;
		}
	}
	if(color==1)
	{
		cout<<"One"<<endl;
	}
	else if(color==2)
	{
		cout<<"Two"<<endl;
	}
	else if(color==3)
	{
		cout<<"Three"<<endl;
	}
	else if(color==4)
	{
		cout<<"Four"<<endl;
	}
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  long x,y;
  cin>>x>>y;

  if(x%y == 0) cout << -1 << endl;
  else cout << x << endl;

  return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 1;i<=N;i++){
        cin >> retu.at(i-1);
        retu.at(i-1) -= i;
    }

    sort(retu.begin(),retu.end());

    long long ans = 0;
    long long ans1 = 0,ans2 = 0;

    if(N%2 == 1){
        int mid = retu.at(N/2);
        for(int i = 0;i<N;i++){
            ans += abs(retu.at(i) - mid);
        }
        cout << ans << endl;
    }
    else{
        int mid1 = retu.at(N/2-1);
        for(int i = 0;i<N;i++){
            ans1 += abs(retu.at(i)-mid1);
        }
        int mid2 = retu.at(N/2);
        for(int i = 0;i<N;i++){
            ans2 += abs(retu.at(i)-mid2);
        }
        cout << min(ans1,ans2) << endl;
    }

    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

const ll M = 1e9 + 1;

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

    unordered_map<int, int> order;
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        order[num]++;
    }

    int ans = 0;
    for (auto itr = order.begin(); itr != order.end(); itr++)
    {
        // cout << itr->first << " : " << itr->second << endl;
        auto key = itr->first;
        auto value = itr->second;

        if (key < value)
        {
            ans += value - key;
        }
        else if (key > value)
        {
            ans += value;
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 4260
package main

import (
	"fmt"
)

func main() {

	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	s := make([]int, M)
	c := make([]int, M)
	number := make([]int, N)
	for i := 0; i < N; i++ {
		number[i] = -1
	}

	var flag int = 0
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %d", &s[i], &c[i])
		if number[s[i]-1] == -1 {
			number[s[i]-1] = c[i]
		} else if number[s[i]-1] != -1 && number[s[i]-1] != c[i] {
			flag = 1
		}
	}

	if N > 1 {
		if number[0] == 0 {
			flag = 1
		} else if number[0] == -1 {
			number[0] = 1
		}

		for i := 1; i < N; i++ {
			if number[i] == -1 {
				number[i] = 0
			}
		}
	} else if N == 1 {
		if number[0] == -1 {
			number[0] = 0
		}
	}

	if flag == 1 {
		fmt.Println("-1")
	} else {
		for i := 0; i < N; i++ {
			fmt.Printf("%d", number[i])
		}
		fmt.Printf("\n")
	}
}


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

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif

typedef long long                LL;
typedef vector < int >           VI;
typedef pair < int,int >         II;
typedef vector < II >            VII;

#define MOD                      1000000007
#define EPS                      1e-12
#define N                        2100
#define PB                       push_back
#define MP                       make_pair
#define F                        first 
#define S                        second
#define ALL(v)                   v.begin(),v.end()
#define SZ(a)                    (int)a.size()
#define FILL(a,b)                memset(a,b,sizeof(a))
#define SI(n)                    scanf("%d",&n)
#define SLL(n)                   scanf("%lld",&n)
#define PLLN(n)                  printf("%lld\n",n)
#define PIN(n)                   printf("%d\n",n)
#define REP(i,j,n)               for(LL i=j;i<n;i++)
#define PER(i,j,n)               for(LL i=n-1;i>=j;i--)
#define endl                     '\n'
#define fast_io                  ios_base::sync_with_stdio(false);cin.tie(NULL)
int x , cnt;
VI g[N];
void dfs(int u , int p , int dep) {
  if(dep > x) cnt ++;
  for(int v : g[u])
    if(v != p)
      dfs(v , u , dep + 1);
}
int main() {
  int n , k; SI(n); SI(k);
  REP(i,0,n-1) {
    int u,v; SI(u); SI(v);
    g[u].PB(v); g[v].PB(u);
  }
  bool odd = false;
  if(k & 1) odd = true;
  x = k/2;
  int ans = n;
  if(!odd)
    REP(i,1,n+1) {
      cnt = 0;
      dfs(i , 0 , 0);
      ans = min(ans , cnt);
    }
  else {
    REP(i,1,n+1) {
      for(int j : g[i]) {
        cnt = 0;
        dfs(i , j , 0);
        dfs(j , i , 0);
        ans = min(ans , cnt);
      }
    }
  }
  PIN(ans);
  return 0;
}


Measured memory_bytes: 384
# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]==dis[1] and senter[0]==dis[0]):
    print(str(S/2) +" "+str(1))
else:
    print(str(S/2) +  " "+ str(0))

Measured memory_bytes: 3064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    priority_queue<ll> pq;
    rep(i,0,N) pq.push(A[i]);
    rep(i,0,M){
        if(pq.empty()) break;
        ll p = pq.top();
        pq.pop();
        pq.push(p/2);
    }
    ll ans = 0;
    while(not pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    print(ans);

    
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n,e,T;
ll dp[100010];
int dis[100010];
ll inf=1LL<<60;

struct node{
    int s,e,m;
    ll mini=0;
    node *l,*r;
    node(int a,int b){
        s=a;e=b;m=(a+b)/2;
        if(s==e)return;
        l=new node(s,m);
        r=new node(m+1,e);
    }
    void update(int pos,int val){
        if(s==e){
            mini=val;
            return;
        }
        if(pos<=m)l->update(pos,val);
        else r->update(pos,val);
        mini=min(l->mini,r->mini);
    }
    ll query(int a,int b){
        if(a>b)return inf;
        if(s==a && b==e){
            return mini;
        }
        if(b<=m)return l->query(a,b);
        if(m<a)return r->query(a,b);
        return min(l->query(a,m),r->query(m+1,b));
    }
};

int main() {
    //freopen("hi.txt", "r", stdin);
    scanf("%d%d%d",&n,&e,&T);
    /// dp[x] = dp[i] + 3(dis[x]-dis[i+1]) + (dis[i+1]-dis[i]) + max(0,T-2(dis[x]-dis[i+1]))
    for(int i=1;i<=n;i++){
        scanf("%d",&dis[i]);
    }
    node *wait,*nowait;
    wait=new node(0,n);
    nowait=new node(0,n);
    int waitpos=0;
    for(int x=1;x<=n;x++){
        wait->update(x-1,dp[x-1]-2LL*dis[x]-dis[x-1]+2LL*dis[x]);
        nowait->update(x-1,dp[x-1]-2LL*dis[x]-dis[x-1]);
        while(waitpos<x && T-2*(dis[x]-dis[waitpos+1])<0){
            waitpos++;
        }
        dp[x]=inf;
        ///ll ans=dp[i] +3LL*dis[x]-2LL*dis[i+1]-dis[i];
        ///ans+=max(0LL,(ll)T-2*(dis[x]-dis[i+1]));
        ll ans=nowait->query(0,waitpos-1)+3LL*dis[x];
        dp[x]=min(dp[x],ans);
        ans=wait->query(waitpos,x-1)+3LL*dis[x]+T-2*dis[x];
        dp[x]=min(dp[x],ans);
        //printf("dp %d = %lld\n",x,dp[x]);
    }
    printf("%lld\n",dp[n]+e-dis[n]);
}


Measured memory_bytes: 20224
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string S; cin >> S;
    repp(i, 0, (int)S.size()) cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

r,D,x = inpl()

for i in range(10):
    x = r*x - D
    print(x)


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

namespace MyProgram{
    public class Program
    {	
        public static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            List<char> list = new List<char>();
            
            for(int i = 0 ; i < s.Length ; i++)
            {
                if(s[i]=='B')
                {
                    if(list.Count > 0)list.RemoveAt(list.Count-1);
                }
                else
                {
                    list.Add(s[i]);
                }
            }
            string ss = String.Join("",list);
            Console.WriteLine(ss);
    	}
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

ll kai[200009];

// mod付きpower
// x^n
ll modpow(ll x, int n) {
	if (n == 0) return 1LL;
	else if (n % 2 == 0) return modpow((x * x) % MOD, n / 2) % MOD;
	else return (modpow((x * x) % MOD, n / 2) * x) % MOD;
}

// a/bを返す
ll divMod(ll a, ll b) {
	ll res = a * modpow(b, MOD - 2);
	return res % MOD;
}

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

	ll N, K; cin >> N >> K;
	kai[0] = 1;
	for (ll i = 1; i <= 200007; i++) kai[i] = (kai[i - 1] * i) % MOD;
	//for (int i = 0; i < 10; i++) cout << kai[i] << " ";

	ll ans = 1;
	for (int i = 1; i <= min(K, N - 1); i++) {
		ll cnt = kai[N];
		cnt = divMod(cnt, kai[i]);
		cnt = divMod(cnt, kai[N - i]);
		//cout << "n" << "C" << i << " is" << cnt << endl;

		cnt *= kai[N - 1]; cnt %= MOD;
		cnt = divMod(cnt, kai[i]);
		cnt = divMod(cnt, kai[N - 1 - i]);

		//cout << cnt << endl;

		ans += cnt;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    int a,b,c,d,p;
    cin >> a >> b >> c >>d >>p;
    int x = p*a;
    int y;
    if (p<=c) {
        y = b;
    }else{
        y = b + d*(p-c);
    }
    cout << min(x,y)<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

string s;

vector<vector<char> > b{
  vector<char>{},
  vector<char>{'.',',','!','?',' '},
  vector<char>{'a','b','c'},
  vector<char>{'d','e','f'},
  vector<char>{'g','h','i'},
  vector<char>{'j','k','l'},
  vector<char>{'m','n','o'},
  vector<char>{'p','q','r','s'},
  vector<char>{'t','u','v'},
  vector<char>{'w','x','y','z'},
};
int main(){ _;
  int n;cin>>n;
  REP(i,n){
    cin>>s;
    int last=0;
    int count=0;
    for(int j=0;j<(int)s.size();j++){
      if(last==0){
	count=0;
      }else if(s[j]=='0'){
	cout<<b[last][count%(int)b[last].size()];
      }else{
	count++;
      }
      last=(s[j]-'0');
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1220
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    B = list(map(int, input().split(' ')))
    result = 0
    dead_enemy = min([A[0], B[0]])  # at town 1
    result += dead_enemy
    rest_power = B[0] - dead_enemy
    for i in range(1, N + 1):
        # (i-1)-th brave result
        dead_enemy = min([A[i], rest_power])
        result += dead_enemy
        rest_enemy = A[i] - dead_enemy
        # i-th brave result
        if i <= N - 1:
            dead_enemy = min([rest_enemy, B[i]])
            result += dead_enemy
            rest_power = B[i] - dead_enemy
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18380
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s; cin >> s;
    rep(i, 3) cout << ((s[i] == '9') ? "1" : "9");
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  string s;
  cin >> s;
  int a = 0;
  for (char c : s) {
    a += c - '0';
  }
  if (a % 9 == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3768
// ABC161C - Replacing Integer

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int N, K;
	cin >> N >> K;

	long long int ans;
	ans = N % K;
	ans = min(ans, abs(ans - K));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  int p;
  int l;
  int r;
}Tree;

int n;
Tree tree[25];

void inorder(int a){
 
  if(tree[a].l != -1)inorder(tree[a].l);
  
  printf(" %d",a);

  if(tree[a].r != -1)inorder(tree[a].r);
   
}

  
void preorder(int a){
 
  printf(" %d",a);
  
  if(tree[a].l != -1)preorder(tree[a].l);

  if(tree[a].r != -1)preorder(tree[a].r);

}

void postorder(int a){
  
  if(tree[a].l != -1)postorder(tree[a].l);

  if(tree[a].r != -1)postorder(tree[a].r);

  printf(" %d",a);
 
}

int main(){
  
  int i,id,parent;

  scanf("%d",&n);
  
   for(i = 0; i < n; i++){
     tree[i].p = -1;
   }
  
  for(i = 0; i < n; i++){
    scanf("%d",&id);
    scanf("%d%d",&tree[id].l,&tree[id].r);
    if(tree[id].l != -1)tree[tree[id].l].p = id;
    if(tree[id].r != -1)tree[tree[id].r].p = id;
   }
  
  for(i = 0; i < n; i++){
    if(tree[i].p == -1){
      parent = i;
      break;
    }
  }
  
  printf("Preorder\n");
  preorder(parent);
  printf("\n");
  
  printf("Inorder\n");
  inorder(parent);
  printf("\n");
  
  printf("Postorder\n");
  postorder(parent);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2112
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest117-C
#  TODO https://atcoder.jp/contests/abc117/tasks/abc117_c

def solveProblem(chessman,checkPointCount,checkPointListOrg):
	if checkPointCount <= chessman:
		answer = 0
	else:
		checkPointList = sorted(checkPointListOrg)
		allLong = checkPointList[-1]-checkPointList[0]
		distanceList=list()
		checkPointRange= range(0,len(checkPointList)-1,+1)
		for i in checkPointRange:
			distanceList.append(checkPointList[i+1]-checkPointList[i])
		distanceList.sort(reverse=True)
		openLine = sum(distanceList[0:chessman-1])
		answer = allLong-openLine
	return answer

if __name__ == '__main__':
	N,M = map(int,(input().strip().split(' ')))
	Xi = list(map(int,input().strip().split(' ')))
	solution = solveProblem(N,M,Xi)
	print("{}".format(solution))


Measured memory_bytes: 13960
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
 
int n;
int a[200005];
long long ans;
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i],a[i]-=i;
	sort(a+1,a+1+n);
	for(i=1;i<=n;i++)
		ans+=abs(a[i]-a[(n+1)/2]);
	cout<<ans<<endl;
} 

Measured memory_bytes: 1024