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


int main() {
  int N;
  cin >> N ;
  
  vector<char> c(N);
  int cnt = 0, r = 0;
  for (int i=0; i<N; i++) {
    cin >> c.at(i);
    if (c.at(i) =='R') {
      r++;
    }
  }
  for (int j=0; j<r; j++) {
    if ( c.at(j) == 'W' ) {
	  cnt++;
    }
  }
 
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        int[] array = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = scanner.nextInt();
        }

        for (int count = 0; count < k; count++) {
            final int[] next = new int[n + 2];
            for (int i = 1; i <= n; i++) {
                final int left = Math.max(i - array[i], 1);
                final int right = Math.min(i + array[i] + 1, n + 1);
                next[left]++;
                next[right]--;
            }
            for (int i = 2; i <= n; i++) {
                next[i] += next[i - 1];
            }

            if (Arrays.stream(array, 1, n + 1).allMatch(i -> i == n)) {
                final String answer = Arrays.stream(array, 1, n + 1)
                    .mapToObj(Integer::toString)
                    .collect(Collectors.joining(" "));
                System.out.println(answer);
                return;
            }
            array = next;
        }

        final String answer = Arrays.stream(array, 1, n + 1)
            .mapToObj(Integer::toString)
            .collect(Collectors.joining(" "));
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


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

#define mod 1000000007
#define INF 1000000000

#define eb emplace_back
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

using ll = long long;
using vi = vector<int>;

string color(int r) {
	if (r >= 2800) return "red";
	if (r >= 2400) return "orange";
	if (r >= 2000) return "yellow";
	if (r >= 1600) return "blue";
	if (r >= 1200) return "cyan";
	if (r >= 800) return "green";
	if (r >= 400) return "brown";
	if (r >= 1) return "gray";
	return "";
}

int main() {
	int n, mn=0, mx=0;
	cin >> n;

	vi a(n);
	rep(i,n) cin>>a[i];

	int lgm = 0;
	set<string> clrs;

	rep (i, len(a)) {
		if (a[i] < 3200) clrs.emplace(color(a[i]));
		else lgm += 1;
	}
	mn = len(clrs);
	mx = mn+lgm;

	mn = (!mn)?1:mn;

	printf("%d %d\n", mn, mx);

	return 0;
}





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

bool is_first = true;

void print_b(int index, vector<long long> &array){
  for (int i = index-1; i >= 0; i--) {
    if(!is_first) printf(" ");
    printf("%lld", array[i]);
    is_first = false;
  }
}

void print_f(int index, vector<long long> &array) {
  for (int i = 0; i < index; i++) {
    if(!is_first) printf(" ");
    printf("%lld", array[i]);
    is_first = false;
  }
}

int main() {
  int n;
  cin >> n;
  int f_index = 0, b_index = 0;
  vector<long long> forward_array(n, -1);
  vector<long long> backward_array(n, -1);

  long long a;
  bool is_tail = true;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(is_tail) forward_array[f_index++] = a;
    else backward_array[b_index++] = a;
    is_tail = !is_tail;
  }

  //
  if(is_tail){
    print_b(b_index, backward_array);
    print_f(f_index, forward_array);
  }else{
    print_b(f_index, forward_array);
    print_f(b_index, backward_array);
  }
  printf("\n");



  return 0;
}



Measured memory_bytes: 5248
#include <iostream>  
#include <cstdio>  
#include <algorithm>  
#include <cstring>  
#include <cmath>   
#define N 505  
using namespace std;  
typedef long long ll;  
int c[505]; 
int s[505]; 
int f[505]; 
int main()  
{  
    int n;  
    scanf("%d",&n);  
    for(int i=1;i<=n;i++)  
        scanf("%d%d%d",&c[i],&s[i],&f[i]);  
    for(int i=1;i<=n;i++){  
        int ans=0;  
        for(int j=i;j<n;j++){  
            if(ans<s[j])   
                ans=s[j];  
            if(ans%f[j]!=0)   
                ans=ans+f[j]-ans%f[j];  
            ans+=c[j];  
        }  
        printf("%d\n",ans);  
    }  
}  

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;


int main(){

	int n;
	scanf("%d", &n);
	int x = 0, y = 0, t = 0;

	For(i, 1, n){
		int nt, nx, ny;
		scanf("%d%d%d", &nt, &nx, &ny);

		int d = nt - t, dis = abs(nx - x) + abs(ny - y);
		if(d < dis || (dis - d) % 2){
			puts("No");
			return 0;
		}

		x = nx, y = ny, t = nt;
	}
	puts("Yes");

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();
        if(b == 1){
            System.out.println(0);
        }else if(b-1 <= n){
            System.out.println((a*(b-1)/b) - a*((b-1)/b));
        }else{
            System.out.println((a*n/b) - a*(n/b));
        }
    }
}

Measured memory_bytes: 27084
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

char S[4010];
int R[4010];
int G[4010];
int B[4010];
int N;

void f(int *C, char c) {
  int sum = 0;
  C[0] = sum;
  for (int i = 0; i < N; ++i) {
    if (S[i] == c)
      ++sum;
    C[i+1] = sum;
  }
}

int main(void) {
  scanf("%d", &N);
  scanf("%s", S);

  f(R, 'R');
  f(G, 'G');
  f(B, 'B');
  // for (int i = 0; i <= N; ++i)
  //   printf("%d ", R[i]);

  int64_t ans = 0;
  for (int i = 1; i < N - 1; ++i) {
    for (int l = 0; l < i; ++l) {
      if (S[i] == S[l])
        continue;
      int *A;
      if (S[i] == 'R')
        A = S[l] == 'G' ? B : G;
      else if (S[i] == 'G')
        A = S[l] == 'R' ? B : R;
      else
        A = S[l] == 'G' ? R : G;

      int cnt = A[N] - A[i+1];
      int r = i * 2 - l;
      if (r < N && S[r] != S[i] && S[r] != S[l])
        --cnt;
      ans += cnt;
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 1776
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    ans = 0
    i, j = 0, 1
    while j <= i + (n - i) // 2:
        t = s[i:j]
        if t in s[j:]:
            ans = max(ans, j - i)
            j += 1
        else:
            i += 1
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n,m;
long long dp[100005];
long long ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int w;
		long long v;
		scanf("%d%lld",&w,&v);
		for(int j=m;j>=w;j--)
		{
			dp[j]=max(dp[j],dp[j-w]+v);
			ans=max(ans,dp[j]);
		}
	}
	printf("%lld",ans);
	return 0;
}



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

int dfs(vector<vector<char>> &S, pair<int,int> begin, int H, int W){
    stack<pair<pair<int,int>,int>> st;
    st.push(make_pair(begin, 0));
    int M=0;
    vector<vector<int>> D(H, (vector<int>(W,-1)));
    while(!st.empty()){
        pair<pair<int,int>,int> p = st.top();
        st.pop();
        if(D[p.first.first][p.first.second] == -1 || D[p.first.first][p.first.second] > p.second){
            D[p.first.first][p.first.second] = p.second; 
        }else{
            continue;
        }
        if(p.first.first-1 >= 0 && S[p.first.first-1][p.first.second] == '.' )st.push(make_pair(make_pair(p.first.first-1, p.first.second),p.second+1));
        if(p.first.second-1 >= 0 && S[p.first.first][p.first.second-1] == '.' )st.push(make_pair(make_pair(p.first.first, p.first.second-1),p.second+1));
        if(p.first.first+1 < H && S[p.first.first+1][p.first.second] == '.' )st.push(make_pair(make_pair(p.first.first+1, p.first.second),p.second+1));
        if(p.first.second+1 < W && S[p.first.first][p.first.second+1] == '.' )st.push(make_pair(make_pair(p.first.first, p.first.second+1),p.second+1));
    }
    rep(i,H){
        rep(j,W){
            M = max(M, D[i][j]);
        }
    }
    return M;
}

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> S(H,(vector<char>(W,'0')));
    rep(i,H){
        rep(j,W){
            cin >> S[i][j];
        }
    }
    int MA = 0;
    pair<int,int> begin;
    rep(i,H){
        rep(j,W){
            if(S[i][j] == '.'){
                begin = make_pair(i,j);
                MA = max(MA, dfs(S,begin,H,W)); 
            }
        }
    }


    cout << MA << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200000)
#define MOD (998244353)


int main(void)
{
    int n;
    scanf("%d",&n);

    int64_t ans = 0;
    for(int i=1;i<=n-1;i++)
    {
        ans += i;
    }
    printf("%ld\n", ans);

    return 0;
}







Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <unistd.h>

using i64 = std::uint_fast32_t;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  using namespace io;
  i64 h = scan();
  i64 n = scan();
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    s += scan();
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;
typedef long long LL;
int main() {
    LL m,n;
    scanf("%lld%lld",&m,&n);
    if (m>=2&&n>=2) printf("%lld\n", m*n-((m-1+n-1)<<1));
    else {
        if (m>n) swap(m, n);
        if (n==1) puts("1");
        else printf("%lld\n", n-2);
    }
    return 0;
}


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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;


#define ff(i, a, b) for ( i=a; i<(b); i++)
#define ffr(i, a) for (int i=0; i<(a); i++)
#define fd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ffd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy

//class node{
//public:
//    int data;
//    node* next;
//};
//void push( node **head_ref,int new_data){
//node* new_node=new node();
//new_node->data=new_data;
//new_node->next=*head_ref;
//*head_ref=new_node;
//}
//void print(node* n){
// while(n!=NULL){
//    cout<<n->data<<" ";
//    n=n->next;
// }
//}
int main() {
	ios_base::sync_with_stdio(0); //cin.tie(0);

   ll t,n,m,k,ans=0,sum=0,res=0,temp=0;
   cin>>n;
   m=n;
   while(m!=1){
    m/=2;
    res++;
   }
   ans=pow(2,res)*2-1;
   cout<<ans<<"\n";
    return 0;
}









Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
  int a,b,c,x,t=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int q=0;q<=c;q++)
        if(i*500+j*100+q*50==x)
          t++;
  cout<<t<<endl;
  system("pause");
  return 0;
}


Measured memory_bytes: 504
n_to_cluster = {}
for n in [1, 3, 5, 7, 8, 10, 12]:
    n_to_cluster[n] = 0
for n in [4, 6, 9, 11]:
    n_to_cluster[n] = 1
for n in [2]:
    n_to_cluster[n] = 2

x, y = map(int, input().split())    
if n_to_cluster[x] == n_to_cluster[y]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 10000000007
using namespace std;
void run(){
ll n,k;
cin>>n>>k;
string s;
cin>>s;
ll maxi=0,oldo=0,oldn=0;
ll ro=0,rz=0;
ll preze[n+1]={0},preon[n+1]={0};
for(ll i=0;i<n;i++){

if(s[i]=='0'&&((i>=1)&&s[i-1]=='1')){
	preon[ro]=oldn;
    ro++;
}
if(s[i]=='1'&&(i>=1&&s[i-1]=='0')){
	preze[rz]=oldo;
	rz++;

}
if(s[i]=='0'){
	oldo++;
	oldn=0;
}
if(s[i]=='1'){
	oldn++;
	oldo=0;
}

}
if(s[n-1]=='1'){
	preon[ro]=oldn;
    ro++;
}
else{
	preze[rz]=oldo;
	rz++;
}
for(ll i=1;i<rz;i++)	
	{
		preze[i]+=preze[i-1];
	}
for(ll i=1;i<ro;i++)	
	{
		preon[i]+=preon[i-1];
	}	

for(ll i=0;i<ro;i++)	
	{
		//cout<<preon[i]<<" "<<preze[i]<<endl;
		
		ll se=(preon[i]-(i-k-1>=0?preon[i-k-1]:0));
	//	cout<<se<<endl;
		ll sa=0;
		if(s[0]=='0'){
				 sa=(preze[i]-(i-k>=0?preze[i-k]:0));
			//	 cout<<"a";
			
		}
		else{
				 sa=((i-1>=0?preze[i-1]:0)-(i-k-1>=0?preze[i-k-1]:0));
				// cout<<(i-1);
			
		}
	//	cout<<sa<<"ss"<<endl;
		se+=sa;
		
		maxi=max(maxi,se);
	}	
	ll se=(((ro>=1)?preon[ro-1]:0)-(ro-k-1>=0?preon[ro-k-1]:0));
	//out<<se;
	if(s[n-1]=='0'){
		se+=(preze[rz-1]-(rz-1-k>=0?preze[rz-1-k]:0));
	}
	maxi=max(maxi,se);
	if(ro==0){
	cout<<n<<endl;
	}
	else{
		cout<<maxi<<endl;
	}
	
	
}
int main() {
	
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N, P; cin >> N >> P;
  vector<ll> so;
  for(ll i=1; i*i<=P; i++){
    if(P%i==0) {
      so.pb(i);
      if(P/i!=i) so.pb(P/i);
    }
  }
  sort(all(so));
  reverse(all(so));
  rep(i,(int)so.size()){
    //cout << so[i] << endl;
  }
  rep(i,(int)so.size()){
    if(so[i]==1) { cout << 1 << endl; return 0;}
    ll P_ = P;
    ll counter = 0;
    while(1){
      if(P_%so[i]==0){
        counter++;
        P_ /= so[i];
      }
      else{
        if(counter >= N){
          cout << so[i] << endl;
          return 0;
        }
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char str[20];
int n;
void dfs(int a){
	if(a==n){
		printf("%s\n",str);
		return;
	}
	int mv=0;
	for(int i=0;i<a;i++){
		mv=max(mv,str[i]-'a'+1);
	}
	for(int j=0;j<=mv;j++){
		str[a]='a'+j;
		dfs(a+1);
	}
}
int main(){

	int a;scanf("%d",&a);n=a;
	dfs(0);
}

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

int main() {
    int N,M,C; 
    cin >> N >> M >> C;
    vector<int>B(M);
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cnt = 0;
        for(int i = 0; i < M; i++) {
            int A;
            cin >> A;
            cnt += A*B[i];
        }
        if(cnt+C > 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char P[105];
pair<pair<string,int>,int> p[105];
int main(){
  int N , t;
  cin>>N;
  for(int i=0;i<N;i++){
    scanf("%s%d",P,&t);
    p[i] = make_pair(make_pair(P,-t),i);
  }
  sort(p,p+N);
  for(int k=0;k<N;k++) cout<<p[k].second+1<<endl;
}
  

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

//配列の要素を順番に出力する関数
void trace(int A[],int N){
  for(int i = 0;i < N;i++){
    if(i > 0)cout << " ";
    cout << A[i];
  }
  cout << endl;
}

//挿入ソートの関数
void insertionSort(int A[],int N){
  int j,v;
  for(int i = 1;i < N;i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A,N);
  }
}

int main(void){
  int N;
  int A[101];

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

  trace(A,N);
  insertionSort(A,N);

  return 0;
}


Measured memory_bytes: 3108
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    N, K = LI()
    A = LI()

    for _ in range(K):
        B = [0]*(N+1)
        for i in range(N):
            l = max(i - A[i], 0)
            r = min(A[i] + i + 1, N)
            B[l] += 1
            B[r] -= 1
        for i in range(N):
            B[i+1] += B[i]

        if A == B:
            break
        A = B
    print(*A[:-1], sep=" ")


main()


Measured memory_bytes: 114036
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int ans = 0;
        double min = Double.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            double tmp = (double)t - (double)h[i] * 0.006;
            double diff = Math.abs(a - tmp);
            if (diff < min) {
                ans = i;
                min = diff;
            }
        }

        System.out.println(ans+1);
    }
}

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

int main() {
	long long n,a[1000000],max=-1,count=0,flag=0;
	cin>>n;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
	    if(a[i]>=a[i+1]){
	        count++;
	    }
	    else{
	        count=0;
	    }
	    if(max<count){
	        max=count;
	    }
	}
if(max==-1)
max=0;
	cout<<max<<'\n';
	return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define opinit() rep(i,9){if(i<3)op[i]='+';else if(i<6)op[i]='-';else op[i]='*';}
#define a n[0]
#define b n[1]
#define c n[2]
#define d n[3]
#define op1 op[0]
#define op2 op[1]
#define op3 op[2]

int ans(int x,int y,char op){
	switch(op){
	case '+':
		return x+y;
	case '-':
		return x-y;
	case '*':
		return x*y;
	}
	
}

int main(){
	vector<int>n(4);
	vector<char>op(9);
	opinit();
	
	int A,B;
	
	while(cin >> a >> b >> c >> d && a || b || c || d){
		sort(n.begin(),n.end());
		bool flag = false;
		do{
			sort(op.begin(),op.end());
			do{
				/*1p^[*/
				A = ans(a,b,op1);
				B = ans(A,c,op2);
				if( ans(B,d,op3) == 10){
					printf("((%d %c %d) %c %d) %c %d\n",a,op1,b,op2,c,op3,d);
					flag = true;
					goto end;
				}
				/*2p^[*/
				A = ans(b,c,op2);
				B = ans(a,A,op1);
				if( ans(B,d,op3) == 10){
					printf("(%d %c (%d %c %d)) %c %d\n",a,op1,b,op2,c,op3,d);
					flag = true;
					goto end;
				}
				/*3p^[*/
				A = ans(c,d,op3);
				B = ans(b,A,op2);
				if( ans(a,B,op1) == 10){
					printf("%d %c (%d %c (%d %c %d))\n",a,op1,b,op2,c,op3,d);
					flag = true;
					goto end;
				}
				/*4p^[*/
				A = ans(a,b,op1);
				B = ans(c,d,op3);
				if( ans(A,B,op2) == 10){
					printf("(%d %c %d) %c (%d %c %d)\n",a,op1,b,op2,c,op3,d);
					flag = true;
					goto end;
				}
				/*5p^[*/
				A = ans(b,c,op2);
				B = ans(A,d,op3);
				if( ans(a,B,op1) == 10){
					printf("%d %c ((%d %c %d) %c %d)\n",a,op1,b,op2,c,op3,d);
					flag = true;
					goto end;
				}
			}while(next_permutation(op.begin(),op.end()));
		}while(next_permutation(n.begin(),n.end()));
		end:
		if(!flag)cout << "0" << endl;
	}
}
	

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

if K==1:
    print(N**3)
    exit()
# if K==2:
#     print( ((N+1)//2)**3 +((N//2)**3))
#     exit()
if not K%2 == 0:
    print((N//K)**3)
    exit()

# print(N/K)
print((N//K)**3 +(int(N/K + 1/2)**3))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /** 借金額 */
    private static final int LOAN = 100000;

    /** 1週間ごとの利子（％） */
    private static final int INTEREST = 5;

    /** 切り上げの単位 */
    private static final int ROUND_UP_SCALE = 1000;

    /**
     * <p>
     * 引数で与えられたn週間後の借金額の残高を出力する。<br/>
     * 借金額は10万円、利子は1週間につき5％、利子の計算後に1,000円未満を切り上げることとする。<br/>
     * <br/>
     * 標準入力から以下を入力値として受け取る。<br/>
     * ・何週間後か（0?100）<br/>
     * </p>
     *
     * @param args
     *            利用しない。
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        // 入力値を受け取る
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int weeks = Integer.parseInt(line);

        // n週間後の借金の残高を計算する
        int loanBalance = calcLoanBalance(weeks);

        // 結果を出力する
        System.out.println(loanBalance);

    }

    /**
     * <p>
     * 引数で与えられた週数が経過したときの借金の残高を計算する。<br/>
     * 1週間経過するごとに利子と残高を再計算する。<br/>
     * この際、金額の1,000円未満を切り上げる。<br/>
     * </p>
     *
     * @param weeks
     *            経過週数
     * @return 利子額
     */
    private static int calcLoanBalance(int weeks) {

        int loanBalance = LOAN;
        for (int i = 0; i < weeks; i++) {
            loanBalance = roundUp(loanBalance + (loanBalance * INTEREST) / 100,
                    ROUND_UP_SCALE);
        }

        return loanBalance;

    }

    /**
     * <p>
     * 引数で与えられた数値を、引数で指定された単位で切り上げる。<br/>
     * </p>
     *
     * @param amount
     *            単位
     * @param scale
     *            切り上げの単位
     * @return 結果
     */
    private static int roundUp(int amount, int scale) {

        int quotient = amount / scale;
        int remainder = amount % scale;

        if (remainder == 0) {
            return amount;
        } else {
            return (quotient + 1) * scale;
        }

    }
}

Measured memory_bytes: 16852
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int K;
  scanf("%d", &K);
  vector<int> a(K);
  REP(i, K) scanf("%d", &a[i]);

  llint l = 2, r = 2;
  for (int i = K-1; i >= 0; --i) {
    llint x = a[i];

    r -= r % x;
    if (l % x) {
      l += x - (l % x);
    }

    if (l > r) {
      puts("-1");
      return 0;
    }

    r += x - 1;
  }

  cout << l << " " << r << endl;
  return 0;
}


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

int main(){
  int n; cin >> n;
  int64_t res = 1, prev = 2;
  for(int i=0; i<n-1; ++i){
    int64_t tmp = res;
    res += prev;
    prev = tmp;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int n, k; cin >> n >> k;
    if (k == 1) {
        cout << 0 << "\n";
        return;
    }
    cout << (n - k) << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  if(n % 2 == 1 && k <= (n + 1) / 2) cout << "YES";
  else if(n % 2 == 0 && k <= n / 2) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,ANS;
  cin>>A>>B;
  ANS=6-A-B;
  cout<<ANS<<endl;
  return 0;
}



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

int
main(int argc, char *argv[])
{
  int i = 0, j = 0;
  char s[100];
  scanf("%s", s);
  char t[100]={};
 

  while(s[i] != '\0'){
    if(s[i] == '0'){ t[j++] = '0';}
    else if(s[i] == '1'){ t[j++] = '1';}
    else if(j != 0){
      j--;
      t[j] = '\0';
    }
    i++;
    
  }
  printf("%s\n", t);

  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int count = Integer.parseInt(br.readLine());
			int number[] = new int[count];
			int result[] = new int[count];
			for (int i = 0; i < count; i++) {
				String s = br.readLine();
				number[i] = Integer.parseInt(s);
				while (true) {
					if (number[i] < 10)
						break;
					s = String.valueOf(number[i]);
					int two[] = new int[s.length() - 1];
					int max = 0;
					for (int j = 0; j < s.length() - 1; j++) {
						String s1 = s.substring(0, j + 1);
						String s2 = s.substring(j + 1, s.length());
						two[j] = Integer.parseInt(s1) * Integer.parseInt(s2);
					}
					for (int j = 0; j < two.length; j++) {
						max = Math.max(max, two[j]);
					}
					number[i] = max;
					result[i]++;
				}
			}
			for (int i = 0; i < count; i++) {
				System.out.println(result[i]);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 27920
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u')System.out.println("vowel");
        else System.out.println("consonant");
    }
}

Measured memory_bytes: 35556
/*input
10
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
void solve()
{
	lld x;
	cin >> x;
	cout << x+x*x+x*x*x << endl; 
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n / 100 * 100 + n / 100 * 10 + n / 100 >= n)
	{
		cout << n / 100;
		cout << n / 100;
		cout << n / 100 << endl;
	}
	else
	{
		cout << n / 100 + 1;
		cout << n / 100 + 1;
		cout << n / 100 + 1 << endl;

	}
}


Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in a:
    if i%4==0:
        c4+=1
    elif i%2==0:
        c2+=1

if c2 == len(a):
    print('Yes')
elif c2 >= 2:
    if c4 >= (math.ceil((len(a)-c2)/2)):
        print('Yes')
    else:
        print('No')
elif c4 >=(len(a)//2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 20168
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        long a=in.nextLong();
        long b=in.nextLong();
        long c=in.nextLong();
        long d=in.nextLong();
        System.out.println(Math.max(Math.max(a*c, a*d), Math.max(b*c, b*d)));
        
        
    }
}

Measured memory_bytes: 35832
import numpy as np

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

L_list = L_list

max_idx = np.argmax(L_list)
sum_edges = np.sum(L_list)

if sum_edges > 2 * L_list[max_idx]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21628
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 1;
  for (int i = 1; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++) {
      if (h[j] > h[i]) {
        ok = false;
        break;
      }
    }
    if (ok)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a,int b){
  if(a%b==0) return b;
  return gcd(b,a%b);
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}
int main(void){
  int n,ans,i;
  scanf("%d",&n);
  int a[n],l[n+2],r[n+2];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  l[0]=a[0];
  r[n-1]=a[n-1];
  for(i=1;i<n;i++){
    l[i]=gcd(l[i-1],a[i]);
    r[n-i]=gcd(r[n-i+1],a[n-i]);
  }
  ans=max(l[n-2],r[1]);
  for(i=1;i<n-1;i++) ans=max(ans,gcd(l[i-1],r[i+1]));
  printf("%d\n",ans);
  return 0;
}

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

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      Console.ReadLine();
      foreach (var points in ReadNumbers())
      {
        var x1 = points[0];
        var y1 = points[1];
        var x2 = points[2];
        var y2 = points[3];
        var x3 = points[4];
        var y3 = points[5];
        var det = 4 * ((x1 - x2) * (y2 - y3) - (y1 - y2) * (x2 - x3));
        var c_x = (y1 - y2) * (y1 + y2) + (x1 - x2) * (x1 + x2);
        var c_y = (y2 - y3) * (y2 + y3) + (x2 - x3) * (x2 + x3);
        var x = (2 / det) * ((y2 - y3) * c_x + (y2 - y1) * c_y);
        var y = (2 / det) * ((x3 - x2) * c_x + (x1 - x2) * c_y);
        var lenSquare = new[]
        {
          Math.Pow(x2 - x1, 2.0) + Math.Pow(y2 - y1, 2.0),
          Math.Pow(x3 - x2, 2.0) + Math.Pow(y3 - y2, 2.0),
          Math.Pow(x1 - x3, 2.0) + Math.Pow(y1 - y3, 2.0)
        };
        var len = lenSquare.Select(l => Math.Sqrt(l)).ToArray();
        var A = Math.Acos((lenSquare[1] + lenSquare[2] - lenSquare[0]) / (2 * len[1] * len[2]));
        var r = (len[0] / Math.Sin(A)) / 2;
        Console.WriteLine("{0:F3} {1:F3} {2:F3}", x, y, r);
      }
    }

    static IEnumerable<double[]> ReadNumbers()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return line.Split(' ').Select(s => double.Parse(s)).ToArray();
    }
  }
}

Measured memory_bytes: 6200
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
s = input()

ans = ''
for x in s:
    i = ord(x) + n
    if i > ord('Z'): i -= (ord('Z') - ord('A') + 1)
    ans += chr(i)
print(ans)

Measured memory_bytes: 5180
f = True
while True:
	for k in range(3):
		p = list(input())
		if p[0] == '0':
			f = False
			break
		a, b = 0, 0
		del p[0]
		for x in p:
			if x == 'A': a += 1
			else: b += 1
		if a > b: a += 1
		else: b += 1
		print(a, b)
	if not f: break


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

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;

  rep(i, 60) {
    ll x = 0;
    rep(j, n) if (a[j]>>i&1) ++x;
    ll now = x *(n - x) % mod;
    rep(j, i) now = now * 2 % mod; // オーバーフロー対策
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>> W >>H >>x >>y >>r;

	if (r<=x&&x<=(W-r)&&r<=y&&y<=(H-r)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;




int main() {
	int x, a, b;
	cin >> x >> a >> b;
	a = abs(x - a);
	b = abs(x - b);
	if (a > b) cout << "B" << endl;
	else cout << "A" << endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
N, M = map(int,input().split())
A = list(map(int,input().split()))
Q = []
for a in A : 
    heappush(Q, [-a, 1])
for i in range(M) :
    B, C = map(int,input().split())
    heappush(Q, [-C, B])
ans = 0
cnt = N
while N>0 :
    C, B = heappop(Q)
    C = -C
    if B < N : 
        ans += B * C
        N -= B
    else :
        ans += C * N
        N = 0
print(ans)

Measured memory_bytes: 37052
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/* 
void comb(vector<vector <ll> > &v) {
	ll mod=1000000007;
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main() {
	ll n,k;
	cin>>n>>k;
	ll a[220000];
	rep(i,0,n)cin>>a[i];
	ll b[220000]={0};
	rep(i,0,n) b[a[i]]++;
	b[0]==454507213;
	sort(b,b+n+1);
	ll cnt=0;
	ll start=0;
	ll ans=0;
	rep(i,0,n+1)if(b[i]!=0) cnt++;
	rep(i,0,n+1)if(b[i]!=0){start=i; break;}
	if(cnt-k>0) rep(i,start,start+cnt-k) ans+=b[i];
	if(cnt-k<=0) cout<<"0";
	else cout<<ans;
	//rep(i,0,n+1)cout<<b[i]<<endl;
	
}


Measured memory_bytes: 3712
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;

int main() {
	int n, k;
	string s;
	char t;
	cin >> n >> s >> k;
	t = s[k - 1];
	for (int i = 0; i < n; i++) {
		if (s[i] != t) cout << "*";
		else cout << s[i];
	}
	cout << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
std::vector<int> g[N];
std::vector<int> levels;
void dfs(int cur , int par = -1)
{
    if(par!=-1)
        levels[cur] = levels[par] + 1;
    for(auto x : g[cur])
    {
        if(x!=par)
        {
            dfs(x,cur);
        }
    }
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,k;
    cin>>n>>k;
    levels.resize(n);
    for (int i = 0; i < n-1; ++i)
    {
        int x ,y;
        cin>>x>>y;
        x--;y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    int ans(k);
    levels[0] = 0;
    dfs(0);

    for (int i = 0; i < n; ++i)
    {
        if(levels[i]==0)
        {
            int si = g[i].size();
            int s = 1;
            for(int i = 0 ; i < si ; i++)
            {
                ans*=(max(0ll,k-s));
                ans%=MOD;
                s++;
            }
        }
        else
        {
            int si = g[i].size();
            int s = 2;
            for(int i = 0 ; i < si - 1 ; i++)
            {
                ans*=(max(0ll,k-s));
                ans%=MOD;
                s++;
            }
        }
        //show(ans);
    }
    cout<<ans;

    printclock;
    return 0;
}


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

count = 0
for a in A:
    if a < 0:
        count += 1

absA = list(map(abs, A))
if count % 2 == 0:
    print(sum(absA))
else:
    min_num = min(absA)
    print(sum(absA) - 2 * min_num)


Measured memory_bytes: 14412
def count(A, idx, N):
    cnt = {}
    for i in range(N):
        if A[i][idx[i]] not in cnt:
            cnt[A[i][idx[i]]] = 0
        cnt[A[i][idx[i]]] += 1
    return cnt


def main():
    N, M = map(int, input().split())
    A = [list(input().split()) for _ in range(N)]
    ans = float("inf")
    idx = [0] * N
    used = set()
    for _ in range(M):
        cnt = count(A, idx, N)
        mx = (0, -1)
        for x in cnt:
            mx = max(mx, (cnt[x], x))
        ans = min(ans, mx[0])
        used.add(mx[1])
        for i in range(N):
            while idx[i] < M and A[i][idx[i]] in used:
                idx[i] += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47980