akhauriyash/Code-Regression huggingface dataset:
int main(void)
{
	char s[101] = {0}, p[101] = {0}, temp[101] = {0};
	int s_len, p_len, i, j;

	scanf("%s", s);
	scanf("%s", p);
	s_len = strlen(s);
	p_len = strlen(p);
	for(i = 0;i < s_len;i++)
	{
		for(j = 0;j < p_len;j++)
			temp[j] = s[(i + j) % s_len];
		temp[j] = '\0';
		if(!strcmp(p, temp))
		{
			printf("Yes\n");
			break;
		}
	}
	if(i == s_len)
		printf("No\n");

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int digsum(int n){
  int sum=0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}
  
int main(){
  int n;
  cin >> n;
  if(n%digsum(n) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int t;
	cin>>t;
	int a=0,b=0,c=0,d=0;
	while(t--){
		string s;
		cin>>s;
		if(s=="AC"){
			a++;
		}
		if(s=="WA"){
			b++;
		}
		if(s=="TLE"){
			c++;
		}
		if(s=="RE"){
			d++;
		}
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
typedef struct {
	int index,
		cnt;
}TRIP;
void sort(TRIP[], int);
int main() {
	int i, n, m,j,a;
	TRIP d[100] = {};
	char *sep;
	while (fscanf(stdin, "%d%d", &n, &m), n, m) {
		while (n--) {
			for (i = 0; i < m; i++) {
				d[i].index = i + 1;
				fscanf(stdin, "%d", &a);
				d[i].cnt += a;
			}
		}
		sort(d, m);
		for (i = 0,sep=""; i < m; i++,sep=" ")
			fprintf(stdout, "%s%d",sep, d[i].index);
		puts("");
		for (i = 0; i < m; i++) d[i].cnt = 0;
	}
	return 0;
}

void sort(TRIP d[], int m){
	TRIP tmp;
	int i, j;
	for (i = 0; i < m; i++)
		for (j = 0; j<m-1; j++)
			if (d[j].cnt < d[j + 1].cnt)
				tmp = d[j], d[j] = d[j + 1], d[j + 1] = tmp;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int x;
    cin>>x;
    cout<<a[x-1];
    return 0;
}



Measured memory_bytes: 256
void main()
{
  import std.stdio, std.conv, std.string;
  immutable n = readln.chomp.to!size_t;
  real sum = 0;
  foreach (i; 0..n)
  {
    auto buf = readln.chomp.split;
    sum += (buf[0].to!real * (buf[1] == "JPY"?1:380000));
  }
  sum.writeln;
}


Measured memory_bytes: 256
package main

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

type Card struct{ Number, Stock int }
type Cards []Card

func (c Cards) Len() int           { return len(c) }
func (c Cards) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Cards) Less(i, j int) bool { return c[i].Number > c[j].Number }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	var sum int64
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sum += int64(as[i])
	}
	sort.Ints(as)
	var cs Cards = make([]Card, m)
	for i := range cs {
		sc.Scan()
		cs[i].Stock, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		cs[i].Number, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(cs)
	var p int
	for _, v := range cs {
		if p >= len(as) || v.Number < as[p] {
			break
		}
		for i := 0; i < v.Stock; i++ {
			if p >= len(as) || v.Number < as[p] {
				break
			}
			sum += int64(v.Number - as[p])
			p++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5120
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

char str[100010];
int len;

inline int Check(int length)
{
    int Max = 0, Min = 1e9;
    for (int i = 1; i < len - length ; i+=length)
    {
        int Next = i + length;
        for (int j = i, k = Next; j <= Next - 2; j++, k++)
                if (str[j] != str[k]) return 1e9;
        Min = min(Min, str[Next-1]-'0');
        Min = min(Min, str[Next+length-1]-'0');
        Max = max(Max, str[Next-1]-'0');
        Max = max(Max, str[Next+length-1]-'0');
    }
    if (Min == 1e9) return Min;
    return Max-Min;
}

int main()
{
    scanf("%s", str+1);
    len = strlen(str+1);
    int Min = 1e9, Max = 0;
    for (int i=1; i<=len; i++) Min = min(Min, str[i]-'0'), Max=max(Max, str[i]-'0');
    int ans = Max-Min;
    for (int i=2; i<len; i++)
        if (len % i == 0)
            ans = min(ans, Check(i));
    if (len!=2)
    {
        int Max = 0, Min = 1e9;
        for (int i=1; i<=len; i++)
        {
            int Cur = str[i]-'0';
            if (Cur == 1)
            {
                Cur = Cur * 10 + (str[i+1]-'0');
                i++;
            }
            Max = max(Max, Cur);
            Min = min(Min, Cur);
        }
        ans = min(ans, Max - Min);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 2832
import math
a, b, x = map(int, input().split())
c = x / a
if c <= a * b / 2:
    h = 2 * c / b
    t = 180 * math.atan(h / b) / math.pi
    print(90 - t)
else:
    c = a * b - c
    h = 2 * c / a
    t = 180 * math.atan(h / a) / math.pi
    print(t)


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

int main() {
	int n;
	int scor_a = 0;
	int scor_b = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string a, b;
		cin >> a >> b;

		if (a > b)
			scor_a += 3;
		else if (a < b)
			scor_b += 3;
		else if (a == b)
		{
			scor_a += 1;
			scor_b += 1;
		}
	}

	cout << scor_a << " " << scor_b << endl;
}

Measured memory_bytes: 3136
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
const ll P60 = (1LL<<60 )- 93LL;
const long long MOD = 2;

//* calculate C(n, 0), C(n, 1), ... C(n, n) list in O(n) 
// ! when n < 63
vll comb_list(ll n){
    vll res(n+1, 1);
    for(ll k=1; k <= n; k++){
        res[k] = res[k-1] * (n - k + 1) / k;
    }
    return res;
}

void solve(long long N, long long P, std::vector<long long> A){
    ll nrOdd=0, nrEven=0;
    REP(i, N){
        if(A[i] % 2 == 0)
            nrEven ++;
        else
            nrOdd ++;
    }
    ll res = 1LL;
    REP(i, nrEven) res *= 2;
    ll res1=0;
    
    vll clist = comb_list(nrOdd);

    if(P){//* sum is odd
        for(ll i=1; i<= nrOdd; i+= 2){
            res1 += clist[i];
        }
    }
    else{//* sum is even
        for(ll i=0; i<= nrOdd; i+= 2){
            res1 += clist[i];
        }
    }
    cout << res * res1 << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, P, std::move(A));
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W+1):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()



Measured memory_bytes: 6204
import sys
input = sys.stdin.readline

Q = int(input())
lr = []
l = []
r = []
for _ in range(Q):
    lr.append([int(x) for x in input().split()])
    l.append(lr[-1][0])
    r.append(lr[-1][1])

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

minl, maxr = min(l), max(r)
cumsum = [0] * (maxr + 1)

for i in range(1, maxr + 1, 2):
    if is_prime(i) and is_prime((i + 1) // 2) and i > 1:
        cumsum[i] = cumsum[i - 2] + 1
    elif i > 1:
        cumsum[i] = cumsum[i - 2]

for j in lr:
    l, r = j
    if l == 1:
        print(cumsum[r])
    else:
        print(cumsum[r] - cumsum[l - 2])









Measured memory_bytes: 75356
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int A, B;
	cin >> A >> B;
	if(B%A==0)cout << A+B << endl;
	else cout << B-A << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i+=2)
    {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

void solve(string s, string t)
{
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s.at(i) != t.at(i))
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    return;
}

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    solve(s, t);
}

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

if sum(a) < sum(b):
  print (-1)
  exit()
cnt = 0
d = [0] * n
s = 0
for i in range(n):
  d[i] = a[i]-b[i]
  if d[i] < 0:
    cnt += 1
    s += abs(d[i])
if cnt == 0:
  print (0)
  exit()

d.sort(reverse=True)

t = 0
for i in range(n):
  if s > d[i]:
    cnt += 1
    s -= d[i]
  else:
    cnt += 1
    break
print (cnt)

Measured memory_bytes: 24212
#include <iostream>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  if (A > B){
    cout << 2*A -1 << endl;
  }else if(A == B){
    cout << A + B << endl;
  }else {
    cout << 2*B -1 << endl;
  }
}

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

int gcd(int $a,int $b) {
    if ($b == 0)
        return $a;

    return gcd($b, $a % $b);
}

int main() {
	int N,X;
	cin>>N>>X;
	vector<int> vec(N);
	for(int i=0; i<N; i++){
		cin>>vec[i];
	}
	vector<int> veca(N);
	vector<int> vecb(N);
	for(int i=0; i<N; i++){
		veca[i]=abs(vec[i]-X);
		vecb[i]=abs(vec[i]-X);
	}
	//vecaの要素の最大公約数を出せばよい→互除法
	
	for(int i=0; i<N-1; i++){
		vecb[i+1]=gcd(veca[i+1],vecb[i]);
	}
	
	cout<<vecb[N-1]<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstdlib> //func147bでインクルード
#include <vector>  //func146b
 
using namespace std;
 
void func146b()
{
    int n;
    string s;
  
    cin >> n >> s;
 
    for (int i = 0; i < s.length(); ++i) {
 
        int x = s[i] - 'A';
        x = (x + n) % 26;
        cout << static_cast<char>('A' + x );
    }
    cout << endl;
}
 
int main()
{
  func146b();
  return 0;
}

Measured memory_bytes: 256
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    string s,ss;
    cin>>n>>s>>ss;
    for(i=0;i<n;i++){
        cout<<s[i]<<ss[i];
    }
    cout<<"\n";
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Remaining Time
            var line = ReadLine();
            int a = line[0];
            int b = line[1];

            if (a + b > 23)
            {
                Console.WriteLine(a + b - 24);
            }
            else
            {
                Console.WriteLine(a + b);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<long> a(n), b(n);
    vector<pair<long, int> > s(n);
    long taka = 0;
    for (int i=0; i < n; i++){
        long a_i,b_i;
        cin >> a_i >> b_i;
        a[i] =a_i;
        b[i] = b_i;
        s[i] = make_pair(a_i+b_i, i);
    }

    //cout << "get" << endl;

    sort(s.begin(), s.end());
    //cout << "sort" << endl;
    bool taka_flag = true;
    for (int i=0; i < n; i++){
        if ( taka_flag == true){
            int index = s[n-i-1].second;
            taka = taka + a[index];
            //cout << a[index] << endl;
            taka_flag = false;
        } else {
            int index = s[n-i-1].second;
            taka = taka - b[index];
            //cout << b[index] << endl;
            taka_flag = true;
        }
    }

    cout << taka << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n;cin >> n;
    string c;
    cin >> c;
    int l_w = 0, l_r = 0, r_w = 0, r_r = 0;
    for(int i=0;i<n;++i){
        if(c[i] == 'W') r_w++;
        else r_r++;
    }
    int ans = INF;
    chmin(ans, r_r);
    for(int i=0;i<n;++i){
        //
        if(c[i] == 'W'){
            l_w++;
            r_w--;
        }else{
            l_r++;
            r_r--;
        }
        
        chmin(ans, max(l_w, r_r));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Solver
        {
            private Dictionary<Tuple<long, long>, long> m_dict = new Dictionary<Tuple<long, long>, long>();
            public long Solve(long S, long X)
            {
                if (S == 0) { return 1; }
                if (X == 0) { return (S / 2) + 1; }
                if (S == 1) { return 2; }
                var key = new Tuple<long, long>(S, X);
                if (!m_dict.ContainsKey(key))
                {
                    long sum = 0;
                    sum = (sum + Solve((S - 0) / 2, (X - 0) / 2)) % MODULO;
                    sum = (sum + Solve((S - 1) / 2, (X - 1) / 2)) % MODULO;
                    sum = (sum + Solve((S - 2) / 2, (X - 0) / 2)) % MODULO;
                    m_dict[key] = sum;
                }
                return m_dict[key];
            }
        }

        static void Main(string[] args)
        {
            long N = ReadLong();
            Console.WriteLine(new Solver().Solve(N, N));
        }
    }
}


Measured memory_bytes: 13376
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
int a, b, c, k;

int main(){
    cin >> a >> b >> c >> k;
    int ret = 0;
    if(k<=a) cout << k << endl;
    else if(k<=a+b) cout << a << endl;
    else cout << a - (k-a-b) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int a,b,c,x,y;
	y=0;
scanf("%d %d %d",&a,&b,&c);
for(x=a;x<=b;x++){
if(c%x==0){
y=y+1;
}
}
printf("%d\n",y);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


char get_char(ll& input) {
	if (input == 1) return 'a';
	if (input == 2) return 'b';
	if (input == 3) return 'c';
	if (input == 4) return 'd';
	if (input == 5) return 'e';
	if (input == 6) return 'f';
	if (input == 7) return 'g';
	if (input == 8) return 'h';
	if (input == 9) return 'i';
	if (input == 10) return 'j';
	if (input == 11) return 'k';
	if (input == 12) return 'l';
	if (input == 13) return 'm';
	if (input == 14) return 'n';
	if (input == 15) return 'o';
	if (input == 16) return 'p';
	if (input == 17) return 'q';
	if (input == 18) return 'r';
	if (input == 19) return 's';
	if (input == 20) return 't';
	if (input == 21) return 'u';
	if (input == 22) return 'v';
	if (input == 23) return 'w';
	if (input == 24) return 'x';
	if (input == 25) return 'y';
	if (input == 0) return 'z';
	return 'Z';
}

char get_char2(ll& input) {
	input++;
	if (input == 1) return 'a';
	if (input == 2) return 'b';
	if (input == 3) return 'c';
	if (input == 4) return 'd';
	if (input == 5) return 'e';
	if (input == 6) return 'f';
	if (input == 7) return 'g';
	if (input == 8) return 'h';
	if (input == 9) return 'i';
	if (input == 10) return 'j';
	if (input == 11) return 'k';
	if (input == 12) return 'l';
	if (input == 13) return 'm';
	if (input == 14) return 'n';
	if (input == 15) return 'o';
	if (input == 16) return 'p';
	if (input == 17) return 'q';
	if (input == 18) return 'r';
	if (input == 19) return 's';
	if (input == 20) return 't';
	if (input == 21) return 'u';
	if (input == 22) return 'v';
	if (input == 23) return 'w';
	if (input == 24) return 'x';
	if (input == 25) return 'y';
	if (input == 26) return 'z';
	return 'Z';
}

int main() {

	ll N;
	cin >> N;

	ll order = 1;
	ll order_num = (ll)(1);

	while (N > (order_num * (ll)(26))) {
		order++;
		order_num *= (ll)(26);
		N -= order_num;
	}


	//	cout << name << endl;

	vector<ll> name_id;
	string name;

	N--;
	for (int i = 0; i < order; i++) {
		name_id.push_back(N % 26);
		N /= 26;
	}

	for (int i = 0; i < name_id.size(); i++) {
		name += get_char2(name_id[i]);
	}

	reverse(name.begin(), name.end());
	cout << name << endl;

	return 0;

}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		String S = sc.next();

		for (int i=0; i<S.length(); i++){
			if (i == a){
				if (S.charAt(i) != '-'){
					System.out.println("No");
					return;
				}
			}else {
				if (!Character.isDigit(S.charAt(i))){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
		return;
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int h,w,k;
int pre[15][1005];

int main(void){
	cin>>h>>w>>k;
	REP(i,h){
		string s;
		cin>>s;
		pre[i][0]=0;
		FORN(j,1,w+1){
			pre[i][j]=pre[i][j-1]+(int)(s[j-1]=='1');
		}
	}
	//
//	cout<<endl;
//	REP(i,h){
//		REP(j,w+1)cout<<pre[i][j]<<' ';
///		cout<<endl;
//	}
//	cout<<endl;
	//
	int minn=1e9;
	vpii v;
	REP(i,1<<(h-1)){
		//
//		cout<<endl;
//		cout<<i<<endl;
		//
		int last=0;
		v.clear();
		REP(j,h){
			if(j==h-1||(i&(1<<j))){
				v.pb(mp(last,j));
				last=j+1;
			}
		}
		int ans=0;
		REP(j,h)if(i&(1<<j))ans++;
		int n=v.size();
		last=0;
		//
//		cout<<n<<' '<<ans<<endl;
//		REP(j,n)cout<<v[j].fi<<' '<<v[j].se<<"  ";
//		cout<<endl;
		//
		
		FORN(j,1,w+1){
			int _cnt[n]={0};
			REP(ii,n){
				FORN(jj,v[ii].fi,v[ii].se+1){
					_cnt[ii]+=pre[jj][j]-pre[jj][j-1];
				}
			}
			//
//			REP(ii,n)cout<<_cnt[ii]<<' ';
//			cout<<' ';
			//
			bool _flag=0;
			REP(ii,n){
				if(_cnt[ii]>k){
//					cout<<"No this answer!\n";//
					ans=1e9;
					_flag=1;
					break;
				}
			}
			if(_flag)break;
			int cnt[n]={0};
			REP(ii,n){
				FORN(jj,v[ii].fi,v[ii].se+1){
					cnt[ii]+=pre[jj][j]-pre[jj][last];
				}
			}
			//
//			REP(ii,n)cout<<cnt[ii]<<' ';
//			cout<<' ';
			//
			bool flag=0;
			REP(ii,n){
				if(cnt[ii]>k){
					flag=1;
					break;
				}
			}
			if(flag){
				ans++;
				last=j-1;
//				cout<<j<<' ';//
			}
//			cout<<endl;//
		}
		minn=min(minn,ans);
//		cout<<ans<<endl;//
	}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<P> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph M(N);
    rep(i, N){
        int u, k;
        cin >> u >> k;
        rep(j, k){
            int v, c;
            cin >> v >> c;
            M[u].push_back(P(v, c));
        }
    }

    vector<int> d(N, INF), p(N, -1);
    vector<bool> seen(N, false);
    d[0] = 0;

    while(1){
        int mincost = INF;
        int u;

        rep(i, N){
            if(!seen[i] && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF) break;
        seen[u] = true;

        rep(i, M[u].size()){
            int v = M[u][i].first, c = M[u][i].second;
            if(!seen[v] && d[u] + c < d[v]){
                d[v] = d[u] + c;
                p[v] = u;
            }
        }
    }

    rep(i, N){
        cout << i << ' ' << d[i] << endl;
    }

}


Measured memory_bytes: 3076
# Author: cr4zjh0bp
# Created: Sun Mar  8 13:31:56 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x1, y1, x2, y2 = na()

x = x2 - x1
y = y2 - y1
print(x2 - y, y2 + x, x1 - y, y1 + x)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
  int n, q; string s; cin >> n >> q >> s;
  vector<int> S(n+1);
  rept(i, 2, n+1){
    if(s[i-1] == 'C' && s[i-2] == 'A')S[i]++;
    S[i] += S[i-1];
  }

  vector<int> ans(q);
  rep(i, q){
    int l, r; cin >> l >> r;
    ans[i] = S[r] - S[l-1];
    if(l>1 && s[l-1]=='C' && s[l-2]=='A')ans[i]--;
  }
  for(auto res: ans) cout << res << ln;
}


Measured memory_bytes: 1792
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar_unlocked());)c-10?a[i]=a[i]*10+c-48:++i;
	for(b[i=s]=1;!b[s=a[s]]++&&s-2;++i);
	printf("%d",s==2?i:-1);
}

Measured memory_bytes: 896
import bisect

a,b,q = map(int,input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]

ans = 10**100

for i in range(q):
    ans = 10**100
    s_idx = bisect.bisect_left(s,x[i])
    t_idx = bisect.bisect_left(t,x[i])
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(ans,abs(x[i] - s[min(s_idx+j,a-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]),abs(x[i] - t[min(t_idx+k,b-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))
            
    print(ans)

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


int main(){
    int64_t a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    ans = max (a*c, a*d);
    ans = max(ans, b*d);
    ans = max(ans, b*c);
    cout << ans << endl;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, x = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      x++;
    }
  }
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;

int N, K;
int A[200010];
int dist[200010];

signed main()
{
	cin >> N >> K;

	rep(i, N) {
		cin >> A[i];
		--A[i];
	}

	rep(i, N) dist[i] = inf;

	int cur = 0, d = 0;

	while (1) {
		if (d == K) {
			cout << cur + 1 << endl;
			return 0;
		}

		if (dist[cur] != inf) {
			break;
		}

		dist[cur] = d;
		cur = A[cur];
		d++;
	}

	// K ippai
	K -= dist[cur];
	int cycle_len = d - dist[cur];

	K %= cycle_len;

	rep(_, K) {
		cur = A[cur];
	}

	cout << cur + 1 << endl;
}




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

int main(void){
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i = 0;i < n;i++)cin >> h[i];
    sort(h,h+n,greater<int>());
    long long int sum = 0;
    for(int i = k;i < n;i++){
        sum += h[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<ll> t(N+1, 0), x(N+1, 0), y(N+1, 0);
    rep(i, 0, N) cin >> t[i+1] >> x[i+1] >> y[i+1]; 
    rep(i, 0, N){
        ll dx = abs(x[i+1] - x[i]);
        ll dy = abs(y[i+1] - y[i]);
        ll dt = t[i+1] - t[i];
        if((dy + dx) % 2 != dt % 2 || dx + dy > dt){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int M,D;
  cin >> M >> D;
  if(D<22){
    cout << "0";
    return 0;
  }
  int ans=0;
  for(int i=1; i <= M; i++){
    for(int j = 22; j <= D; j++){
      if(j%10<2) continue;
      if(i==((j/10)*(j%10))) ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
void vector(int[101][101],int[1][101],int,int);
void vector(int x[101][101],int y[1][101],int i,int j){
    int k,l,c;
    for(k=0;k<i;k++){
        c=0;
        for(l=0;l<j;l++){
            c+=x[k][l]*y[0][l];
        }
        printf("%d\n",c);
    }
    return;
}
int main(void){
    int n,m,i,j;
    int a[101][101],b[1][101];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[0][j]);
    }
    vector(a,b,n,m);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int l,r,d;
	cin>>l>>r>>d;
	int ans = 0;
	while(l<=r)
	{
		if(l%d==0)
			ans++;
		l++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import numpy as np
import itertools
N, C, *XV = [int(_) for _ in open(0).read().split()]
XV = [0, 0] + XV
XV = np.array(XV).reshape((N+1, 2))
YV = np.zeros((N+1, 2), dtype=np.int64)
YV[1:] = XV[:0:-1]
YV[1:, 0] *= -1
YV[1:, 0] += C

def calc(XV,YV):
    cumxvv = np.cumsum(XV[:, 1])
    cumxvv -= 2 * XV[:, 0]
    cumyvv = np.cumsum(YV[:, 1])
    cumyvv -= YV[:, 0]
    cummaxyvv = list(itertools.accumulate(cumyvv, func=lambda a, b: a if a > b else b))
    ans=-float('inf')
    for i in range(N + 1):
        ans = max(ans, cumxvv[i] + cummaxyvv[N - i])
    return ans
print(max(calc(XV, YV), calc(YV, XV)))


Measured memory_bytes: 48992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N,M; cin>>N>>M;
    priority_queue<ll> A;

    for (int i = 0; i < N; ++i) {
        ll tmp; cin>>tmp;
        A.push(tmp);
    }

    ll minimum=0, X=0;
    for (int i = 0; i < M; ++i) {
        X = A.top();
        A.pop();
        A.push(X/2);
    }

    ll sum=0;
    while(!A.empty()){
        sum += A.top();
        A.pop();
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
//#define MAX 500010
//#define NIL -1
using namespace std;

struct Node {
	int key;

	Node* r, * l, * p;
};

Node* root, * NIL;


void insert(int ke) {
	Node* y = NIL;
	Node* x = root;
	Node* z;

	z = (Node*)malloc(sizeof(Node));

	z->key = ke;
	z->l = NIL;
	z->r = NIL;

	while (x != NIL) {
		y = x;

		if (z->key < x->key) {
			x = x->l;
		}
		else {
			x = x->r;
		}
	}


	z->p = y;

	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->l = z;
		}
		else {
			y->r = z;
		}
	}
}

Node* find(Node* q,int ke) {
	while (q != NIL && ke != q->key) {
		if (ke < q->key) {
			q = q->l;
		}
		else {
			q = q->r;
		}
	}

	return q;
}

void inorder(Node* u) {
	if (u == NIL) {
		return;
	}

	inorder(u->l);
	printf(" %d", u->key);
	inorder(u->r);
}


void preorder(Node* u) {//先行順巡回
	if (u == NIL) {
		return;
	}
	printf(" %d", u->key);
	preorder(u->l);
	preorder(u->r);
}


int main() {
	int n, i, x;
	string com;

	//scanf_s("%d", &n);
	scanf("%d", &n);
	//cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> com;

		if (com[0] == 'f') {
			//scanf_s("%d", &x);
			scanf("%d", &x);
			//cin >> x;

			Node *t = find(root, x);

			if (t != NIL) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
		else if (com == "insert") {
			//scanf_s("%d", &x);
			scanf("%d", &x);
			//cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			//cout << endl;
			printf("\n");
			preorder(root);
			//cout << endl;
			printf("\n");
		}

	}

	return 0;
}








Measured memory_bytes: 22048
n,x = map(int,input().split())
ass = list(map(int,input().split()))

ass = sorted(ass)

count =0
for i,a in enumerate(ass):
	if i == len(ass)-1:
		if a < x:
			break
		elif a == x:
			count+=1
			break
		else:
			break
			
	if x < a:
		break
			
	
	x -= a
	count += 1
	
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n)<(m)+EPS)
#define GE(n,m) ((n)+EPS>(m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1; 
  if (dot(b,c)<-EPS) return 2; 
  if (norm(b)<norm(c)) return -2; 
  return 0; 
}
namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}
VP convexHull(VP ps) { 
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for (int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while (k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  ch.resize(k-1);
  return ch;
}
int inConvex(P p, const VP& ps) {
  int n = ps.size();
  int dir = ccw(ps[0], ps[1], p);
  rep (i, n) {
    int ccwc = ccw(ps[i], ps[(i + 1) % n], p);
    if (!ccwc) return 2;
    if (ccwc != dir) return 0;
  }
  return 1;
}
int main(){
  int n;
  cin>>n;
  P p[n];
  rep(i,n){
    double a1,a2;
    cin>>a1>>a2;
    p[i]=P(a1,a2);
  }
  VP p1,p2;
  rep(i,n)p1.push_back(p[i]);
  rep(i,n){
    if(i)p2.push_back(p[i-1]);
    p1.erase(p1.begin());
    VP a1,a2;
    if(p1.size()>=3){
      a1=convexHull(p1);
      if(inConvex(p[i],a1)==1){cout<<"Impossible"<<endl;goto L;}
    }
    if(p2.size()>=3){
      a2=convexHull(p2);
      if(inConvex(p[i],a2)==1){cout<<"Impossible"<<endl;goto L;}
    }
  }
  cout<<"Possible"<<endl;L:;
}

Measured memory_bytes: 3356
N = int(input())
S = list(input())


max = 0

for half in range(N-1):

    X = S[0:half+1]
    Y = S[half+1:N] 

    set_X = set(X)
    set_Y = set(Y)
    tmp = len(set_X&set_Y)

    if tmp > max:
        max = tmp

print(max)

Measured memory_bytes: 3064
n = int(input())
s = input()
result = 0

for i in range(10):
  a = s.find(str(i))
  if a == -1:
    continue
  for i in range(10):
    b = s.find(str(i), a + 1)
    if b == -1:
      continue
    for i in range(10):
      if s.find(str(i), b + 1) != -1:
        result += 1

print(result)


Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, x, d;
    cin >> n >> x >> d;
    LL d2 = d;
    if(d == 0){
        if(x == 0){
            cout << 1 << endl;
        }else{
            cout << n+1 << endl;
        }
        return 0;
    }
    map<LL, vector<pair<LL,LL>>> ranges;
    ranges[0].emplace_back(0, 1);
    for(LL i = 0; i < n; ++i){
        if(d >= 0){
            LL r = (i+1) * x % d2;
            LL left = (i+1) * x / d2 + i * (i+1) / 2;
            LL right = (i+1) * x / d2 + i * (i+1) / 2 + (n-1-i) * (i+1);
            ranges[r].emplace_back(left, right+1);
        }else{
            LL d2 = -d;
            LL r = (i+1) * x % d2;
            LL left = (i+1) * x / d2 - i * (i+1) / 2 - (n-1-i) * (i+1);
            LL right = (i+1) * x / d2 - i * (i+1) / 2;
            ranges[r].emplace_back(left, right+1);
        }
    }
    LL ans = 0;
    for(auto p: ranges){
        LL right = -1e+18;
        sort(p.second.begin(), p.second.end());
        for(auto p2: p.second){
            //cerr << p.first <<", " << p2 << endl;
            if(right < p2.first){
                ans += p2.second - p2.first;
                right = p2.second;
            }else{
                ans += max<LL>(0, p2.second - right);
                right = max<LL>(right, p2.second);
            }
            //cerr << "ans=" << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 22144
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() 
{
	double x1, x2, y1, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	cout << setprecision(12) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1)*(y2 - y1)) << endl;
	return 0;
}


Measured memory_bytes: 3292
import bisect
import sys
s=list(input())
t=list(input())
n=len(s)
l=[chr(i) for i in range(97, 97+26)]
ct=[[] for i in range(26)]
for i in range(len(s)):
  ct[l.index(s[i])].append(i)

ans=0
y=-1
for i in range(len(t)):
  x=l.index(t[i])
  if len(ct[x])==0:
    print(-1)
    sys.exit()
  z=bisect.bisect(ct[x],y)
  if z==len(ct[x]):
    ans=(ans//n)*n+n+ct[x][0]
    y=ct[x][0]
  else:
    ans=(ans//n)*n+ct[x][z]
    y=ct[x][z]
print(ans+1)

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

int main(){
	
	for(int d,n,m,ans;cin>>d,d;){
		ans=0;
		cin>>n;//店の数
		cin>>m;//注文の数
		vector<int>V(2*n);
		V[0]=0;
		for(int i=1;i<n;i++)cin>>V[i];
		for(int i=0;i<n;i++)V[i+n]=V[i]+d;
		sort(V.begin(),V.end());
		for(int i=0,k;i<m;i++){
			cin>>k;
			vector<int>::iterator a = lower_bound(V.begin(),V.end(),k);
			vector<int>::iterator b = upper_bound(V.begin(),V.end(),k);
			ans+=min(abs(k-(*a)),abs(k-(*(b-1))));
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
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);
}
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll g=a[0];
    rep(i,n) g=gcd(g,a[i]);
    if(g!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    map<ll,ll> mp;
    rep(i,n){
        ll x=a[i];
        for(ll j=2;j<=sqrt(x);j++){
            if(x%j!=0)continue;
            if(mp[j]!=0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            mp[j]++;
            while(x%j==0)x/=j;
        }
        if(x>=2){
            if(mp[x]!=0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            mp[x]++;
        }
    }
    cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 11240
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600], ans;
bool cond;
char c;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    n = s.size();
    if(s[n-1]=='s')
        s+= "es";
    else
        s+= "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
        using namespace std;
		typedef long long int ll;
			int main(){	
			    
                  int N, A, B, C;
                  cin >> N >> A >> B >> C;
                  vector<int> l(N);
                  
                  for(int i=0; i<N; i++){
                      cin>> l.at(i);
                  }
                  
                  int M=100000; 
                  
                  for (int tmp = 0; tmp < (1 << 16); tmp++) {
                      
                            bitset<16> s(tmp);
                            int b;
                            int AL=0;
                            int AN=0;
                            
                            int BL=0;
                            int BN=0;
                            
                            int CL=0;
                            int CN=0;
                            
                            int MP=0; 
                            
                            for(int i=0; i<N; i++){
                                b = s.test(2*i)+2*s.test(2*i+1);
                                if(b==0){
                                    
                                }else if(b==1){
                                    AL+= l.at(i);
                                    AN++;
                                }else if(b==2){
                                    BL+= l.at(i);
                                    BN++;
                                }else if(b==3){
                                    CL+= l.at(i);
                                    CN++;
                                }
                                if(AN!=0&&BN!=0&&CN!=0){
                                    MP = (AN+BN+CN-3)*10 + max(A-AL,AL-A)+ max(B-BL,BL-B)+ max(C-CL,CL-C); 
                                    M=min(MP,M); 
                                }
                            }
                  }              
             cout<< M << endl;   
              
              
        	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a.begin(),a.end());
  ll tmp=a[n/2];
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans+=abs(a[i]-tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int H, W;
	char S[64][64] = {{0}};
	int i, j, k, l;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 1; i <= H; i++) {
		if (scanf("%62s", S[i] + 1) != 1) return 1;
	}
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (S[i][j] == '.') {
				int count = 0;
				for (k = -1; k <= 1; k++) {
					for (l = -1; l <= 1; l++) {
						if (S[i + k][j + l] == '#') count++;
					}
				}
				S[i][j] = count + '0';
			}
		}
	}
	for (i = 1; i <= H; i++) {
		puts(S[i] + 1);
	}
	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
#

def main():
    N = ii()
    print((N-1)//2)


main()


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.sort()

flg = [0 for i in range(n)]
for i in range(n):
    flg[a[i]] += 1
for i in range(n-1):
    print(flg[i+1])

print(0)

Measured memory_bytes: 32244
N = int(input())
A = list(map(int,input().split()))

almost_half = sum(A)/2

former = 0
for n in range(N):
  former += A[n]
  if former == almost_half:
    print(0)
    break
    
  if former > almost_half:
    if n == 0:
      #print("case01",n,former)
      print(abs(A[0]-sum(A[1:])))
      break
    elif n == N-1:
      #print("case02",n,former)
      print(abs(A[n]-sum(A[:n])))
      break
    else:
      #print("case03",n,former)
      #print(abs(sum(A[n:])-sum(A[:n])),abs(sum(A[n+1:])-sum(A[:n+1])))
      print(min(abs(sum(A[n:])-sum(A[:n])),abs(sum(A[n+1:])-sum(A[:n+1]))))
      break

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int r, c, n, ck1, ck2;

vector<ii> vec[4];

bool cmp(const ii &a, const ii &b){
    return a.fi > b.fi;
}

stack<int> st;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        int x1, y1, x2, y2;
        ck1 = 0, ck2 = 0;
        cin >> x1 >> y1 >> x2 >> y2;
        if(x1 == 0 || x1 == r)
            ck1 = 1;
        if(y1 == 0 || y1 == c)
            ck1 = 1;
        if(x2 == 0 || x2 == r)
            ck2 = 1;
        if(y2 == 0 || y2 == c)
            ck2 = 1;
        if(ck1 && ck2){
            ck1 = 0, ck2 = 0;
            if(x1 == 0 || x1 == r){
                if(x1 == 0)
                    vec[0].pb({y1, i});
                else
                    vec[2].pb({y1, i});
                ck1 = 1;
            }
            if(ck1 == 0 && (y1 == 0 || y1 == c)){
                if(y1 == 0)
                    vec[3].pb({x1, i});
                else
                    vec[1].pb({x1, i});
            }
            if(x2 == 0 || x2 == r){
                if(x2 == 0)
                    vec[0].pb({y2, i});
                else
                    vec[2].pb({y2, i});
                ck2 = 1;
            }
            if(ck2 == 0 && (y2 == 0 || y2 == c)){
                if(y2 == 0)
                    vec[3].pb({x2, i});
                else
                    vec[1].pb({x2, i});
            }
        }
    }
    sort(vec[0].begin(), vec[0].end()); sort(vec[1].begin(), vec[1].end()); sort(vec[2].begin(), vec[2].end(), cmp); sort(vec[3].begin(), vec[3].end(), cmp);
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < vec[i].size(); j++){
                if(!st.empty() && vec[i][j].se == st.top())
                    st.pop();
                else
                    st.push(vec[i][j].se);
        }
    }
    if(st.size() != 0)
        cout << "NO\n";
    else
        cout << "YES\n";
}


Measured memory_bytes: 2520