akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MX = 100 * 1000 + 7;

ll a[MX], b[MX];
int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i++) {
        b[i] = a[i] + b[i - 1];
    }

    int ptr = n;
    while (ptr - 1 >= 1 && b[ptr - 1] * 2 >= a[ptr]) {
        ptr--;
    }

    cout << n - ptr + 1 << endl;
}


Measured memory_bytes: 1792
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var d = int.Parse(spl[0]);
        var n = int.Parse(spl[1]);

        if (d == 0) {
            if (n == 100) return 101;
            return n;
        }

        if (n == 100) n++;
        return Pow(100,d) * n;
    }

    static long Pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                ans = ans * x;
            }
            x = x * x;
            n /= 2;
        }
        return ans;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll f(ll n, ll x){
    if(n >= 0)return n / x + 1;
    return 0;
}

int main(){
    
    ll a, b, x;
    cin >> a >> b >> x;
    cout << f(b, x) - f(a - 1, x) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n == 0) break;
    multiset<int> slist,elist;
    for(int i=0; i<n; i++){
      int h1,h2,m1,m2,s1,s2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
      int s = h1 * 3600 + m1 * 60 + s1;
      slist.insert(s);
      int e = h2 * 3600 + m2 * 60 + s2;
      elist.insert(e);
    }
    int ret = 0, count = 0;
    multiset<int>::iterator its = slist.begin(), ite = elist.begin();
    while(its != slist.end()){
      if((*its) < (*ite)){
        count++;
        its++;
        if(count > ret) ret = count;
      }else{
        count--;
        ite++;
      }
    }
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 2128
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func relates3(n int) {
	check:
	for i := 3; i <= n; i++ {
		if i % 3 == 0 {
			fmt.Printf(" %d",i)
			continue check
		} else {
			for x := i; x > 0; x /= 10 {
				if x % 10 == 3 {
					fmt.Printf(" %d",i)
					continue check
				} 
			}
		}
	}

	fmt.Println()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	relates3(n)
}


Measured memory_bytes: 1112
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    H, W = MAP()
    S = ['.'*(W + 2), *['.' + INPUT() + '.' for _ in range(H)], '.'*(W + 2)]

    ans = ["" for _ in range(H)]
    dy = [0, -1, -1, -1, 0, 1, 1, 1]
    dx = [1, 1, 0, -1, -1, -1, 0, 1]
    for i in range(H):
        for j in range(W):
            if S[i+1][j+1] == '#':
                ans[i] += '#'
                continue

            cnt = 0
            for y, x in zip(dy, dx):
                if S[i+1+y][j+1+x] == '#':
                    cnt += 1

            ans[i] += str(cnt)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9908
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    a,b,c,d=mi()

    print(max(a*c,a*d,b*c,b*d))





if __name__ == "__main__":
    main()

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

int f (int n) {
    int t = 1;
    while (t <= n) t *= 2;
    return t;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for (auto& e : a) { cin >> e; mp[e]++; }
    sort(a.rbegin(), a.rend());
    
    int ans = 0;
    for (const auto& x : a) if (mp[x] > 0) {
        int b = f(x) - x;
        if (mp.count(b)) if (mp[b] > 0) {
            if (x != b) {
                ans++; mp[x]--; mp[b]--;
            } else if (mp[b] > 1) {
                ans++; mp[x]--; mp[b]--;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        String str = scan.next();
        if (Character.isUpperCase( str.charAt( 0 ) )) {
            System.out.println("A");
        } else 
            System.out.println("a");

    }
}


Measured memory_bytes: 35384
#include <bits/stdc++.h>
#define sort stable_sort
using namespace std; 

int _; 

int n,ans,a[1005];

int main()
{ 
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	sort(a,a+n); 
	for(int i=0;i<n;i++)
		for(int k=i+1;k<n;k++)
			for(int j=k+1;j<n;j++)
				if(a[i]+a[k]>a[j] && a[i] != a[k] && a[j] != a[k])
					ans++; 
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 3760
import bisect
n = int(raw_input())
edges = list(map(int, raw_input().split(" ")))


def solve():
	edges.sort()
	ans = 0

	for i in range(len(edges)):
		for j in range(i+1, len(edges)):
			sum_of_two = edges[i] + edges[j]
			idx = bisect.bisect_left(edges, sum_of_two)

			if idx-1 > j:
				ans += idx-1-j
	return ans 
print(solve())

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

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> dups = new ArrayList<Integer>();
    ArrayList<Integer> list = new ArrayList<Integer>();
    int N = sc.nextInt();
    for(int i = 0; i < N; i++) {
      int curr = sc.nextInt();
      if(!list.contains(curr)) {
        list.add(curr);
      }
    }
    System.out.println(list.size());
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
    int N;
    int i;
    
    scanf("%d", &N);
    
    for(i=1;i<=N;i++){
        if(i*i > N){
            printf("%d\n", (i-1)*(i-1));
            return 0;
        }else if(i*i == N){
            printf("%d\n", i*i);
            return 0;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <map>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int * b = new int[n];
    int sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> b[i];
        if (i > 0)
        {
            sum += b[i] > b[i - 1] ? b[i - 1] : b[i];
        }
    }
    sum += b[0] + b[n - 2];
    cout << sum;

    delete[] b;
    return 0;
}


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

int main(void)
{
	int n, a[100], num = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		for(int j = n - 1; j > 0; j--) {
			if(a[j - 1] > a[j]) {
				swap(a[j - 1], a[j]);
				num++;
			}
		}
	}
	for(int i = 0; i < n; i++) {
		cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < N; i++)
#define INF (INT64_MAX /2)


























int main() {
    long long N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += N / i;
        if (N %i == 0) ans--;
    }   
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	int ans=0;
	ans= arr[n/2]-arr[n/2-1];

	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

/*

*/

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

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        // String match1 = "[A-Z]";
        // String match2 = "[a-z]";

        // if (a.matches(match1)) {
        //     System.out.println("A");
        // } else {
            System.out.println(a + a*a + a*a*a);
        // }

    }
}

Measured memory_bytes: 35812
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		
		if (D == 0 && N < 100) {
			System.out.println(N);
		} else if (D == 0 && N == 100) {
			System.out.println(101);
		} else if (D == 1 && N == 100) {
			System.out.println(100 * 101);
		} else if (D == 1) {
			System.out.println(100 * N);
		} else if (D == 2 && N == 100) {
			System.out.println(100 * 100 * 101);
		} else if (D == 2) {
			System.out.println(100 * 100 * N);
		}
	}
	
}

Measured memory_bytes: 21844
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
ll counter;

int main() {
	ll a = 0, b = 0, n = 0, counter = 0, maxi = 0;
	ll nums[100002];
	std::string str, str2;
	cin >> a;
	cout << a*a*a << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//最大公約数
ll gcd(ll a,ll b)
{
    if(a%b == 0)
        return b;
    else
        return gcd(b, a % b);
}

double arr[10];
/*
int main(){
    cin >> n;
    ll p[20];
    for (ll i = 0; i < n;i++)
    {
        cin >> p[n];
        //cout << p[n] << endl;
    }
    ll count = 0;
    for (ll i = 1; i < (n - 1);i++)
    {
        if(((p[i-1]-p[i]>0) && (p[i]-p[i+1]>0)) ||  ((p[i+1]-p[i]>0)&&(p[i]-p[i-1]>0)))
        {
            count++;
            //cout << i << count << endl;
        
        }
    }
    cout << count << endl;
}
*/

int main()
{
    ll n;
    cin >> n;
    ll d[100000];
    for (ll i = 0; i < n;i++)
    {
        cin >> d[i];
    }
    sort(d, d + n);
    ll s = d[(n / 2) - 1];
    ll l = d[n / 2];
    cout << l - s;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}



int main(void) {
    FAST_IO;
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
    
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin>>S>>T;
    int N=S.size(), M=T.size();
    vi sumS(N+1);
    vi sumT(M+1);
    rep(i,N) sumS[i+1]=sumS[i]+(S[i]=='A');
    rep(i,M) sumT[i+1]=sumT[i]+(T[i]=='A');
    // dbrep(sumS,N+1);
    // dbrep(sumT,M+1);

    int Q; cin>>Q;
    auto checkType = [](vi &sum, int a, int b){
        int cntA = sum[b]-sum[a];
        int cntB = (b-a)-cntA;
        int diff = abs(cntA-cntB) % 3;
        if (cntA>cntB && diff==1) return 1;
        if (cntA>cntB && diff==2) return 2;
        if (cntA<cntB && diff==1) return 2;
        if (cntA<cntB && diff==2) return 1;
        return 0;
    };
    while(Q--){
        int a,b,c,d; cin>>a>>b>>c>>d; a--; c--;
        int t1 = checkType(sumS,a,b);
        int t2 = checkType(sumT,c,d);
        cout<<(t1==t2?"YES":"NO")<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4236
import numpy
a, b, h, m = list(map(int, input().split()))

t_angle = (h * 30) + (m * 0.5) # 30 = 360 / 12, 0.5 = 30 / 60
b_angle = m * 6 # 6 = 360 / 60
space_angle = abs(b_angle - t_angle)
c2 = (a * a + b * b) - (2 * a * b * numpy.cos(numpy.radians(space_angle)))
print(numpy.sqrt(c2))

Measured memory_bytes: 27196
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    char a, b;
    std::cin >> a >> b;
    std::cout << ((a=='D')^(b=='D')?'D':'H') << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define mod 1000000007
#define long long long
int arr[100000];
int dp[100000];

int main(){
    long n;cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    for(int i=0;i<n;i++){
        dp[i]=mod;
    }dp[0]=0;
    for(int i=0;i<n;i++){
        if(i+1<n){dp[i+1]=min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1]));}
        if(i+2<n){dp[i+2]=min(dp[i+2],dp[i]+abs(arr[i]-arr[i+2]));}
    }
    
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b,c;
  cin>>a>>b;
  if((a+b)%2==0)
    ans((a+b)/2);
  else ans("IMPOSSIBLE");
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
mem = defaultdict(int)
def g(a,b):
    a,b = max(a,b),min(a,b)
    if mem[(a,b)]:return mem[(a,b)]
    c,d = a,b
    while b:a,b=b,a%b
    mem[(c,d)] = a
    return a
d = defaultdict(int)
K = int(input())
ans = 0
lis = []
for a in range(1,K+1):
    for b in range(1,K+1):
        lis.append(g(a,b))
        d[g(a,b)] += 1
lis = list(set(lis))
for c in range(1,K+1):
    for l in lis:
        ans += (d[l]*g(c,l))

print(ans)

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  queue<char> aa;
  queue<char> bb;
  queue<char> cc;
  for(char x : a) aa.push(x);
  for(char x : b) bb.push(x);
  for(char x : c) cc.push(x);
  
  int look=0;
  char res;
  while(1){
    if(look==0){
      if(aa.empty()){
        res='A';break;
      }
      look = (int)aa.front()-97;
      aa.pop();
    }
    if(look==1){
      if(bb.empty()){
        res='B';break;
      }
      look = (int)bb.front()-97;
      bb.pop();
    }
    if(look==2){
      if(cc.empty()){
        res='C';break;
      }
      look = (int)cc.front()-97;
      cc.pop();
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
import collections
def inpl(): return list(map(int, input().split()))

#### START
X = int(input())
l = []
for i in range(1, 1000):
  for j in range(2, 11):
    if not i**j in l:
      l.append(i**j)

l.sort(reverse=True)
for i in l:
  if i<=X:
    print(i)
    break

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String  s = scan.next();
		String  t = scan.next();
		String ans = "No";

		if(s.length() + 1 == t.length() ) {
			if(s.equals(t.substring(0 ,s.length()))) {
				ans = "Yes";
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27008
n, q = gets.split.map(&:to_i)
s = gets.chomp
a = [0]
(1...n).each do |i|
  a[i] = a[i-1] + (s[i-1, 2] == 'AC' ? 1 : 0)
end
q.times do
  l, r = gets.split.map(&:to_i)
  puts a[r-1] - a[l-1]
end

Measured memory_bytes: 3452
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  rep (i, N) cin >> A[i];
  vector<long> F(N);
  rep (i, N) cin >> F[i];

  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());

  long foo_score = 0;
  long foo_K = 0;
  rep (i, N) foo_K += A[i];

  long bar_score = 0;
  rep (i, N) bar_score = max(bar_score, A[i] * F[i]);
  long bar_K = 0;

/*
  cout << "foo_score: " << foo_score << endl;
  cout << "foo_K: " << foo_K << endl;
  cout << "bar_score: " << bar_score << endl;
  cout << "bar_K: " << bar_K << endl;
*/

  if (foo_K <= K) {
    cout << foo_score << endl;
    return;
  }

  if (K == 0) {
    cout << bar_score << endl;
    return;
  }

  while (foo_score + 1 < bar_score) {
    long mid_score = (foo_score + bar_score) / 2;
    long mid_K = 0;
    rep (i, N) {
      long target_A = mid_score / F[i];
      if (target_A >= A[i])  continue;
      mid_K += A[i] - target_A;
    }

    if (mid_K <= K) {
      bar_score = mid_score;
      bar_K = mid_K;
    } else {
      foo_score = mid_score;
      foo_K = mid_K;
    }

/*
    cout << "---------" << endl;
    cout << "mid_score: " << mid_score << endl;
    cout << "mid_K: " << mid_K << endl;
    cout << "foo_score: " << foo_score << endl;
    cout << "foo_K: " << foo_K << endl;
    cout << "bar_score: " << bar_score << endl;
    cout << "bar_K: " << bar_K << endl;
*/
  }

  cout << bar_score << endl;
  return;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
    string s, t;
    cin >> s ;
    cin >> t;
    int num = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) num++;
    }
    cout << num ;
  //  system("pause");
}

Measured memory_bytes: 3452
n = int(input())
link = {}

for i in range(n):
    a = list(map(int, input().split()))
    a.reverse()

    u, k = a.pop(), a.pop()
    link[u] = []
    for j in range(k):
        link[u] += [a.pop()]

d, f = {}, {}
t = 0


def dfs(u):
    global t
    t += 1
    d[u] = t

    for v in link[u]:
        if v not in d: dfs(v)

    if u not in f:
        t += 1
        f[u] = t


for u in range(1, n + 1):
    if u not in d: dfs(u)

for i in range(1, n + 1):
    print(i, d[i], f[i])



Measured memory_bytes: 5660
A,B,C,D,E,F = map(int,input().split())

Ws = set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1-a,100*B):
        Ws.add(a+b)

Ss = set()
for c in range(0,F+1,C):
    for d in range(0,F+1-c,D):
        Ss.add(c+d)

ans = set()
for w in Ws:
    for s in Ss:
        if 0<w+s<=F and s<=(w//100)*E:
            ans.add((s/(w+s),w,s))
ans = sorted(ans,reverse=True)
print(ans[0][1]+ans[0][2],ans[0][2])

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

typedef long long ll;

ll n;
ll x[100005];
ll d[100005];
ll y[100005];
ll i;

ll mod = 1000000007;

ll fact[500005],rfact[500005];
vector <ll> G[1000005];
bool used[1000005];
bool used2[1000005];

ll ynum;

ll pow(ll x,ll n){
	if(n == 0){
		return 1;
	}else if(n == 1){
		return x;
	}
	if(n % 2 == 1){
		return (pow(x,n-1) * x)% mod;
	}else{
		ll num = pow(x,n/2);
		return (num*num) % mod;
	}
}


void init(){
	fact[0] = 1;
	for(ll i=1;i<=500000;i++){
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
	}
	rfact[500000] = pow(fact[500000],mod-2);
	for(ll i=499999;i>=0;i--){
		rfact[i] = rfact[i+1] * (i + 1);
		rfact[i] %= mod;
	}
}

ll dfs(ll v){
	used[v] = true;
	ll sum = 1;
	for(int i=0;i<G[v].size();i++){
		ll nv = G[v][i];
		if(used[nv])continue;
		sum += dfs(nv);
	}
	return sum;
}

ll dfs2(ll v){
	used2[v] = true;
	ll sum = G[v].size();
	for(int i=0;i<G[v].size();i++){
		ll nv = G[v][i];
		if(used2[nv])continue;
		sum += dfs2(nv);
	}
	return sum;
}

ll c3(ll n,ll r){
	//nCr
	ll res1 = fact[n];
	ll res2 = rfact[r];
	ll res3 = rfact[n-r];
	return (((res1 * res2) % mod) * res3) % mod;
}


bool solve(){
	cin >> n;
	ynum = 0;
	if(n == 0){
		return false;
	}
	d[0] = 0;
	for(int i=0;i<n;i++){
		cin >> x[i];
		d[i+1] = 0;
		y[i] = 0;
		G[i].clear();
		used[i] = false;
		used2[i] = false;
	}
	used[n] = false;
	used2[n] = false;


	G[n].clear();
	y[n] = 0;
	for(i=0;i<n;i++){
		if(find(G[i+1].begin(),G[i+1].end(),x[i]) == G[i+1].end()){
			G[i+1].push_back(x[i]);
			G[x[i]].push_back(i+1);
			d[x[i]]++;
			d[i+1]++;
		}
	}
	for(i=1;i<=n;i++){
		if(d[i] >= 3){
			cout << 0 << endl;
			return true;
		}
	}
	for(i=1;i<=n;i++){
		if(!used[i]){
			y[ynum] = dfs(i);
			if(dfs2(i) != 2 * y[ynum] - 2){
				cout << 0 << endl;
				return true;
			}
			ynum ++;
		}
	}
	ll two = 0,three = 0;
	for(int i=0;i<ynum;i++){
		if(y[i] == 2){
			two++;
		}else if(y[i] >= 3){
			three++;
		}else{
			cout << 0 << endl;
			return true;
		}
		//cout << y[i] << " ";
	}
	//cout << endl;
	ll ans = 0;
	//cout << endl;
	for(int i=0;i<=two/2;i++){
		ll res1 = (three + 1) * fact[two + three - 2 * i];
		res1 %= mod;
		res1 *= pow(2ll,two + three);
		res1 %= mod;
		res1 *= c3(two,2*i);
		res1 %= mod;
		res1 *= fact[2*i];
		res1 %= mod;
		//cout << "res = " << res1 << endl;
		ans += res1;
		ans %= mod;
		//cout << ans << endl;
	}
	ans %= mod;
	cout << ans << endl;
	return true;

}




int main(){
	init();
	while(solve()){}
	return 0;
}


Measured memory_bytes: 41188
def p_a():
    H, W, A, B = map(int, input().split())

    S = [[0] * W for _ in range(H)]

    if A == 0 and B == 0:
        for i in range(H):
            print(*S[i], sep="")
        exit()

    for i in range(B):
        for j in range(A):
            S[i][j] = 1

    for i in range(B, H):
        for j in range(A, W):
            S[i][j] = 1

    for i in range(H):
        print(*S[i], sep="")

if __name__ == '__main__':
    p_a()


Measured memory_bytes: 78172
import sys
readline = sys.stdin.readline
from bisect import bisect_right

def main():
    N, M, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    B = list(map(int, readline().rstrip().split()))

    a_acc, b_acc = A[:], B[:]
    for i in range(1, N):
        a_acc[i] += a_acc[i-1]
    
    for i in range(1, M):
        b_acc[i] += b_acc[i-1]
    
    res = 0
    for i, a in enumerate(a_acc):
        if a >= K:
            break
        left = K - a
        j = bisect_right(b_acc, left)
        res = max(res, i + 1 + j)
    
    res = max(res, bisect_right(a_acc, K))
    res = max(res, bisect_right(b_acc, K))

    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47572
import sys

n,m = map(int,input().split())
num_list = [list(map(int,input().split())) for _ in range(m)]

if n == 1:
    min_num = 0
    max_num = 9
elif n == 2:
    min_num = 10
    max_num = 99
else:
    min_num = 100
    max_num = 999

for i in range(min_num,max_num+1):
    num_str = str(i)
    count = 0
    for elem in num_list:
        idx = elem[0]-1
        if num_str[idx] == str(elem[1]):
            count += 1
        else:
            break
    if count == m:
        print(num_str)
        sys.exit()


print('-1')

Measured memory_bytes: 3064
#include <cstdio>

using namespace std;

int main()
{
  long long a, b1, b2;
  scanf("%lld %lld.%lld", &a, &b1, &b2);
  
  printf("%lld\n", a * (b1 * 100 + b2) / 100);
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<string> a(n+1);

    for(int i=0;i<n;i++){
        cin >> a[i+1];
    }

    if(n%2==1){
        for(int i=n;i>0;i-=2){
            cout << a[i] << " ";
        }
        for(int i=2;i<n;i+=2){
            cout << a[i] << " ";
        }
    }
    else{
        for(int i=n;i>0;i-=2){
            cout << a[i] << " ";
        }
        for(int i=1;i<n;i+=2){
            cout << a[i] << " ";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))
 
int main(){
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++){
        S.push_back(S[0]);
        S.erase(S.begin());
        if(S == T){
            Yes(true);
            return 0;
        }
    }
    Yes(false);
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A,B,C,K = map(int, readline().split())

    if K <= A:
        ans = K
    elif A < K <= A + B:
        ans = A
    else:
        ans = A - (K - (A+B))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
<?php

fscanf(STDIN, "%d", $n);
$input = trim(fgets(STDIN));
$p_arr = explode(' ', $input);

$count = 0;
foreach ($p_arr as $i => $p) {
    if ($p != $i + 1) {
        ++$count;
    }
}

echo ($count === 2) || ($count === 0) ? 'YES' : 'NO';


Measured memory_bytes: 4984
#include<iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  int ans=0;
  if(A>B){
    ans+=A;
    A--;
  }
  else{
    ans+=B;
    B--;
  }
  if(A>B){
    ans+=A;
    A--;
  }
  else{
    ans+=B;
    B--;
  }
  cout<<ans;
  

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  string s;
  int size;
  int r_count = 0;
  int l_count = 0;
  int position = 0;
  vector<int> r_length;
  vector<int> l_length;
  vector<int> h;
  cin >> s;
  size = s.size();
  for(int i=0; i<s.size(); i++){
    h.push_back(0);
  }
  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='R'){
      r_count++;
      if(l_count!=0){
        l_length.push_back(l_count);
        l_count=0;
      }
    }else{
      l_count++;
      if(r_count!=0){
        r_length.push_back(r_count);
        r_count=0;
      }
      if(i==s.size()-1){
        l_length.push_back(l_count);
        l_count=0;        
      }
    }
  }
  int tmp_r;
  int tmp_l;
  for(int i = 0; i < r_length.size(); i++){
    position += r_length.at(i);
    tmp_r = (r_length.at(i) + 1) / 2;
    h.at(position-1) += tmp_r;
    h.at(position) += r_length.at(i) - tmp_r;
    tmp_l = (l_length.at(i) + 1) / 2;
    h.at(position) += tmp_l;
    h.at(position-1) += l_length.at(i) - tmp_l;
    position += l_length.at(i);
  }
  for(int i=0; i<s.size(); i++){
    cout << h.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1784
import numpy as np


def main():
    h, w = map(int, input().split())
    sss = [list(input()) for _ in range(h)]
    check = [[0 for _ in range(w)] for _ in range(h)]
    move = [[-1, 0], [1, 0], [0, -1], [0, 1]]
    sharp_count = 0
    for i in range(h):
        for j in range(w):
            if sss[i][j] == '#':
                sharp_count += 1
                for k, l in move:
                    if i+k < h and i+k >= 0 and j+l < w and j+l >= 0:
                        if sss[i+k][j+l] == "#":
                            check[i][j] = 1
                            check[i+k][j+l] = 1
    if sharp_count == np.sum(check):
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 27124
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 104204
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n;

	int k = 1;
	int ct = 0;
	cin >> n;
	for(int i = 0; i< n; ++i)
	{
		int x;
		cin >> x;
		if(x == k)
		{
			ct++;
			k++;
		}
	}
	if(ct == 0)
		cout << -1;
	else
	{
		cout << n - ct;
		
	}
	

    return 0;
}

Measured memory_bytes: 256
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    cout<<(n+1)/2<<endl;
}   aryanc403();
    return 0;
}


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

constexpr int MaxN = 100000;

int main()
{
	int N;
	int64_t K;
	int64_t A[MaxN];

	cin >> N >> K;

	for (int i = 0; i < MaxN; ++i)
	{
		A[i] = 0;
	}

	for (int i = 0; i < N; ++i)
	{
		int a, b;
		cin >> a >> b;
		A[a - 1] += b;
	}

	for (int i = 0; i < MaxN; ++i)
	{
		K -= A[i];

		if (K <= 0)
		{
			cout << i + 1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
     while(true){
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1 || f == -1)cout << "F" << endl;
        else if (m + f >= 80)cout << "A" << endl;
        else if (m + f >= 65 && m + f < 80)cout << "B" << endl;
        else if (m + f >= 50 && m + f < 65)cout << "C" << endl;
        else if (m + f >= 30 && m + f < 50){
            if (r >= 50)cout << "C" << endl;
            else cout << "D" << endl;
        }
        else if (m + f < 30)cout << "F" << endl;
    }
}



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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		long ans = nextLong();

		for(int i=1;i<N;i++){
			ans=lcm(ans,nextLong());
		}
		System.out.println(ans);

	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
	public static long lcm(long a, long b) {
		long x, y;

		return ((a / gcd(a, b)) * b);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18
 
ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}
 
class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
 
    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        string str="abcdefghijklmnopqrstuvwxyz";
        vector<ll> ans;
        while(n!=0)
        {
            n--;
            ans.pb(n%26);
            n/=26;
        }

        reverse(ans.begin(),ans.end());

        for(auto i:ans)
        cout<<str[i];
    }
}

Measured memory_bytes: 3608
# データ読み込み

import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, B  = map(int,input_data().split())
A
out = ":("
if A <= 8 and B <= 8:
  out = "Yay!"

print(out)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const int N = 1e5+600;
ll a[N];
int main(){
    int n,m;
    cin>>n>>m;
    int mx = n;
    while(n--){
      int k;
      cin>>k;
      for(int i = 0; i < k; i++){
        int x;
        cin>>x;
        a[x]++;
      }
    }
    int sum = 0;
    for(int i = 1; i <= m;i++){
      if(a[i] == mx) sum++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int r;
	scanf("%d", &r);
	if(r>=2800){
		printf("AGC\n");
	}
	else if(r<2800 && r>=1200){
		printf("ARC\n");
	}
	else if(r<1200){
		printf("ABC\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
# sys.setrecursionlimit(10**7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
tmp_ans = n*(n-1)//2
ans = []
for i in range(m):
    ans.append(tmp_ans)
    a=ab[m-1-i][0]
    b=ab[m-1-i][1]
    a-=1
    b-=1
    if not uf.is_same(a,b):
        tmp_ans-=uf.size(a)*uf.size(b)
    uf.union(a,b)

ans.reverse()
for i in ans:
    print(i)


Measured memory_bytes: 33308
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string a;
  ll q[30];
  rep(i,26)q[i]=0;
  cin >> a;
  rep(i,a.length())q[a[i]-'a']++;
  rep(i,26){
    if(q[i]%2==1){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
}

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

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  vector<int> v(n, 1);
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == s[i]) v[i] = v[i - 1] + 1;
  }
  bool r = true;
  for (int i = min(a, b) - 1; i < max(c, d); i++) {
    r &= !(s[i] == '#' && v[i] > 1);
  }
  if (b < c && d < c) {
    bool t = false;
    for (int i = b - 1 + 1; i < d + 1; i++) {
      t |= s[i] == '.' && v[i] >= 3;
    }
    r &= t;
  }
  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1284
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
S,SS=[0]*(n+1),[0]*(n+1)
for i in range(n):
  S[i+1]=S[i]+A[i]
  SS[i+1]=SS[i]+max(0,A[i])
ans=-float("inf")
for i in range(n-k+1):
  ans=max(ans,SS[i]+SS[n]-SS[k+i]+max(0,S[k+i]-S[i]))
print(ans)

Measured memory_bytes: 16716
#include <iostream>
using namespace std;
int main()
{


    int H, A, count = 0;
    cin >> H >> A;
    while (H > 0)
    {
        H = H - A;
        count++;
    }
    if (H <= 0)
    {
        cout << count << endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  int min_a = *min_element(a,a+N);

  int dp[K+1];
  fill(dp,dp+K+1,0);
  for(int i=0;i<N;i++){
    dp[a[i]] = 1;
  }
  for(int i=0;i<min_a;i++){
    dp[i] = -1;
  }

  for(int i=0;i<=K;i++){
    if(dp[i]==0){
      bool extl = false;
      for(int j=0;j<N;j++){
        if(i - a[j] >= 0){
          if(dp[i-a[j]] == -1){
            extl = true;
            break;
          }
        }
      }
      if(extl) dp[i] = 1;
      else dp[i] = -1;
    }
  }

  if(dp[K] == 1) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;

}

Measured memory_bytes: 640
#
 
#include<stdio.h>
 
int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
 
    int s = a*b;
    int mawari = a*2+b*2;
     
    printf("%d %d\n", s, mawari);
 return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,x,i;
    cin>>n>>x;
    int ara[n+1];
    ara[0]=0;
    for(i=1;i<=n;i++)
        cin>>ara[i];
    int ans=0,cnt=0;
    i=0;
    while(1)
    {
        ans+=ara[i];
        if(ans>x)
            break;
        cnt++;
        i++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 100
#define MAX_M 100
 
int main(){
    int N,M,A[MAX_M],B;
    cin >> N >> M;
    for(int i = 0 ; i < M ; i++){
	cin >> A[i]; A[i]--;
    }
    int point[MAX_N] = {0};
    for(int i = 0 ; i < M ; i++){
	int X = 0;
	for(int j = 0 ; j < N ; j++){
	    cin >> B; B--;
	    if(A[i] != B){ X++; }
	    else{ point[j]++; }
	}
	point[A[i]] += X;
    }
    for(int i = 0 ; i < N ; i++){
	cout << point[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3096