akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()
	mx := 1000
	curMoney := 1000
	curP := 0
	rate := 0
	for i := 0; i < N; i++ {
		curMoney = curP*max(rate, A[i]) + curMoney

		if mx < curMoney {
			mx = curMoney
		}

		curP = curMoney / A[i]
		curMoney -= (curMoney / A[i]) * A[i]
		rate = A[i]
	}

	fmt.Println(mx)
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1784
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            int C = line[2];
            int ans = 0;
            if ((A - B) < C)
            {
                ans = C - (A - B);
            }
            else
            {
                ans = 0;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=998244353;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
const int nmax = 1e5 + 4 ;
vector < pair < int , int >  > edge[nmax];
vector < ll > depth(nmax);
void dfs( int x , int p ){
    for( auto child : edge[x]){
       if(child.ff != p){
            depth[child.ff] = depth[x] + child.ss ;
            dfs(child.ff,x);
       }
    }
}
void solve(){
    int n ;
    cin >> n  ;
    for( int i = 0 ; i < n - 1 ; i++){
         int  u , v , w ;
         cin >> u >> v >> w ;
         edge[u].PB({v,w});
         edge[v].PB({u,w});
    }
    dfs(1,-1);
    for( int i = 1 ; i <= n ; i++){
        if(depth[i]%2==0){
                cout << 0 << "\n";
        }
        else{
                cout << "1\n";
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 8832
// C++ program to multiply two numbers represented 
// as strings. 
#include<bits/stdc++.h> 
using namespace std; 

// Multiplies str1 and str2, and prints result. 
string multiply(string num1, string num2) 
{ 
	int len1 = num1.size(); 
	int len2 = num2.size(); 
	if (len1 == 0 || len2 == 0) 
	return "0"; 

	// will keep the result number in vector 
	// in reverse order 
	vector<int> result(len1 + len2, 0); 

	// Below two indexes are used to find positions 
	// in result. 
	int i_n1 = 0; 
	int i_n2 = 0; 
	
	// Go from right to left in num1 
	for (int i=len1-1; i>=0; i--) 
	{ 
		int carry = 0; 
		int n1 = num1[i] - '0'; 

		// To shift position to left after every 
		// multiplication of a digit in num2 
		i_n2 = 0; 
		
		// Go from right to left in num2			 
		for (int j=len2-1; j>=0; j--) 
		{ 
			// Take current digit of second number 
			int n2 = num2[j] - '0'; 

			// Multiply with current digit of first number 
			// and add result to previously stored result 
			// at current position. 
			int sum = n1*n2 + result[i_n1 + i_n2] + carry; 

			// Carry for next iteration 
			carry = sum/10; 

			// Store result 
			result[i_n1 + i_n2] = sum % 10; 

			i_n2++; 
		} 

		// store carry in next cell 
		if (carry > 0) 
			result[i_n1 + i_n2] += carry; 

		// To shift position to left after every 
		// multiplication of a digit in num1. 
		i_n1++; 
	} 

	// ignore '0's from the right 
	int i = result.size() - 1; 
	while (i>=0 && result[i] == 0) 
	i--; 

	// If all were '0's - means either both or 
	// one of num1 or num2 were '0' 
	if (i == -1) 
	return "0"; 

	// generate the result string 
	string s = ""; 
	
	while (i >= 0) 
		s += std::to_string(result[i--]); 

	return s; 
} 

// Driver code 
int main() 
{ 
	string str1,st2; 
	cin>>str1>>st2;
	string str2;
	for(auto it: st2)
	{
	    if(it!='.')
	    str2+=it;
	}
	if((str1.at(0) == '-' || str2.at(0) == '-') && 
		(str1.at(0) != '-' || str2.at(0) != '-' )) 
		cout<<"-"; 


	if(str1.at(0) == '-' && str2.at(0)!='-') 
		{ 
			str1 = str1.substr(1); 
		} 
		else if(str1.at(0) != '-' && str2.at(0) == '-') 
		{ 
			str2 = str2.substr(1); 
		} 
		else if(str1.at(0) == '-' && str2.at(0) == '-') 
		{ 
			str1 = str1.substr(1); 
			str2 = str2.substr(1); 
		} 
	string s=multiply(str1, str2);
	if(s.size()<3)
	cout<<0;
	else
	cout<<s.substr(0,s.size()-2);
	return 0; 
} 


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;cin>>n;
    
    int t[n];
    int s=0;
    rep(i,n){
        cin>>t[i];
        s+=t[i];
    }
    
    int m;cin>>m;
    int p,x;
    
    rep(i,m){
        cin>>p>>x;
        int ans = s - t[p-1] + x;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import re
import doctest
import functools

class IO_for_Contest(object):
    @staticmethod
    def my_input():
        #return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        n = IO_for_Contest.read_int()
        return IO_for_Contest.read_n_int(n)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map( \
                int, \
                re.split('\s+', IO_for_Contest.my_input().strip())))[ : n]
def solve():
    a = IO_for_Contest.read_from_input()
    print(think_min_cost_for(a))

def think_min_cost_for(arr):
    """
    >>> think_min_cost_for([4, 8])
    8
    """
    ceil = 100
    floor = -100
    cost = []
    for to in range(floor, ceil + 1):
        cost.append(think_min_cost_about(arr, to))
    return min(cost)

def think_min_cost_about(arr, to):
    diff = list(map(lambda x: x - to, arr))
    diff_2 = list(map(lambda x: x ** 2, diff))
    return sum(diff_2)

if __name__ == '__main__':
    #doctest.testmod()
    solve()

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

int main(){
  string s;
  cin>>s;
  int l;
  l=s.length();
  
  rep(i,l){
  cout<<'x';
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];

  sort(a.begin(), a.end());
  cout << a[2] - a[0] << endl;


  
  return 0;
}

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

int main() {
  int N,l,r;
  int num = 0;
  cin >> N;
  
  for (int i=0; i<N; i++){
    cin >> l >> r;
    num += r - l + 1;
  }
  
  cout << num << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;
bool ip[SIZE];
int ps[SIZE];

int main()
{
	int Q;
	cin >> Q;
	int p=0;
	rep(i,0,SIZE)ip[i] = true;
	ip[0] = ip[1] = false;
	rep(i,2,SIZE){
		if(ip[i]) for(int j=2*i;j<=SIZE;j+=i) ip[j] = false;
	}
	int t = 0;
	rep(i,0,SIZE){
		if(ip[i] && ip[(i+1)/2])t++;
		ps[i] = t;
	}
	int l,r;
	rep(i,0,Q){
		cin >> l >> r;
		cout << ps[r]-ps[l-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,x,k = 0,sum = 0,ksum = 0;
  long long a[3000];
  cin >> n >> x;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a,a+n);
  if(sum == x){
    cout << n << endl;
    return 0;
  }
  while(ksum + a[k] <= x && k < n - 1){
    ksum += a[k];
    k++;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())

a = [0 for i in range(n)]
a = [int(s) for s in input().split()]
res = 0

dig_0 = [0 for i in range(60)]
dig_1 = [0 for i in range(60)]

for i in range(n):
    #print("----")
    for j in range(60):
        #print(bin(a[i]>>j))
        s = (a[i]>>j)%2
        if(s == 1):
            dig_1[j] += 1
        else:
            dig_0[j] += 1

#print((3>>1)%2)
for i in range(60):
    #print(dig_0[i],dig_1[i])
    res += dig_0[i]*dig_1[i]*2**i
    #print(res)
md = 10**9 + 7
print(res%md)


Measured memory_bytes: 121488
S = input()

S_zen =int(S[0:2])
S_go = int(S[2:4])

judge_list_MM = [1+i for i in range(12)]

#print(judge_list_MM)

if S_zen in judge_list_MM and S_go in judge_list_MM :
    print("AMBIGUOUS")
elif S_go in judge_list_MM :
    print("YYMM")
elif S_zen in judge_list_MM :
    print("MMYY")
else :
    print("NA")

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var s, t string

	fmt.Scan(&s)
	fmt.Scan(&t)

	m := 0
	for i := 0; i < len(s)-len(t)+1; i++ {
		n := substringMatchCount(s, t, i)
		if n > m {
			m = n
		}
	}

	fmt.Println(len(t) - m)
}

func substringMatchCount(s string, t string, idx int) int {
	c := 0
	for i := 0; i < len(t); i++ {
		if s[idx+i] == t[i] {
			c++
		}
	}

	return c
}


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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var n = int.Parse(input[0]);
        var m = int.Parse(input[1]);

        var heightMap = new Dictionary<int, int>();
        var dict = new Dictionary<int, List<int>>();

        var hinput = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            heightMap[i + 1] = int.Parse(hinput[i]);
            dict[i + 1] = new List<int>();
        }

        for (int i = 0; i < m; i++)
        {
            var wayinput = Console.ReadLine().Split(' ');
            dict[int.Parse(wayinput[0])].Add(int.Parse(wayinput[1]));
            dict[int.Parse(wayinput[1])].Add(int.Parse(wayinput[0]));
        }

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (dict[i + 1].Count == 0)
            {
                ans++;
                continue;
            }
            var heightList = new List<int>();
            foreach (var v in dict[i + 1])
            {
                heightList.Add(heightMap[v]);
            }
            if (heightMap[i + 1] > heightList.Max())
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 48092
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	auto N=in();
	int M=(1<<N);
	
	REP(i,M){
		cout << i <<":";
		int v=i;
		int n=0;
		while(v){
			if(v&1) cout << ' ' << n;
			v >>= 1;
			n++;
		}
		cout << endl;
	}

	return 0;
}


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

int h, w;
int c[26], two, one;

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int i = 0; i < w; i++)
			c[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		c[i] %= 4;
		two += c[i] / 2;
		c[i] %= 2;
		one += c[i];
	}
	cout
			<< (two <= h / 2 * (w & 1) + w / 2 * (h & 1) && one == (h & w & 1) ?
					"Yes" : "No") << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n; string s; cin >> n >> s;
	int ans=0;
	rep(i,n-2){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  scanf("%d %d", &n, &m);

  vector<int> a, b, c;
  REP(i,m){
    int t1, t2, t3;
    scanf("%d %d %d", &t1, &t2, &t3);
    t1--; t2--; t3 *= -1;
    a.pb(t1); b.pb(t2); c.pb(t3);
  }

  llong d[1000];
  REP(i,1000){
    d[i] = LLONG_MAX;
  }
  
  d[0] = 0;

  REP(i,n - 1){
    REP(j,m){
      if(d[a[j]] == LLONG_MAX){
        continue;
      }

      if(d[b[j]] > d[a[j]] + c[j]){
        d[b[j]] = d[a[j]] + c[j];
      }
    }
  }

  llong ans = d[n - 1];
  bool cycle[1000] = {};

  REP(i,n){
    REP(j,m){
      if(d[a[j]] == LLONG_MAX){
        continue;
      }

      if(d[b[j]] > d[a[j]] + c[j]){
        d[b[j]] = d[a[j]] + c[j];
        cycle[b[j]] = true;
      }

      if(cycle[a[j]]){
        cycle[b[j]] = true;
      }
    }
  }

  if(cycle[n - 1]){
    printf("inf\n");
  }else{
    printf("%lld\n", -ans);
  }
  return 0;
}



Measured memory_bytes: 256
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

const int n_cities = 50;

int road[n_cities];

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8
)");
#endif
    int n, m;
    in >> n >> m;

    for (int i = 0; i < n; ++i) road[i] = 0;

    int a_i, b_i;
    for (int i = 0; i < m; ++i) {
        in >> a_i >> b_i;
        road[a_i - 1]++;
        road[b_i - 1]++;
    }

    for (int i = 0; i < n; ++i) cout << road[i] << endl;

    return 0;
}

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

using namespace std;

int main(){
    map<string,string>m;
    string s;
    m["A"] = "T";
    m["C"] = "G";
    m["G"] = "C";
    m["T"] = "A";

    cin >> s;

    cout << m[s] << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    Si = S[::-1]
    a = ['maerd', 'remaerd', 'esare', 'resare']
    temp = str()
    cnt = 0
    for i in Si:
        temp += i
        if temp in a:
            cnt += len(temp)
            temp = str()
    print('YES' if cnt == len(S) else 'NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  int h, a;
  cin >> h >> a;
  cout << (h+(a-1))/a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int F[45];

void fib(int n){

  int i;

  F[0] = 1;
  F[1] = 1;

  for(i=2;i<=n;i++){
    
    F[i] = F[i - 2] + F[i - 1];

  }


}


int main(){

  int n;

  scanf("%d",&n);

  fib(n);

  printf("%d\n",F[n]);

  return 0;
}



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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string ans = "";
	while (n) {
		ans = char((n-1)%26+'a')+ans;
		n = (n-1)/26;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3652
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: usize = itr.next().unwrap().parse().unwrap();

    // (i + 1) * i / 2 <= n
    let mut ok = 0;
    let mut ng = 1usize << 30;
    while ng - ok > 1 {
        let mid = (ok + ng) / 2;
        if mid * (mid + 1) / 2 < n {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok + 1);
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n){
        cin >> vec[i];
    }
    vector<int> cnt(n, 0);
    rep(i, n){
        if(i+vec[i]+1 < n){
            cnt[i+vec[i]+1]++;
        }
    }
    ll res = 0;
    rep(i, n){
        if(i-vec[i]+1 >= 0){
            res += cnt[i-vec[i]+1];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
int a[502][502];

typedef tuple<int,int,int,int> T;
int main(){
    int H,W;
    int N=0;
    vector<T> o;
    cin >> H >> W;

    rep(i,H){
        rep(j,W){
            cin >> a[i][j];
        }
    }

    rep(i,H){
        rep(j,W){
            int x1,x2,y1,y2;
            if(a[i][j]%2 && j!=W-1){
                a[i][j+1]+=1;
                a[i][j]-=1;
                y1=i+1;
                y2=i+1;
                x1=j+1;
                x2=j+2;
                o.emplace_back(T(y1,x1,y2,x2));
                N++;
            }
        }
    }

    rep(i,H){
        if(a[i][W-1]%2 && i!=H-1){
            int x1,x2,y1,y2;
            a[i+1][W-1]+=1;
            a[i][W-1]-=1;

            y1=i+1;
            y2=i+2;
            x1=W;
            x2=W;
            o.emplace_back(T(y1,x1,y2,x2));
            N++;
        }
    }

    cout << N << endl;
    rep(i,N){
        cout << get<0>(o[i])<< " "
        << get<1>(o[i])<< " "
        << get<2>(o[i])<< " "
        << get<3>(o[i])<< endl;
    }
    return 0;
}



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

int main(){
	int k,s,cnt=0;;cin>>k>>s;
  	for (int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
            	if(0<=s-i-j && s-i-j<=k) cnt++;
        }
    }
	cout<<cnt<<endl;      
}    

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a+b+c+d << endl;
}


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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int main()
{
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }

    vector<int> vec;
    rep(i,0,300000){
      vec.push_back(i);
    }

    vec[1]=0;
    rep(i,0,300000){
      if(vec[i]!=0){
        for(int j=i+i;j<300000;j+=i){
          vec[j]=0;
        }
      }
    }
    vector<int> vec2;
    rep(i,0,300000){
      if(vec[i]!=0){
        vec2.push_back(i);
      }
    }

    int count=0;
    rep(i,0,vec2.size()){
      if(vec2[i]>2*n){
        break;
      }
      if(vec2[i]>n){
        count++;
      }
    }
    cout<<count<<endl;
  }

  return 0;
}

Measured memory_bytes: 6072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],root;
vector<int> G[N];
ll sum;
ll dfs(int u,int fa){
	if(G[u].size()==1)return a[u];
	ll tot=0,mx=0;
	for(int i=0;i<(int)G[u].size();++i){
		int v=G[u][i];
		if(v==fa)continue;
		ll p=dfs(v,u);
		if(p<0)return -1;
		mx=max(mx,p);
		tot+=p;
	}
	if(a[u]>tot||a[u]<(tot+1)/2)return -1;
	ll o=tot-a[u];
	if(o>tot-mx)return -1;
	return 2*a[u]-tot;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(n==2){
		puts(a[1]==a[2]?"YES":"NO");
		return 0;
	}
	for(int i=1;i<=n;++i){
		if(G[i].size()>1){
			root=i;break;
		}
	}
	puts(!dfs(root,0)?"YES":"NO");
	return 0;
}


Measured memory_bytes: 16028
#include<stdio.h>
int main(void)
{
  int c=0,i,hight=0;
  char s[11];
  
  scanf("%s",s);
  
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
      c++;
    else
      c=0;
    
    if(hight<c)
      hight=c;
  }

  printf("%d\n",hight);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

void aiueo(int *,int);
void insertionSort(int *,int);




int main(){
  int N,i,j;
  int A[100];

  scanf("%d",&N);

  for(i=0;i <= N-1;i++){
    scanf("%d",&A[i]);

  }aiueo(A,N);

    insertionSort(A,N);
    return 0;
  }

  void aiueo(int *A,int N){
    int i;
    for(i=0;i < N;i++){
      if(i > 0)printf(" ");
      printf("%d", A[i]);
    }
    printf("\n");
  }
  void insertionSort(int *A,int N){
    int v,i,j;

    for(i=1;i <= N-1;i++){
      v=A[i];
      j=i-1;
      while(j >= 0 && A[j] > v){
	A[j+1]=A[j];
	j--;

      }
      A[j+1] = v;
      aiueo(A,N);
    }
  }
      
		     
	
		       



Measured memory_bytes: 2108
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
lis_c=[list(map(int,input().split())) for i in range(n)]
ans=float("inf")
cnt=[[0]*c for i in range(3)]
for i in range(n):
    for j in range(n):
        cnt[(i+j)%3][lis_c[i][j]-1]+=1
# print(cnt)
for i in range(c):
    for j in range(c):
        for k in range(c):
            if i==j or j==k or i==k:
                continue
            tmp=0
            color=[i,j,k]
            for l in range(3):
                for m in range(c):
                    tmp+=cnt[l][m]*d[m][color[l%3]]
            ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 45660
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
p2=x*c*2
if x<y:
  p2+=(y-x)*b
p3=y*c*2
if y<x:
  p3+=(x-y)*a
p4=c*max(x,y)*2
print(min(p1,p2,p3,p4))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int mn = INF;
    int ans = 0;
    REP(i, n) {
        if (chmin(mn, a[i])) ans++;
    }
    cout << ans << EOL;
}


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

int main()
{
    map<string, int> m;

    int n;
    cin >> n;

    while (n--)
    {
        int x;
        int y;
        string z, a;

        cin >> x;
        if (x == 0)
        {
            cin >> z >> y;
            //m.insert(make_pair(z, y));
            m[z] = y;
        }
        if (x == 1)
        {
            cin >> z;
            cout << m[z] << endl;
        }
        if (x == 2)
        {
            cin >> z;
            m.erase(z);
        }
        if (x == 3)
        {
            cin >> z >> a;
            for (auto it = m.lower_bound(z); it != m.upper_bound(a); it++)
            {
                if (it->second)
                    cout << it->first << ' ' << it->second << endl;
            }
        }
    }
    return 0;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    string s;
    cin>>s;

    rep(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



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

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

g = As[0]
for a in As:
    g = gcd(g, a)

for a in As:
    if a >= K and (a-K) % g == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 14224
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f

let util = ABC(stdin)

let isOK w =
  w
  |> Array.sort
  |> Array.item 1
  |> (=) (w.[1])
  
let N = util.Scan1 int
let xs = util.ScanVecH int

xs
|> Array.windowed 3
|> Array.filter isOK
|> Array.length
|> printfn "%d"


Measured memory_bytes: 14812
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 55
using namespace std;
int a,b,c,maxx=0;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	maxx=max(a,b); maxx=max(maxx,c);
	int ans=123456789;
	for(int i=maxx;i<=521;i++)
	{
		int cnt=(i-a)/2+(i-b)/2+(i-c)/2;
		int temp=(i-a)%2+(i-b)%2+(i-c)%2;
//		cerr<<i<<" "<<cnt<<" "<<temp<<endl;
		if(temp&1)
			continue;
		ans=min(ans,cnt+temp/2);
	}
	printf("%d\n",ans);
}


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


int main(){
    int x,y;
    cin >> x >> y;
    int ans,ans1;
    for(int i=0;i<101;i++){
        ans1 = y - 4 * i;
        for(int j=0;j<101;j++){
            ans = ans1 - 2 * j;
            if(ans == 0 && i + j ==x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<bitset>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9+7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

class TrieNode{
    public:
    bool isword;
    char c;
    map<char,TrieNode*> m;
    string word;
    public:
    TrieNode(){}
    TrieNode(char ch){
        c=ch;
        isword=false;
    }
};

void insert(TrieNode* root,string word){
    TrieNode* temp=root;
    for(char c:word){
        if(temp->m.find(c)==temp->m.end())
            temp->m[c]=new TrieNode(c);
        temp=temp->m[c];
    }
    temp->isword=true;
    temp->word=word;
}



int main() {
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}




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

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> c(n);
    REP(i, n) cin >> c[i];

    vector<int> color(200005, 0);
    vector<LL> dp(n+1, 0);
    dp[0] = 0, dp[1] = 1;
    color[c[0]] = 1;
    FOR(i, 1, n)
    {
        if(c[i] != c[i-1]) dp[i+1] = (dp[i] + dp[color[c[i]]]) % MOD;
        else dp[i+1] = dp[i];
        
        color[c[i]] = i+1;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<math.h>
int a[100][20]={0};
int main()
{
	int n,m,i,j,t;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		scanf("%d",&a[i][j]);
	}
	int sum;
	sum=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
//			printf("1\n");
			double s=0;
			for(t=0;t<m;t++)
			{
				s+=((a[i][t]-a[j][t])*(a[i][t]-a[j][t]));
//				printf("2\n");
			}
			
			s=sqrt(s);
			int mu=s;
			if(s-mu==0)
			sum++;
		}
	}
	printf("%d\n",sum);
 } 

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mInt = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 100000000



int main(){
	int N,Q;
	cin>>N>>Q;
	
	fenwick_tree<long long> F(N);
	
	vector<long long> a(N);
	rep(i,N){
		cin>>a[i];
		F.add(i,a[i]);
	}	
	
	rep(i,Q){
		int t;
		cin>>t;
		
		if(t==0){
			int p,x;
			cin>>p>>x;
			F.add(p,x);
		}
		else{
			int l,r;
			cin>>l>>r;
			cout<<F.sum(l,r)<<endl;
		}
	}
	
    return 0;
}

Measured memory_bytes: 12132
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  string N;
  cin >> N;
  ll len=N.size();
  ll i;
  
  ll ans=0;
  ll f=0;
  for(i=len-1; i>=0; i--) {
    ll d=N[i]-'0';
    d+=f;
    
    if(0<=d && d<=5) {
      ans+=d;
      
      if(d==5 && i>0 && 5<=N[i-1]-'0' && N[i-1]-'0'<=9) f=1;
      else f=0;
    }else if(6<=d && d<=9) {
      ans+=10-d;
      f=1;
    }else if(d==10) {
      ans+=10-d;
      f=1;
    }
  }
  
  if(f) ans++;
  
  pt(ans);
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    bool chk = 1;
    int cnt = 0;
    for (int i = 1; i * (i + 1) <= 2 * n; i++) {
        if (i * (i + 1) == 2 * n) {
            chk = 0;
            cnt = i + 1;
        }
    }
    if (chk) {
        cout << "No\n";
        return 0;
    }
    vector<vector<int>> vec(cnt);
    bool seen[n] = {};
    int now = 0;
    rep(i, 0, cnt) {
        rep(j, 0, i) {
            rep(k, 0, cnt - 1) {
                if (!seen[vec[j][k] - 1]) {
                    vec[i].push_back(vec[j][k]);
                    seen[vec[j][k] - 1] = 1;
                    break;
                }
            }
        }
        rep(j, i, cnt - 1) { vec[i].push_back(++now); }
    }
    cout << "Yes\n" << cnt << "\n";
    rep(i, 0, cnt) {
        cout << cnt - 1 << " ";
        rep(j, 0, cnt - 1) { cout << vec[i][j] << " "; }
        cout << "\n";
    }
}


Measured memory_bytes: 5304
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi x(n + 1);
	rep2(i, 1, n) {
		cin >> x[i];
	}
	vi a(x);
	sort(all(a));
	rep2(i, 1, n) {
		if (x[i] < a[n / 2 + 1]) {
			cout << a[n / 2 + 1] << endl;
		}
		else {
			cout << a[n / 2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,d;cin >> n >> d;
    int ans=0;
    REP(i,n){
        ll x,y;cin >> x >> y;
        if(x*x+y*y<=d*d){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
  cin>>n;
  long long int p=n;
  if(p%2==0 && p%n==0)
    {
		cout<<p<<endl;
    }
    else
      cout<<p*2<<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

#define INF (1000000000)

typedef struct {
    int dx;
    int lev;
} STONE;

int min(int a, int b)
{
    if (a > b){
        return (b);
    }
    return (a);
}

int danger(STONE a, STONE b)
{
    return (abs(a.dx - b.dx) * (a.lev + b.lev));
}

int main(void)
{
    int n, m;
    int dx, lev;
    int i, j, k, l;
    int num[151];
    STONE info[151][11];
    static int dp[151][76][11];
    int ans;
    
    while (1){
        scanf("%d%d", &n, &m);
        
        if (n + m == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &num[i]);
            for (j = 0; j < num[i]; j++){
                scanf("%d%d", &info[i][j].dx, &info[i][j].lev);
            }
        }
        
        memset(dp, -1, sizeof(dp));
        memset(dp[0], 0, sizeof(dp[0]));
        if (m > 0){
            memset(dp[1][1], 0, sizeof(dp[1][1]));
        }
        
        ans = INF;
        
        for (i = 0; i <= m; i++){
            for (j = 1; j < n; j++){
                for (k = 0; k < num[j]; k++){
                    for (l = 0; l < num[j - 1]; l++){
                        if (dp[j][i][k] == -1 && dp[j - 1][i][l] != -1){
                            dp[j][i][k] = dp[j - 1][i][l] + danger(info[j][k], info[j - 1][l]);
                        }
                        else if (dp[j - 1][i][l] != -1){
                            dp[j][i][k] = min(dp[j][i][k], dp[j - 1][i][l] + danger(info[j][k], info[j - 1][l]));
                        }
                        if (dp[j][i][k] != -1 && j == n - 1){
                            ans = min(ans, dp[j][i][k]);
                        }
                    }
                    if (i != 0 && j >= 2){
                        for (l = 0; l < num[j - 2]; l++){
                            if (dp[j][i][k] == -1 && dp[j - 2][i - 1][l] != -1){
                                dp[j][i][k] = dp[j - 2][i - 1][l] + danger(info[j][k], info[j - 2][l]);
                            }
                            else if (dp[j - 2][i - 1][l] != -1){
                                dp[j][i][k] = min(dp[j][i][k], dp[j - 2][i - 1][l] + danger(info[j][k], info[j - 2][l]));
                            }
                        }
                        if (dp[j][i][k] != -1 && ((j == n - 2 && i < m) || (j == n - 1))){
                            ans = min(ans, dp[j][i][k]);
                        }
                    }
                }
            }
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 920
#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 d;
int c[26],s[365][26],last[26],t[365];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> d;
  for(int i=0;i<26;i++) {
    cin >> c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  for(int i=0;i<d;i++) {
    int score;
    for(int j=0;j<26;j++) {
      int tscore=s[i][j];
      for(int k=0;k<26;k++) {
        if(k==j) continue;
        tscore-=c[k]*(i+1-last[k]);
      }
      if(j==0) score=tscore;
      else if(tscore>score) {
        score=tscore;
        t[i]=j;
      }
    }
    last[t[i]]=i+1;
  }
  int cnt=100000;
  while(cnt--) {
    int day=rand()%d;
    int v=rand()%26;
    if(t[day]==v) continue;
    int dscore=0;
    int check[2]={v,t[day]};
    int pscore=0;
    int cscore=0;
    for(int i=0;i<2;i++) last[check[i]]=0;
    for(int i=0;i<d;i++) {
      pscore+=s[i][t[i]];
      last[t[i]]=i+1;
      for(int j=0;j<2;j++) {
        int id=check[j];
        pscore-=c[id]*(i+1-last[id]);
      }
    }
    for(int i=0;i<2;i++) last[check[i]]=0;
    for(int i=0;i<d;i++) {
      if(day==i) {
        cscore+=s[i][v];
        last[v]=i+1;
      }
      else {
        cscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(int j=0;j<2;j++) {
        int id=check[j];
        cscore-=c[id]*(i+1-last[id]);
      }
    }
    if(pscore<cscore) {
      t[day]=v;
    }
  }
  for(int i=0;i<d;i++) {
    printf("%d\n",t[i]+1);
  }
}

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

using namespace std;

int main()
{
    int n,k,i,j,l,m,res=1;
    cin>>n>>k;

    for(i=1;i<=n;i++)
    {
        j=res*2;
        l=res+k;
        m=min(j,l);
        res=m;

    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc159/abc159_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  vector<int> counts(N + 1, 0);
  ll max_ans = 0;
  rep(i, N) {
    int _c;
    cin >> _c;
    c[i] = _c;
    counts[_c]++;
  }

  rep(i, N + 1) {
    int cnt = counts[i];
    if (cnt) {
      max_ans += (ll)cnt * (cnt - 1) / 2;
    }
  }

  rep(i, N) {
    int _c = c[i];
    int cnt = counts[_c];
    if (cnt >= 2) {
      ll b = (ll)cnt * (cnt - 1) / 2;
      ll d = (ll)(cnt - 1) * (cnt - 2) / 2;
      cout << max_ans - (b - d) << endl;
    } else {
      cout << max_ans << endl;
    }
  }
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<long long> vals(n);
	const long long inf = 1ll<<60;
	const int magic = 200;
	vector<vector<long long> > f(magic + 1, vector<long long>(n + 1, -inf));
	vector<char> sig(n + 1, '+');
	cin >> vals[0];
	for(int i = 1; i < n; i++){
		cin >> sig[i] >> vals[i];
	}
	f[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < magic; j++){
			int csig = j%2 == 0?1:-1;
			if(sig[i] == '-'){
				f[j][i+1] = max(f[j][i+1], f[j][i] - csig * vals[i]);
				if(j) f[j-1][i+1] = max(f[j-1][i+1], f[j][i] - csig * vals[i]);
				f[j+1][i+1] = max(f[j+1][i+1], f[j][i] - csig * vals[i]);
			} else {
				f[j][i+1] = max(f[j][i+1], f[j][i] + csig * vals[i]);
				if(j) f[j-1][i+1] = max(f[j-1][i+1], f[j][i] + csig * vals[i]);
			}
		}
	}
	cout << f[0][n] << endl;
	return 0;
}


Measured memory_bytes: 159360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		// データ数を取得する
		int loop = Integer.parseInt(readLine(reader));
		for (int i = 0; i < loop; i++) {
			String[] sideArray = readLine(reader).split(" ");
			int[] sideNumArray = new int[sideArray.length];
			for (int j = 0; j < sideNumArray.length; j++) {
				sideNumArray[j] = Integer.parseInt(sideArray[j]);
			}

			// 三平方の定理を利用してチェックを行う
			Arrays.sort(sideNumArray);
			int smallTwo = sideNumArray[0] * sideNumArray[0] + sideNumArray[1]
					* sideNumArray[1];
			int largeOne = sideNumArray[2] * sideNumArray[2];

			// 定理を満たす場合はYES、そうでない場合はNOを出力する
			if (smallTwo == largeOne) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}

	}

	/**
	 * ストリームから1行読み込んで、文字列として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return　文字列
	 */
	private static String readLine(BufferedReader reader) {
		String line = null;
		try {
			line = reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return line;
	}
}

Measured memory_bytes: 20196
"""
全探索は無理なオーダー
N個のこま，
M - N回の移動が必要
−＞間の距離の長いのを移動しないように配置すれば良い
"""
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if N >= M:
    print(0)
    exit()

dist = [X[i+1] - X[i] for i in range(M-1)]
dist.sort(reverse=True)

count = sum(dist)
for i in range(N-1):
    count -= dist[i]

print(count)

Measured memory_bytes: 13960