akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(5);
  for(int i=0;i<5;i++){
    cin >> A.at(i);
  }
  vector<int> B(5);
  int sum=0;
  for(int i=0;i<5;i++){
    if(A.at(i)%10==0){
      B.at(i)=A.at(i);
    }
    else{
      B.at(i)=A.at(i)-A.at(i)%10+10;
    }
    sum+=B.at(i);
  }
  int minB=10000000;
  for(int i=0;i<5;i++){
    minB=min(minB,sum-B.at(i)+A.at(i));
  }
  cout << minB << endl;
}

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

using namespace std;

int main() {

    int n;
    cin >> n;
    if (n < 1200)
        cout << "ABC\n";
    else if (n < 2800)
        cout << " ARC\n";
    else
        cout << "AGC\n";
    return 0;
}




Measured memory_bytes: 256
ss = gets.chomp.split('')

childs = Array.new(ss.length, 0)

tmp = 0
ss.each_with_index { |s, i|
  if s == 'R'
    tmp += 1
  else
    childs[i] += tmp/2
    childs[i-1] += tmp/2+ tmp%2
    tmp = 0
  end
}

tmp = 0
ss.reverse!
childs.reverse!

ss.each_with_index do |s, i|
  if s == 'L'
    tmp += 1
  else
    childs[i] += tmp/2
    childs[i-1] += tmp/2 + tmp%2
    tmp = 0
  end
end

childs.reverse!

puts childs.join(' ')


Measured memory_bytes: 12308
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

vector<vector<ll>>bits(ll N){
	vector<vector<ll>> V;
	for(int t=0;t<(1<<N);t++){
		vector<ll> vv;
		for(int i=0;i<N;i++){
			if(t&(1<<i))vv.push_back(i);
		}
		V.push_back(vv);
	}
	return V;
}

int main()
{
	ll N;
	set<ll>st;
	cin>>N;
	rep(i,N){
		ll t,size;
		cin>>t;
		size=st.size();
		st.insert(t);
		if(st.size()==size){
			st.erase(t);
		}
	}
	cout<<st.size()<<endl;
}

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int cnt=0;
	if(a[0]=='1')cnt++;
	if(a[1]=='1')cnt++;
	if(a[2]=='1')cnt++;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
def ranlength(A):
    num = list(A)
    count = 1
    result = ''
    table = []
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
               count = count + 1
            else:
                result += str(num[i]) + str(count)
                table.append(count)
                count = 1
        except:
            result += str(num[i]) + str(count)
            table.append(count)
    return(table)
    
S = ranlength(input())
#RRLRLなら[2,1,1,1]で出る

def gather(x,y):
    ans = [0]*(x+y)
    if (x+y)%2 == 0:
        ans[x-1] = (x+y)//2
        ans[x] = (x+y)//2
    if x%2 == 0 and y%2 != 0:
        ans[x-1] = (x+y)//2
        ans[x] = (x+y)//2 + 1
    elif x%2 != 0 and y%2 == 0:
        ans[x-1] = (x+y)//2 + 1
        ans[x] = (x+y)//2
    return(ans)

children = []
for i in range(len(S)//2):
    children += gather(S[2*i],S[2*i+1])

print(*children)


Measured memory_bytes: 7056
#include<iostream>
#include<algorithm>
using namespace std;
int c[9],a[9],ans;
bool used[9];
void DFS(int len){
	if(len==9){
		if(!(2+a[0]+a[2]+a[5]-a[8]+10*(1+a[1]+a[4]-a[7])+100*(a[3]-a[6])))ans++;
		return;
	}
	if(c[len]==-2){
		for(int i=0;i<9;i++){
			if(!used[i]){
				a[len]=i,used[i]=true;
				DFS(len+1);
				used[i]=false;
			}
		}
	}
	else {
		a[len]=c[len];
		DFS(len+1);
	}
}
int main(){
	for(int i=0;i<9;i++)used[i]=0;
	for(int i=0;i<9;i++){
		cin>>c[i];c[i]--;
		if(c[i]>=0)used[c[i]]=true;
	}
	ans=0;
	DFS(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3016
#include <stdio.h>
#include <string.h>
int main(void)
{
  int a=0;int b=0;int c=0;int i=0;int j=0;int k=0;int p=0;
  int x[50]={0};
  int y[50]={0};
  scanf("%d",&a);
  while(i<a){
    scanf("%d",&x[i]);
    ++i;
  }
  memcpy(y,x,sizeof(x));
  for(p=0;p<(i-1);++p){
    for(j=(i-1);j>p;--j){
      if(y[j]<y[j-1]){
        k=y[j];
        y[j]=y[j-1];
        y[j-1]=k;
      }
      }
    }
    for(b=0;b<i;++b){
      if(x[b]!=y[b]){
        ++c;
      }
    }
    if(c>=3){
      printf("NO\n");
    }else
    if(c<3){
      printf("YES\n");
    }
    return 0;
}

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

using namespace std;
#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef set<char> setc;
typedef set<int> seti;

void solve(){
	//write solution here
	string a, b, c;
	cin>>a>>b>>c;
	cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
	
}

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

Measured memory_bytes: 3652
#include <iostream>

using namespace std;
long long a,b,c,A,B;
int main()
{
    cin>>a>>b>>c;
    if(c-a-b<=0)
    {
        cout<<"No";
        return 0;
    }
    A=4*a*b;
    B=(c-a-b)*(c-a-b);

    if(A<B)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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


using namespace std;

int main() {
  int N, ws, max_counter;

  cin>>N;

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


  ws = 0;
  max_counter = 0;
  for (int we = 1; we < N; ++we){
    if (H[we] <= H[we - 1]) {
      max_counter = max(max_counter, we - ws);
    } else {
      ws = we;
    }
  }

  cout<<max_counter<<"\n";

  return 0;
}

Measured memory_bytes: 640
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	long int sum;
	scanf("%d %d",&a,&b);
	sum = a * b;
	if(sum % 2 == 0)
		printf("Even\n");
		else
			printf("Odd\n");
			return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  if (s[0] == 'Y' &&
      s[1] == 'A' &&
      s[2] == 'K' &&
      s[3] == 'I') {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(3e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, q, a[MAX_N], b[MAX_N], cnt, ans=-1;

int main() {
    cin >> n;
    REP(i,n){
        cin >> a[i+1];
        b[i+1] = a[i+1];
    }
    sort(b,b+n+1);
    REP(i,n+1){
        if(a[i]!=b[i]) cnt++;
    }
    cin >> q;
    REP(i,q){
        if(ans<0 && cnt==0)ans=i;
        int x, y;
        cin >> x >> y;
        if(a[x]!=b[x])cnt--;
        if(a[y]!=b[y])cnt--;
        swap(a[x],a[y]);
        if(a[x]!=b[x])cnt++;
        if(a[y]!=b[y])cnt++;
    }
    if(ans<0 && cnt==0)ans=q;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	std::string str;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, str)){
#else
	while(std::getline(std::cin, str)){
#endif
		std::string result;

		for(int i = 0; i < str.size(); i++){
			if(str[i] == '@'){
				int n = str[i + 1] - '0';
				std::string s(1, str[i + 2]);
				for(int j = 0; j < n; j++){
					result.append(s);
				}
				i += 2;
			}
			else{
				std::string s(1, str[i]);
				result.append(s);
			}
		}
		std::cout << result << std::endl;
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
using namespace std;

int N,M;
int a[51],b[51],c[51],d[51];

void solve(int x,int y){
    int d1 = 1<<30;
    int ans = 0;
    rep(i,M){
        int dist = abs(x-c[i])+abs(y-d[i]);
        if(d1 > dist) {
            ans = i+1;
            d1 = dist;
        }
    }
    cout << ans << endl;
}

int main(){
    cin >> N >> M;
    rep(i,N) cin >> a[i] >> b[i];
    rep(i,M) cin >> c[i] >> d[i];
    
    rep(i,N) solve(a[i],b[i]);


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int cng;
  if(N%1000!=0){
  	cng = (N/1000+1)*1000-N;
  } else{
    cng = 0;
  }
  cout << cng << endl;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){
    ll n,m,l,r,x;
    
    scanf("%lld",&x);
    for(ll i=1;i<=500;i++){
    	ll a=i*i*i*i*i;
    	for(ll j=-500;j<=500;j++){
    		ll b=j*j*j*j*j;
    		if(a-b==x){
    			printf("%lld %lld",i,j);
    			return 0;
    		}
    	}
    }
    for(ll i=-500;i<=0;i++){
    	ll a=i*i*i*i*i;
    	for(ll j=-500;j<=500;j++){
    		ll b=j*j*j*j*j;
    		if(a-b==x){
    			printf("%lld %lld",i,j);
    			return 0;
    		}
    	}
    }
    
    

 	return 0;
}




Measured memory_bytes: 3828
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ramen = 700;
    int egg = 100;
    int roasted = 100;
    int green_onions = 100;
    int result = 700;
    if(s[0] == 'o') result = result + egg;
    if(s[1] == 'o') result = result + roasted;
    if(s[2] == 'o') result = result + green_onions;
    cout << result << endl;
}

Measured memory_bytes: 256
def cumsum(li):
    ret = []
    sum = 0
    for i in li:
        sum += i
        ret.append(sum)
    return ret


class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self._bit = [0 for _ in range(size)]
        self._size = size

    def add(self, i, w):
        """
        i 番目に w を加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x

    def sum(self, i):
        """
        0 番目から i 番目までの合計
        :param int i:
        :return:
        """
        ret = 0
        x = i + 1
        while x > 0:
            ret += self._bit[x - 1]
            x -= x & -x
        return ret

    def __len__(self):
        return self._size


def count_inversions(li, max=None):
    """
    リストから転倒数 (li[i] > li[j] (i < j) となる (i, j) の組み合わせ数) を返す
    バブルソートするときに反転する必要がある数。
    :param numpy.ndarray | list of int li:
            すべての要素が 0 以上の int である配列。
            BIT を使うので、マイナスを含んだり最大値が大きい場合は np.argsort の結果を指定
            ただしリストに重複を含む場合は np.argsort は unstable なので別の方法使うこと
            https://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html
    :param int max: li の最大値。わかる場合は指定
    :rtype: int
    """
    if not max:
        max = __builtins__.max(li)
    bit = BinaryIndexedTree(size=max + 1)
    ret = 0
    for i in range(len(li)):
        ret += i - bit.sum(li[i])
        bit.add(li[i], 1)
    return ret


def bisect_left_callable(fn, x, lo, hi):
    """
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


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

series_sorted = sorted(series)

# L と r の選び方の組み合わせ数。1 から N までの和に等しい
lr_size = (N + 1) * N / 2


# cumsum[L] <= cumsum[r] となる (L, r) の組み合わせ数を数える
# 転倒数を数えて lr_size から引けばいい
# それが (lr_size + 1) // 2 以上である一番大きい x を探す
def solve(i):
    x = series_sorted[i]
    # series を x 以上かどうかで 1 と 0 に置換し累積和を取る
    cumsum_li = [0] + cumsum([1 if s >= x else -1 for s in series])
    # 転倒数 (cumsum にマイナスを含むので最小でも 0 になるよう N を加算）
    inversions = count_inversions([N + i for i in cumsum_li], max=N + N)
    if lr_size - inversions >= (lr_size + 1) // 2:
        return i
    else:
        return float('inf')


ans_i = bisect_left_callable(solve, float('inf'), lo=0, hi=N)
print(series_sorted[max(0, min(N - 1, ans_i - 1))])


Measured memory_bytes: 120932
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int i,j,c;
    vector<int> a;
    vector<int> b;
    for(i=0;i<10;i++)
    {
        cin>>c;
        a.push_back(c);
    }
    for(j=0;j<10;j++)
    {
        cin>>c;
        b.push_back(c);
    }
    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end(),greater<int>());
    cout<<a[0]+a[1]+a[2]<<" "<<b[0]+b[1]+b[2]<<endl;
    return 0;
}



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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;


int main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, 0, n-1) cin >> A[i];

  int cont = 0;
  rep(i, 0, n-1) {
    while (A[i] % 2 == 0) {
      cont++;
      A[i] /= 2;
    }
  }

  cout << cont << endl;
}


Measured memory_bytes: 384
#!/usr/local/bin/ruby
a = Array.new
while (line = gets) != "0 0\n"
 a << line.split(" ").map(&:to_i)
end
a.each do |x,y|
 case x
  when 1
   ans = y
  when 2
   ans = 31 + y
  when 3
   ans = 60 + y
  when 4
   ans = 91 + y
  when 5
   ans = 121 + y
  when 6
   ans = 152 + y
  when 7
   ans = 182 + y
  when 8
   ans = 213 + y
  when 9
   ans = 244 + y
  when 10
   ans = 274 + y
  when 11
   ans = 305 + y
  when 12
   ans = 335 + y
 end
 case ans % 7
  when 0
   puts "Wednesday"
  when 1
   puts "Thursday"
  when 2
   puts "Friday"
  when 3
   puts "Saturday"
  when 4
   puts "Sunday"
  when 5
   puts "Monday"
  when 6
   puts "Tuesday"
 end
end

Measured memory_bytes: 6112
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(){
	    int n,x,r=1,t;
	    int arr[999];
scanf("%d",&n);
for(x=0;x<n;x++)scanf("%d",arr+x);
qsort(arr,n,4,compare);
    t=arr[0];
    for(x=1;x<n;x++){
        if(t!=arr[x]){
            t=arr[x];
            r++;
        }
    }
    printf("%d\n",r);
    return 0;
}

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


//I have to use hashset
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        
        str = br.readLine();
        int n = Integer.parseInt(str);

        str=br.readLine();
        String[] temp = str.split("\\s");
        
        int[] A = new int[temp.length];
        for(int i= 0;i<temp.length;i++){
            A[i] = Integer.parseInt(temp[i]);
        }

        str = br.readLine();
        int q = Integer.parseInt(str);

        str=br.readLine();
        String[] temp2 = str.split("\\s");

        for(int i=0;i<q;i++){
            int m =Integer.parseInt(temp2[i]);
            List<Integer> list = new ArrayList<Integer>();
            if(cal(n,A,list,m)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
        
        
       
    }

 
   public static boolean cal(int Len,int[]AA,List<Integer> list,int m){//i,n,A
        int F = AA[0];
        list.add(F);
     
        if(Len == 1){
            if(F == m){
                return true;
            }else{
                int l = list.size();
                
                for(int i=0;i<l-1;i++){
                    if(list.get(i) + list.get(l-1) == m){
                        return true;
                    }
                }

                return false;
            }
        }
    
        int[] temp = new int[AA.length -1];
        
        for(int i=1;i<AA.length;i++){
            temp[i-1] =AA[i];
        }
        
        if(F == m){
            return true;
        }
        
        if(list.size()>1){
            int l = list.size();
            for(int i=0;i<l-1;i++){
                if(list.get(i) + list.get(l-1) == m){
                    return true;
                }else{
                    list.add(list.get(i) + list.get(l-1));
                }
            }
            return cal(temp.length,temp,list,m);
        }else{
            return cal(temp.length,temp,list,m);
        }
   }
}


Measured memory_bytes: 558900
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pll;
const int N = 200010;
int ch[N][2], ec[N];
vector<pll> t[N];
bool flag0;

void dfs(int x, LL k)
{
	if(!ch[x][0]) { t[x].push_back(mp(0, 0)); return; }
	dfs(ch[x][0], k); dfs(ch[x][1], k);
	Rep(w, 2){
		int l = ch[x][0], r = ch[x][1];
		int p = 0;
		if (t[l].size()){
			Rep0(i, t[l].size() - 1) {
			//	printf("%d ", t[l][i].first);
				bool flag = false;
				while (p < t[r].size() && t[l][i].second + ec[l] + ec[r] + t[r][p].first <= k)
					p ++, flag = true;
				if (flag) t[x].push_back(mp(t[l][i].first + ec[l], t[r][p - 1].second + ec[r]));
			}
			//printf("\n");
		}
		swap(ch[x][0], ch[x][1]);
	}
	sort(t[x].begin(), t[x].end());
	if (!t[x].size()) flag0 = true;
}

int main()
{
	
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i ++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (ch[x][0]) ch[x][1] = i;
		else ch[x][0] = i;
		ec[i] = y;
	}
	
	LL l = 0, r = 1e12;
	
	while(l != r) {
		LL mid = (l + r) >> 1;
		Rep(i, n) t[i].clear();
		flag0 = false;
		dfs(1, mid);
		if (flag0) l = mid + 1;
		else r = mid;
	}
	printf("%lld\n", l);
	
	return 0;
}


Measured memory_bytes: 28660
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,l;
char s[maxn];
char ton[maxn];
int main(){
	n=read();
	scanf("%s",s+1);
	l=strlen(s+1);
	for(int i='A';i<='Z';i++){
		ton[i]=i;
		ton[i+26]=i;
	}
	for(int i=1;i<=l;i++){
		s[i]=ton[s[i]+n];
	}
	for(int i=1;i<=l;i++)
	printf("%c",s[i]);
	return 0;
}


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

int main(void){
  while(true){
    int q1, b, c1, c2, q2, aChicken, oChicken;
    cin >> q1 >> b >> c1 >> c2 >> q2;
    if(q1 == 0) break;
    aChicken = min(q2, b / c1);
    b = b - aChicken * c1;
    oChicken = max(0, b / c2);
    b = b - oChicken * c2;

    while(aChicken + oChicken < q1 && aChicken != 0){
    b += c1;
    b += oChicken * c2;
    oChicken = b / c2;
    b = b - oChicken * c2;
    aChicken--;
    }

    if(aChicken == 0){
      cout << "NA" << endl;
    }else{
      cout << aChicken << " " << oChicken << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{int i,a,b;
for(i=1;;i++){scanf("%d%d",&a,&b);
if(a!=0||b!=0){if(a<=b){printf("%d %d\n",a,b);}
               else{printf("%d %d\n",b,a);}}
else{return 0;}}}              

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int w[100],v[100];
int n;
long long dp[101][100001];
long long solve(int start,int weight) {
  if (start >= n) return 0;
  if (weight <= 0) return 0;
  if (dp[start][weight] != -1) return dp[start][weight];
  long long res = 0;
  if (weight >= w[start]) {
    res = max(res,solve(start+1,weight-w[start])+v[start]);
  }
  res = max(res,solve(start+1,weight));
  dp[start][weight] = res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int W; cin >> n >> W;
  for(int i=0;i<101;i++) {
    for(int j=0;j<100001;j++) {
      dp[i][j] = -1;
    }
  }
  for(int i=0;i<n;i++) {
    cin >> w[i] >> v[i];
  }
  cout << solve(0,W);
  return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c&&a%2==0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    while(a%2==0&&b%2==0&&c%2==0){
        ll aa=a,bb=b,cc=c;
        a=bb/2+cc/2;
        b=aa/2+cc/2;
        c=aa/2+bb/2;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
MOD = 10 ** 9 + 7


def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD


def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()


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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

const int MAXN = 16;
int sum[(1 << MAXN)];
int dp[(1 << MAXN)][MAXN];
int path[MAXN][MAXN];

int cost(int bit1, int bit2) {
  return sum[bit1 | bit2] - (sum[bit1] + sum[bit2]);
}

int main() {
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    path[a][b] = c;
    path[b][a] = c;
  }

  REP(i, (1 << n)) {
    REP(bit, n) {
      if (!(i & (1 << bit))) continue;
      FOR(bit2, bit + 1, n) {
        if (!(i & (1 << bit2))) continue;
        sum[i] += path[bit][bit2];
      }
    }
  }

  REP(i, (1 << n)) {
    REP(j, n) {
      dp[i][j] = (1 << 30);
    }
  }
  dp[1][0] = 0;

  FOR(mask, 1, (1 << n)) {
    REP(i, n) {
      if (!(mask & (1 << i))) continue;
      if (dp[mask][i] == (1 << 30)) continue;

      REP(j, n) {
        if (mask & (1 << j)) continue;
        if (path[i][j] == 0) continue;

        dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j], dp[mask][i] + cost(mask ^ (1 << i), (1 << j)));
      }

      int mask1 = (((1 << n) - 1) ^ mask);
      for (int mask2 = mask1; mask2 > 0; mask2 = ((mask2 - 1) & mask1)) {
        dp[mask | mask2][i] = min(dp[mask | mask2][i], dp[mask][i] + cost(mask ^ (1 << i), mask2));
      }
    }
  }
  cout << dp[(1 << n) - 1][n - 1] << endl;

  return 0;
}


Measured memory_bytes: 4480
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
char chara[n];
scanf("%s",chara);
int len=strlen(chara);
if(len%2){
	printf("No");
	return 0;
}
else{
	for (int i=0;i<len/2;i++){
		if(chara[i]!=chara[i+(len/2)]){
			printf("No");
			return 0;
		}
		else{
			continue;
		}
	}
}
printf("Yes");
return 0;
}


Measured memory_bytes: 1668
n, k = [ int(v) for v in input().split() ]
r, s, p = [ int(v) for v in input().split() ]
dp_list = [ [0, 0, 0] for i in range(n+1) ]
t = input()
hand = "rsp"
win = [r, s, p]

t_list = [t[i::k] for i in range(k)]
ans = 0
for z in t_list:
    dp_list = [ [0, 0, 0] for i in range(len(z)+1) ]
    for i, v in enumerate(z):
        a = (hand.index(v)-1)%3
        for j in range(3):
            dp_list[i+1][j] = max(dp_list[i][(j+1)%3], dp_list[i][(j-1)%3])
        dp_list[i+1][a] += win[a]

    ans += max(dp_list[-1])

print(ans)

Measured memory_bytes: 65712
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n;
    cin >> n;

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

    long long res = ((n % 2 == 0 && cnt[0] == 0) || (n % 2 != 0 && cnt[0] == 1) ? 1 : 0);
    for (int i = (n % 2 == 0 ? 1 : 2); i <= n; i += 2) {
        if (cnt[i] == 2) {
            res *= 2;
            res %= 1000000007;
        } else {
            res = 0;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 4096
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    vector<ll>a(n);for(ll i=0;i<n;++i)a[i]=in();
    map<ll,ll>difcnt;for(ll i=0;i<n;++i)++difcnt[a[i]-i];
    ll ans=0;
    for(ll i=0;i<n;++i){
        ans+=difcnt[-a[i]-i];
        --difcnt[a[i]-i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 27352
n = int(input())
h = [int(x) for x in input().split()]

a = [0, abs(h[1]-h[0])]

for i in range(2, n):
	mva = abs(h[i]-h[i-1])+a[i-1]
	mvb = abs(h[i]-h[i-2])+a[i-2]
	a.append(min(mva, mvb))
print(a[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  ll a[100];
  rep(i, n) cin>>a[i];
  
  ll s=0;
  rep(i, n) {
    ll b; cin>>b;
    s+=b;
  }
  
  ll c[100];
  rep(i, n-1) cin>>c[i];
  
  rep(i, n-1) {
    if(a[i]+1==a[i+1]) s+=c[a[i]-1];
  }
  
  cout << s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  int count=0;
  int flg=0;
  vector<int> ans(N);
  while(flg!=1&&count!=N){
    int val=1;
    int web=-1;
    for(int j=0;j<N;j++){
      if(b[j]==val){
        web=j;
        val++;
      }else if(b[j]!=0){
        val++;
      }
    }
    if(web!=-1){
      ans[count]=b[web];
      b[web]=0;
      count++;
    }else{
      flg=1;
    }
  }
  if(flg==1){
    cout<<-1<<endl;
  }else{
    reverse(ans.begin(),ans.end());
    for(int i=0;i<N;i++){
      cout<<ans[i]<<endl;
    }
  }
}

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

#define all(a) (a).begin(),(a).end()

int main() {
	vector<int> A(3);;
	cin>>A[0]>>A[1]>>A[2];
	sort(all(A));
	int ans = 0;
	if(A[0]%2!=A[1]%2){
		A[2]++;A[1]++;ans++;
	} 
	ans += A[2]-A[1] + (A[2]-(A[0]+A[2]-A[1]))/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

bool flip[10][10];
bool tmp[10][10];

bool get(int h,int w){
	static int dh[] = {1,0,0,0,-1};
	static int dw[] = {0,1,0,-1,0};
	bool ret = flip[h][w];
	FOR(i,5){
		int nh = dh[i]+h,nw = dw[i]+w;
		if(0 <= nh && nh < 10 && 0 <= nw && nw < 10)
			ret ^= tmp[nh][nw];
	}

	return ret;
}

int main()
{
	int n; cin>>n;
	while(n--){
		FOR(i,10) FOR(j,10){ int x; cin>>x; flip[i][j] = x == 1; }
		FOR(i,2<<10){
			memset(tmp,0,sizeof(tmp));
			FOR(j,10) tmp[0][j] = (i & (1 << j)) != 0;
			for(int j = 1; j < 10; j++) for(int k = 0; k < 10; k++){
				tmp[j][k] = get(j-1,k);
			}
			bool ok = true;
			FOR(j,10) if(get(9,j)){
				ok = false;
				break;
			}
			if(ok) break;
		}
		FOR(i,10) FOR(j,10) printf("%d%c",tmp[i][j],j == 9 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
 //https://atcoder.jp/contests/dp/tasks/dp_b
int main(){
  int n,k; cin>>n>>k;
  int h[n];
  for(int i=0; i<n; i++) cin>>h[i];
  vector<int> dp(n, 0);
  for(int i=1; i<n; i++){
    int mn=1e9+1;
    for(int j=1; j<=k; j++){//going backwards
      if(i-j>=0)
        mn=min(mn, abs(h[i]-h[i-j])+dp[i-j]);
    }
    dp[i]+=mn;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
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> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<int, int> factorize_factorial(int a) {
    map<int, int> ret;
    REPF(x, 2, a + 1) {
        int y = x;
        for(int i = 2; i * i <= y; i++) {
            int cnt = 0;
            while (y % i == 0) y /= i, cnt++;
            if (cnt != 0) ret[i] += cnt;
        }
        if (y != 1) ret[y] += 1;
    }
    return ret;
}

signed main() {
    int N;
    cin >> N;
    auto f = factorize_factorial(N);

    vector<set<int>> se(100);
    FORE(p, f) {
        if (p.second >= 2) se[2].insert(p.first);
        if (p.second >= 4) se[4].insert(p.first);
        if (p.second >= 14) se[14].insert(p.first);
        if (p.second >= 24) se[24].insert(p.first);
        if (p.second >= 74) se[74].insert(p.first);
    }

    int ans = 0;
    {
        int tmp = 0;
        FORE(t, se[2]) {
            FORE(f1, se[4]) {
                FORE(f2, se[4]) {
                    if (t == f1 || t == f2 || f1 == f2) continue;
                    tmp++;
                }
            }
        }
        ans += tmp / 2;
    }
    {
        int tmp = 0;
        FORE(x, se[2]) {
            FORE(y, se[24]) {
                if (x == y) continue;
                tmp++;
            }
        }
        FORE(x, se[4]) {
            FORE(y, se[14]) {
                if (x == y) continue;
                tmp++;
            }
        }
        ans += tmp;
    }
    ans += SZ(se[74]);
    cout << ans << endl;
    return (0^_^0);
}



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

int main () {
    int n, t, e;
    while (cin >> n >> t >> e) {
        vector<int> x(n);
        for (int i = 0; i < n; i++) {
            cin >> x[i];
        }

        int result = -1;
        for (int i = 0; i < n; i++) {
            for (int xx = x[i]; xx <= t + e; xx += x[i]) {
                if (xx >= t - e) {
                    result = i + 1;
                }
            }
            if (result > 0) {
                break;
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 1200
using System;

namespace p3 {
	class prg {
		static void Main() {
			uint h = uint.Parse(Console.ReadLine());
			uint m, s;
			s = (uint)(h % 60);
			h -= s;
			h /= 60;
			m = (uint)(h % 60);
			h -= m;
			h /= 60;
			Console.WriteLine(h + ":" + m + ":" + s);
		}
	}
}

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

S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y)
{
    vector<ll> p(N);
    for (int i = 0; i < N; i++)
    {
        p[i] = i;
    }
    double ans = 0;
    ll cnt = 0;
    do
    {
        double tmp = 0;
        for (int i = 0; i < N - 1; i++)
        {
            tmp += sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
        }

        ans += tmp;
        cnt++;
    } while (next_permutation(p.begin(), p.end()));

    cout << fixed << setprecision(10) << (double)ans / cnt << endl;
}

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


Measured memory_bytes: 256
using System;

namespace ABC168B
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            if(S.Length <= K) Console.WriteLine(S);
            else Console.WriteLine(S.Substring(0,K)+"...");
        }
    }
}


Measured memory_bytes: 27476
#include<iostream>
#include<algorithm>
using namespace std;
int ans[1001][1001][3];char m[3]={'J','O','I'};
int main(){int h,w,k;cin>>h>>w>>k;char z;for(int i=0;i<h;i++)for(int r=0;r<3;r++)ans[i][0][r]=0;for(int j=0;j<w;j++)for(int r=0;r<3;r++)ans[0][j][r]=0;for(int i=1;i<=h;i++){for(int j=1;j<=w;j++){cin>>z;for(int r=0;r<3;r++){ans[i][j][r]=ans[i-1][j][r]+ans[i][j-1][r]-ans[i-1][j-1][r];if(m[r]==z)ans[i][j][r]++;}}}int x[2],y[2];for(int u=0;u<k;u++){for(int i=0;i<2;i++)cin>>y[i]>>x[i];for(int r=0;r<3;r++){if(r)cout<<" ";int cnt=ans[y[1]][x[1]][r]+ans[y[0]-1][x[0]-1][r];cnt-=ans[y[1]][x[0]-1][r]+ans[y[0]-1][x[1]][r];cout<<cnt;}cout<<endl;}return 0;}

Measured memory_bytes: 12784
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<sstream>
using namespace std;
void p(int x)
{
    int i,j;
    for(i=2;i<=1000000;i++)
    {
    if(x==1) { printf("\n"); return; }

    while(x%i==0)
      {
        printf(" %d",i);
        x=x/i;
      }
    }
    printf(" %d\n",x);
}

int main()
{
    int x;cin>>x;
    printf("%d:",x);
    p(x);

return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

mint dp[100005][13];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n) {
        rep(j,13) {
            if (s[i] == '?') {
                for (int k = 0; k <= 9; k++) {
                    dp[i+1][(10*j+k)%13] += dp[i][j];
                }
            } else {
                int c = s[i]-'0';
                dp[i+1][(10*j+c)%13] += dp[i][j];
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13896
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;

  int d[4];
  rep(i, 4) d[i] = s[i] - '0';

  rep(bit, 1<<3) {
    int result = d[0];
    string ans;

    ans += s[0];

    rep(i, 3) {
      if (bit & (1<<i)) result += d[i+1], ans += '+';
      else result -= d[i+1], ans += '-';

      ans += s[i+1];
    }

    if (result == 7) {
      cout << ans << "=7" << endl;
      return (0);
    }
  }

  return (0);
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(_t => int.Parse(_t)).ToArray();
            int x = tmp[0];
            int t = tmp[1];
            var ans = x - t;
            ans = ans < 0 ? 0 : ans;
            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        long k = sc.nextLong();
        int n = str.length();
        
        for (int i = 0; i < k; i++) {
            if (c[i] == '1') {
                if (i == k - 1) {
                    System.out.println(1);
                    return;
                }
            } else {
                System.out.println(c[i]);
                return;
            }
        }
    }
}


Measured memory_bytes: 21844
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  bool flag = false;
  if(a + b > c * 2) flag = true;
  ll ans = 0;
  if(flag)
  {
    ll h = min(x, y);
    ans = h * c * 2;
    x -= h;
    y -= h;
  }
  ans += min(x * c * 2, x * a);
  ans += min(y * b, y * c * 2);
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int main() {
	int N,K;
	cin>>N>>K;
	ll ans=0;
	for (ll i = K; i < N+2; i++){
		ans+=(i*(N+N-i+1))/2-((i-1)*i)/2+1;
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3588
from math import sqrt
n,d=map(int,input().split())
x=[]

ans=0
for i in range(n):
    x.append(list(map(int,input().split())))

for j in range(n):
    for k in range(n):
        a=0
        if j!=k:
            for l in range(d):
                a+=(x[j][l]-x[k][l])**2
            if sqrt(a).is_integer()==True:
                ans+=1
print(ans//2)


Measured memory_bytes: 3060
s = input()

if s[0] == s[1] and s[0] == s[2]:
    print('No')
elif s[0] == s[1] and s[0] == s[3]:
    print('No')
elif s[1] == s[2] and s[2] == s[3]:
    print('No')
elif s[0] == s[1] and s[2] == s[3]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2]:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
double dist(pair<int,int> a,pair<int,int> b){
  return pow((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second),0.5);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  int no_of_input;
  vector<pair<int,int> > vect1;
  int input1,input2;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input1 >> input2;
    vect1.push_back({input1,input2});
  }
  sort(vect1.begin(),vect1.end());
  double sum = 0;
  do{
    for(int i=0;i<vect1.size()-1;i++){
      
      sum += dist(vect1[i],vect1[i+1]);
    }
  }while(next_permutation(vect1.begin(),vect1.end()));
  for(int i=1;i<=no_of_input;i++){
    sum /= i;
  }
  cout << sum;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,a,c = 0;scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    c += a%2;
  }
  printf(c%2 ? "NO\n":"YES\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
    	int a,b ; cin >> a >> b;
    	vector<int> arr;

    	if(a <= b){
    		cout << 0 << endl;
    		return 0;
    	}


    	while(a--){
    		int k; cin >> k;
    		arr.push_back(k);
    	}

    	sort(arr.begin(),arr.end());
    	while(b--){
    		arr.pop_back();
    	}

    	ll sum = 0;
    	for(int a: arr){
    		sum += a;
    	}
    	cout << sum << endl;




    	return 0;
}

Measured memory_bytes: 1400