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

main(){
	int n,m,p ;
	int num[110] ;
	
	while( cin >> n >> m >> p , n ){
		int sum = 0 ;
		for( int i=1 ; i<=n ; i++ ){
			cin >> num[i] ;
			sum += num[i] ;
		}
		if( num[m] == 0 ) cout << 0 << endl ;
		else cout << sum*(100-p)/num[m] << endl ;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,K,S;
  cin>>N>>K>>S;
  rep(i,K) cout<<S<<" ";
  rep(i,N-K){
    if(S<1e9) cout<<S+1<<" ";
    else cout<<S-1<<" ";
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int cnt[6];

int main() {
	cin >> N;
	
	map<char, int> conv;
	string tmp = "MARCH";
	REP(i, 5) conv[tmp[i]] = i + 1;
	
	REP(i, N) {
		string str;
		cin >> str;
		cnt[conv[str[0]]]++;
	}
	
	ll ans = 0;
	REP(i, 1<<5) {
		int c = 0;
		REP(j, 5) if (i >> j & 1) c++;
		if (c != 3) continue;
		ll p = 1;
		REP(j, 5) if (i >> j & 1) p *= cnt[j + 1];
		ans += p;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::pair<int,int> > bombs;
	bombs.reserve(n);
	rep(i,n) {
		int a,b;
		std::cin >> a >> b;
		bombs.emplace_back(a,b);
	}
	std::vector<std::pair<int,int> > codes;
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		codes.emplace_back(a,b);
	}
	std::sort(all(bombs));
	std::vector<int> xors(n+1);
	xors[0] = bombs[0].second; xors[n] = bombs[n-1].second;
	rep(i,n-1) {
		xors[i+1] = bombs[i].second^bombs[i+1].second;
	}
	debug(xors);
	std::map<std::pair<int,int>, int> map;
	std::vector<std::vector<int> > g(n+1,std::vector<int>());
	std::vector<int> bombs2(n);
	rep(i,n) {
		bombs2[i] = bombs[i].first;
	}
	debug(bombs2);
	rep(i,m) {
		int a = std::lower_bound(all(bombs2),codes[i].first)-bombs2.begin();
		int b = std::upper_bound(all(bombs2),codes[i].second)-bombs2.begin();
		map[std::make_pair(a,b)] = i;
		map[std::make_pair(b,a)] = i;
		if(a==b) continue;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	debug(n,m);
	std::set<int> set;
	std::vector<int> went(n+1,false);
	auto dfs = [&] (auto f, int i, int par) -> int {
		int impossible = false;
		went[i]=true;
		debug(i,par);
		for(int to: g[i]) {
			if(went[to]) continue;
			if(f(f,to,i)) impossible = true;
		}
		if(xors[i]) {
			if(par==-1) return 1;
			xors[par]^=1;
			set.emplace(map[std::make_pair(i,par)]);
		}
		return impossible;
	};
	debug(went);
	rep(i,n+1) {
		if(went[i]) continue;
		went[i]=true;
		if(dfs(dfs,i,-1)) {
			print(-1);
			return 0;
		}
	}
	print(set.size());
	for(auto x:set) {
		std::cout << x+1 << ' ';
	}
	std::cout << ENDL;
	return 0;
}


Measured memory_bytes: 49388
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  string s = "ACL";
  rep(i, n-1){
    s += "ACL";
  }
  cout << s << endl;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
  int a, b;
  
  while (~scanf("%d%d", &a, &b)){
    stringstream conv;
    conv << a + b;
    cout << conv.str().size() << endl;
  }

  return (0);
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<vector<int>> C(10,vector<int>(10));
    string v;
    for(int i=1;i<N+1;++i){
        v = to_string(i);
        C[(int)v[0]-48][(int)v[v.length()-1]-48] += 1;
    }
    int ans = 0;
    for(int i=0;i<10;++i){
        for(int j=0; j<10;++j){
            if(i==0 || j==0){
                continue;
            }
            ans += C[i][j]*C[j][i];
        }
    }
    cout << ans << endl;
}

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

int n;
char s[100001] = {}, a[100001] = {}; // a -> animals; s -> answers
string ans;

bool solve(char x, char y){
	a[1] = x;
	a[2] = y;
	bool p, q;
	for(int i = 2; i <= n-1; i++)
		a[i] == 'S'?
			s[i] == 'o' ? a[i+1] = a[i-1] :
				a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' :
			s[i] == 'x' ? a[i+1] = a[i-1] :
				a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S';
	p = a[n] == 'S' ?
		s[n] == 'o' ?
			a[n-1] == a[1] ? true : false : 
		a[n-1] != a[1] ? true : false : 
		// a[n] == 'W'
		s[n] == 'o' ?
			a[n-1] == a[1] ? false : true : 
		a[n-1] != a[1] ? false : true ;
	q = a[1] == 'S' ?
		s[1] == 'o' ?
			a[n] == a[2] ? true : false : 
		a[n] != a[2] ? true : false : 
		// a[n] == 'W'
		s[1] == 'o' ?
			a[n] == a[2] ? false : true : 
		a[n] != a[2] ? false : true ;
	return p && q;
}

int main() {
	cin >> n;
	for(int h = 1; h <= n; h++) a[h] = '_';
	for(int i = 1; i <= n; i++){
		cin >> s[i];
	}
	
	if(solve('S', 'S')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('S', 'W')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('W', 'S')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('W', 'W')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else cout << "-1" << endl;
	
	return 0;
}

Measured memory_bytes: 888
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# 組み合わせの数
count = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                count += 1

print(count)


Measured memory_bytes: 3060
#include <stdio.h>

#define X 10000

int main() {
	int n = 0, a[10000], i, j, count = 0, flag = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n; i++) {
		for (j = 2; j <= (int)sqrt(a[i]); ++j) {
			if (a[i] % j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			count++;
		}
		flag = 0;
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2036
N, M = map(int, input().split())

sa = set()
sb = set()


for i in range(M):

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

    if a==1:
        sa.add(b)
    elif b==N:
        sb.add(a)

print("POSSIBLE" if len(sa&sb)!=0 else "IMPOSSIBLE")

Measured memory_bytes: 19024
#include <stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define chmax(p,q)(p<(q)?p=(q),1:0)

double dp[510][510];
int a[510];
double cum[510];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,0,n)cum[i+1]=cum[i]+a[i];
	rep(i,1,n+1)dp[0][i]=-1e20;
	rep(k,1,m+1)rep(i,k,n+1)rep(j,k-1,i)chmax(dp[k][i],dp[k-1][j]+(cum[i]-cum[j])/(i-j));
	printf("%.9f\n",dp[m][n]);
}



Measured memory_bytes: 3856
mat_small = []
xy = input().split(' ')
for i in range(int(xy[0])):
    mat_small.append(input())

big  = [(int(xy[1])+ 2)* '#'  for a in range(int(xy[0])+ 2) ]

for s in range(1, (int(xy[0])+ 1)):
    big[s] = '#' + mat_small[s-1] + '#'

for v in big:
    
    print(v)  

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

using std::cin;

int main()
{
    int vert_num;
    cin >> vert_num;
    std::vector<int> vert(vert_num);

    for (auto i = 0; i < vert_num; i++) {
        vert.at(i) =  i + 1;
    }

    int horiz;
    cin >> horiz;

    while (horiz--) {
        int swap1, swap2;
        char x;
        cin >> swap1 >> x >> swap2;

        int tmp = vert.at(swap1 - 1);
        vert.at(swap1 - 1) = vert.at(swap2 - 1);
        vert.at(swap2 - 1) = tmp;
    }

    for (auto i = 0; i < vert_num; i++) {
        std::cout << vert.at(i) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

#define N 1000001

int main(){
	int i,j, num[N], n, k, q, cnt[N];

	scanf("%d %d %d", &n, &k, &q);
	
	for (i = 0; i < q; i++) {
		scanf("%d", &num[i]);
	}

	for (i = 0; i < n; i++) {
		cnt[i] = 0;
	}

	for (i = 0; i < q; i++){
		cnt[num[i] - 1]++;
	}

	for (i = 0; i < n; i++) {
		if (cnt[i] > (q -k))
			printf("Yes\n");
		else {
			printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 6912
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
inf = 10**9+7

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [inf for i in range(n+1)]
dp[1] = 0
for i in range(1,n):
    for j in range(k):
        if i-j-1 >= 0:
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(h[i]-h[i-j-1]))
        else:
            break
print(dp[n])

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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MAXN = 3e3+20;
const double EPS= 1e-10;

int n, m;
string s, t;
int lcs[MAXN][MAXN];

stack<char> pila;

void backtracking(int target){
    for(int i=n; i>=1 && target; --i){
        for(int j= m; j>=1 && target ; --j){
            if(target==lcs[i][j] && s[i-1]==t[j-1]){
                target--;
                pila.push(s[i-1]);
                break;
            }
        }
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    cin>> s>> t;
    n= s.size();
    m= t.size();
    for1(i,n){
        for1(j,m){
//            if(j==5 && i==1) cout<< (s[i-1]== t[j-1])<<el;
            if(s[i-1]==t[j-1]){
                lcs[i][j]= lcs[i-1][j-1]+1;
            }else{
                lcs[i][j]= max(lcs[i-1][j], lcs[i][j-1]);
            }
//            cout<< lcs[i][j]<< " ";
        }
//        cout<< el;
    }
//    cout<<el;
//    cout<< lcs[n][m]<<el;
    backtracking(lcs[n][m]);
    while(pila.size()){
        cout<< pila.top();
        pila.pop();
    }
    cout<<el;
}


Measured memory_bytes: 35712
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int a[7]={1,3,5,7,8,10,12},b[4]={4,6,9,11},c[1]={2},x,y,f,q,p,v;
int main()
{
	cin>>x>>y;
	if(x==2||y==2)
		cout<<"No\n";
	else{
		for(int i=0;i<7;i++){
			if(x==a[i])
				f=1;
			if(y==a[i])
				q=1;
		}
		for(int i=0;i<4;i++){
			if(x==b[i])
				p=1;
			if(y==b[i])
				v=1;
		}
		if((q==1&&f==1)||(p==1&&v==1))
			cout<<"Yes\n";
		else
			cout<<"No\n";

	}

	return 0;
}



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

using namespace std;

int main(int argc, char *argv[]) {
  vector<string> result;
  int m, d;
  int mday[12] = {31, 29, 31, 30, 31, 30,
                  31, 31, 30, 31, 30, 31};

  while (true) {
    cin >> m >> d;
    if (m == 0 && d == 0)
      break;
    int days = 0;
    for (int i = 1; i < m; i++)
      days += mday[i-1];
    days += d;
    days %= 7;
    if (days == 1)
      result.push_back("Thursday");
    else if (days == 2)
      result.push_back("Friday");
    else if (days == 3)
      result.push_back("Saturday");
    else if (days == 4)
      result.push_back("Sunday");
    else if (days == 5)
      result.push_back("Monday");
    else if (days == 6)
      result.push_back("Tuesday");
    else
      result.push_back("Wednesday");
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 1196
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	p = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	k = lcm(a)
	s = 0
	for i in 1:n
		s += k÷a[i]
	end
	println(s%p)
end

main()

Measured memory_bytes: 172488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<=b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>=b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    while(true){
        int M,nl,nr; cin >> M >> nl >> nr;
        if(M==0) break;
        int A[M]; rep(i,M) cin >> A[i];
        int ans;
        int pos=-1;
        rng(i,nl-1,nr){
            if(chmax(pos,A[i]-A[i+1])) ans=i+1;
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3216
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		List<List<String>> A = new ArrayList<>();
		List<List<String>> B = new ArrayList<>();
		
		for (int i = 0; i < in[0]; i++) {
			List<String> a = Arrays.asList(sc.nextLine().split(""));
			A.add(a);
		}
		
		for (int i = 0; i < in[1]; i++) {
			List<String> b = Arrays.asList(sc.nextLine().split(""));
			B.add(b);
		}
		
		boolean exist = false;
		for (int y = 0; y < A.size(); y++) {
			for (int x = 0; x < A.get(y).size(); x++) {
				if(y+B.size()-1 >= A.size() || x+B.size()-1 >= A.size()) continue;
				
				boolean match = true;
				for (int i = 0; i < B.size(); i++) {
					for (int j = 0; j < B.get(i).size(); j++) {
						if (!(A.get(y+i).get(x+j).equals(B.get(i).get(j)))) match = false;
					}
				}
				if(match) exist = true;
			}
		}	
		
		System.out.println(exist ? "Yes" : "No");		
	}
}


Measured memory_bytes: 28624
l = list(map(int, input().split()))

l = sorted(l)

a = l[0]
b = l[1]
c = l[2]

if (c-a)%2 == (c-b)%2:
	print(int(c-b+(b-a)/2))
else:
	print(int(c+1-b+(b-a+1)/2))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
	
	int day, month, year;
	fscanf(stdin, "%d/%d/%d", &year, &month, &day);
	if (year >= 2019 && month > 4)
		printf("TBD\n");
	else
		printf("Heisei\n");

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b, c) = sc.nextLine.split(" ").map(_.toInt)
    if (a + b >= c) println("Yes")
    else println("No")
  }

}


Measured memory_bytes: 25556
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
typedef long long LL;
#define int LL
int readint(){
	int x=0,f=1;char s=getchar();
	#define sc (s=getchar())
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		sc;
	}
	while(s>='0'&&s<='9'){
		x=(x<<3)+(x<<1)+(s^48);
		sc;
	}
	#undef sc
	return x*f;
}
signed main(){
	int x=readint();
	double be=100,nian=0;
	while(be<x){
		nian++,be=floor(1.0*be*1.01);
	}
	cout<<nian;
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> vp;
  map<pair<int, int>, int> m;
  rep(i, n){
    int x, y;
    cin >> x >> y;
    vp.push_back(make_pair(x, y));
  }
  rep(i, n){
    rep(j, n){
      if(i == j) continue;
      m[make_pair(vp.at(i).first - vp.at(j).first, vp.at(i).second - vp.at(j).second)]++;
    }
  }
  int mx = 0;
  for(auto p : m){
    mx = max(mx, p.second);
  }
  int ans = n - mx;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  vector<string> s(n);
  for(int i = 0;i<n;i++){
    cin >> s.at(i);
  }
  for(int i = 0;i<n;i++){
    if(s.at(i) == "AC"){
      a = a + 1;
    }else if (s.at(i) == "WA"){
      b = b + 1;
    }else if(s.at(i) == "TLE"){
      c = c +1;
    }else{
      d = d + 1;
    }
  }
    cout << "AC x " << a << endl;
cout << "WA x " << b << endl;
cout << "TLE x " << c << endl;
cout << "RE x " << d << endl;
  
}


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

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int fish, dog, cat, aaa, aa, abc, ac;
signed main() {
  int N, M;
  cin >> N >> M;
  int s[3] = {-1, -1, -1};
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    if (s[a] == -1 || s[a] == b) {
      s[a] = b;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = 0;
  if (N == 3) {
    if (s[0] == 0) {
      ans = -1;
    } else {
      if (s[0] == -1) s[0] = 1;
      if (s[1] == -1) s[1] = 0;
      if (s[2] == -1) s[2] = 0;
      ans = s[0] * 100 + s[1] * 10 + s[2];
    }
  } else if (N == 2) {
    if (s[2] >= 0) {
      ans = -1;
    } else if (s[0] == 0) {
      ans = -1;
    } else {
      if (s[0] == -1) s[0] = 1;
      if (s[1] == -1) s[1] = 0;
      ans = s[0] * 10 + s[1];
    }
  } else if (N == 1) {
    if (s[1] >= 0 || s[2] >= 0) {
      ans = -1;
    } else {
      if (s[0] == -1) s[0] = 0;
      ans = s[0];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e6;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> d;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            if (i != 1)
                d.pb(i);
            if (i * i != n)
                d.pb(n / i);
        }
    }
    set <int> lol;
    for (auto &k : d)
    {
        int x = n;
        while (x % k == 0)
            x /= k;
        if (x % k == 1)
            lol.emplace(k);
    }
    --n;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            if (i != 1)
                lol.emplace(i);
            if (i * i != n)
                lol.emplace(n / i);
        }
    }
    cout << lol.size();
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long x, y, ans = 1e9 + 10;
    cin >> x >> y;
    if (x <= y) {
        ans = min(y - x, ans);
    }
    if (x <= -y) {
        ans = min(-y - x + 1, ans);
    }
    if (-x <= y) {
        ans = min(y + x + 1, ans);
    }
    if (-x <= -y) {
        ans = min(-y + x + 2, ans);
    }
    cout << ans << endl;
}

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

class union_find {
public:
  vector<unsigned int> par, rank;
  union_find(unsigned int n) {
    for(unsigned int i = 0; i < n; i++){
      par.push_back(i);
      rank.push_back(0);
    }
  }
  unsigned int root(unsigned int x){
    return par[x] == x ? x : par[x] = root(par[x]);
  }
  bool same(unsigned int x, unsigned int y){
    return root(x) == root(y);
  }
  void unite(unsigned int x, unsigned int y){
    x = root(x);
    y = root(y);
    if (x == y){return;}
    if (rank[x] < rank[y]){
      par[x] = y;
    }
    else {
      par[y] = x;
      if (rank[x] < rank[y]){
        rank[x]++;
      }
    }
  }
};

int main(){
  INT(n); INT(m);
  int ans = 0;
  union_find uf(n + 1);
  REP(m){
    INT(x); INT(y); INT(z);
    uf.unite(x, y);
  }
  set<int> s;
  REP(i, 1, n + 1){
    s.insert(uf.root(i));
  }
  printf("%d\n", SZ(s));
  return 0;
}

Measured memory_bytes: 5748
import math
a, b, x = map(int, input().split())
s = x/a
half = (a*b)/2

if s<=half:
    y = (2*s)/b
    z = math.sqrt(b**2+y**2)
    alpha = b/z
    alpha = math.asin(alpha)
    alpha = math.degrees(alpha)

    print(alpha)

if s>half:
    z = math.sqrt(b**2+a**2)

    alpha = b/z
    alpha = math.asin(alpha)
    alpha = math.degrees(alpha)

    beta = a/z
    beta = math.asin(beta)
    beta = math.degrees(beta)

    l = 2*(s-half)/(math.sin(math.radians(90-alpha))*z)
    k = math.sqrt(z**2+l**2-2*l*z*math.cos(math.radians(90-alpha)))

    gamma = 2*(s-half)/(k*z)
    gamma = math.asin(gamma)
    gamma = math.degrees(gamma)

    print(90-(gamma+beta))


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int max_len = 1;
    int last = n - 1, num_zero = (s.back() == '0');
    for (int first = n - 2; 0 <= first; --first) {
        if (s[first] == '1'
            || (s[first] == '0' && s[first + 1] == '0')) {
            max_len = max(max_len, last - first + 1);
        }
        else {
            ++num_zero;
            while (k < num_zero) {
                while (s[last] == '1') --last;
                while (s[last] == '0') --last;
                --num_zero;
            }
            max_len = max(max_len, last - first + 1);
        }
    }

    cout << max_len << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int A[][] = new int[n][m];
    int b[] = new int[m];
    int c[] = new int[n];

    for(int x = 0; x < n; x++){
      for(int y = 0; y < m; y++){
        int v = sc.nextInt();
        A[x][y] = v;
      }
      c[x] = 0;
    }
    for(int x = 0; x < m; x++){
      int v = sc.nextInt();
      b[x] = v;
    }

    for(int x = 0; x < n; x++){
      for(int y = 0; y < m; y++){
        c[x] = c[x]+(A[x][y]*b[y]);
      }
      System.out.println(c[x]);
    }
  }
}



Measured memory_bytes: 40464
import java.util.Scanner;
public class Main{

	static int []a;
	static int ans;
	static int count;
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);		//入s力
		int n = sc.nextInt();				//入力したのをint型に変換
		sc.close();
		long a0 = 2;
		long a1 = 1;
		long a2 = 0;
		if(n != 0){
			if(n != 1){
				for(int i = 0;i <= n-2;i++){
					a2 = a0 + a1;
					a0 = a1;
					a1 = a2;

				}
				System.out.println(a2);
			}else{
				System.out.println(a1);
			}
		}else{
			System.out.println(a0);
		}

	}



}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main() {
    int midterm, final, makeup;
    cin >> midterm >> final >> makeup;
    while (midterm != -1 || final != -1 || makeup != -1) {
        if (midterm == -1 || final == -1)
            cout << "F\n";
        else if (midterm + final >= 80)
            cout << "A\n";
        else if (midterm + final >= 65)
            cout << "B\n";
        else if (midterm + final >= 50)
            cout << "C\n";
        else if (midterm + final >= 30 && makeup >= 50)
            cout << "C\n";
        else if (midterm + final >= 30)
            cout << "D\n";
        else 
            cout << "F\n";
        cin >> midterm >> final >> makeup;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    string c, x = "aeiou";
    cin >> c;
    if (x.find(c) < 5) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--) //ループ変数は1ずつデクリ
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--) //ループ変数は1ずつデクリ
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    REP(i, n) { cin >> A.at(i); }

    ll cnt = 0;
    while (true) {
        REP(i, n) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
            } else
                goto OUT;
        }
        cnt++;
    }
OUT:
    cout << cnt << endl;
}


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

typedef struct Node
{
    int key;
    struct Node *parent;
    struct Node *left;
    struct Node *right;
} Node;

class BinSearchTree
{
private:
    Node *root;

    Node *allocNode()
    {
        Node *node = (Node *)malloc(sizeof(Node));
        return node;
    };

    void setNode(Node *node, int key, Node *parent, Node *left, Node *right)
    {
        node->key = key;
        node->parent = parent;
        node->left = left;
        node->right = right;
    };

    Node *addNode(Node *node, int key)
    {
        if (node == NULL)
        {
            node = allocNode();
            setNode(node, key, NULL, NULL, NULL);
        }
        else if (key == node->key)
        {
            ;
        }
        else if (key < node->key)
        {
            node->left = addNode(node->left, key);
            node->left->parent = node;
        }
        else
        {
            node->right = addNode(node->right, key);
            node->right->parent = node;
        }

        return node;
    };

    void preorder(Node *node)
    {
        if (node == NULL)
            return;
        printf(" %d", node->key);
        preorder(node->left);
        preorder(node->right);
    };

    void inorder(Node *node)
    {
        if (node == NULL)
            return;
        inorder(node->left);
        printf(" %d", node->key);
        inorder(node->right);
    };

public:
    BinSearchTree()
    {
        root = NULL;
    };

    void insert(int key)
    {
        root = addNode(root, key);
    };

    void printPreorder()
    {
        preorder(root);
    }

    void printInorder()
    {
        inorder(root);
    };
};

int main()
{
    int n;
    BinSearchTree tree;
    cin >> n;
    string s;
    while (n--)
    {
        cin >> s;
        if (s == "insert")
        {
            int a;
            cin >> a;
            tree.insert(a);
        }
        else
        {
            tree.printInorder();
            cout << endl;
            tree.printPreorder();
            cout << endl;
        }
    }
}


Measured memory_bytes: 26800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , x = 1 , ans , A[MAXN] , cnt[3];
vector<ll> vec;
string s;

ll solve(vector<ll> vec){
    ll n = SZ(vec) , x = 1;
    if(n == 1)  return vec[0];
    while(x * 2 <= n - 1)   x *= 2;
    vector<ll> v;
    for(ll i = 0 ; i + x < n ; i++) v.push_back(vec[i] + vec[i + x]);
    return solve(v);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    cin >> n >> s;
    while((n - 1) % (x * 2) == 0)   x *= 2;
    for(ll i = 0 ; i < n ; i++){
        A[i] = s[i] - 48;
        A[i]--;
        cnt[A[i]]++;
        vec.push_back(A[i]);
    }
    ans = solve(vec);
    if(ans % 2 == 1)    return cout << 1 << endl , 0;
    if(cnt[1] >= 1) return cout << 0 << endl , 0;
    vec = {};
    for(ll i = 0 ; i < n ; i++) vec.push_back(A[i] / 2);
    ans = solve(vec);
    if(ans % 2 == 1)    return cout << 2 << endl , 0;
    cout << 0 << endl;

    return 0;
}
/*

*/


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

const int N = 60;
int n, m, q, A[N], a[N], b[N], c[N], d[N], ans;
int culc();

void f(int i, int pi){
    if (i == n+1) {
        ans = max(ans, culc());
        return;
    }
    FOR(j, pi, m+1){
        A[i] = j;
        f(i + 1, j);
    };
}

int culc(){
    int cnt = 0;
    rep(i, q) {
        if (A[b[i]] - A[a[i]] == c[i]) {
            cnt += d[i];
        }
    };
    return cnt;
}

int main()
{
    cin >> n >> m >> q;
    
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    f(1, 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: u64,
    }

    let ans = match N % 10 {
        //
        x if x == 3 => "bon",
        x if [0, 1, 6, 8].contains(&x) => "pon",
        _ => "hon",
    };

    println!("{}", ans);
}


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

using namespace std;

vector<vector<int> > G;
vector<int> dist;

int dfs(int u) {
    if (dist[u] != -1)
        return dist[u];
    
    int res = 0;
    for (auto v : G[u])
        res = max(res, dfs(v)+1);
    
    return dist[u] = res;
}

int main() {
    int n, m;   cin >> n >> m;
    int x, y;   
    G.resize(n);
    dist.resize(n, -1);

    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        G[x-1].push_back(y-1);
    }

    int ans = 0;
    for (int u = 0; u < n; u++) {
        if (dist[u] == -1) {
            ans = max(ans, dfs(u));
        }
        else
            ans = max(ans, dist[u]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11036
MOD = 1000000007

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

step =[1]*(N+1)
for i in range(1,N+1,1):
    step[i]= (step[i-1]*i)%MOD
def nCk(n,k):
    return (step[n]*pow(step[k],MOD-2,MOD)*pow(step[n-k],MOD-2,MOD))%MOD

max_sum=0
min_sum=0
for i in range(0,N,1):
    if i+1 < K:
        continue
    max_sum += (A[i]*nCk(i,K-1) + MOD)%MOD
    min_sum += (A[N-1-i]*nCk(i,K-1) + MOD)%MOD

print((max_sum-min_sum)%MOD)


    

Measured memory_bytes: 63556
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::string S;
    std::cin >> N >> S;

    for (auto&& s : S) {
        char c = s + N;
        c = (c > 'Z') ? c - ('Z'-'A'+1) : c;
        std::cout << c;
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
s = input()


#0101...の順にした場合に必要な操作数
a = s[0::2].count("1") + s[1::2].count("0")
#1010...の順にした場合に必要な操作数
b = s[0::2].count("0") + s[1::2].count("1")

print(min(a,b))

Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int N;
ll M;
vector<int> v(100101), fen;

int Sum(int idx)
{
	int ret = 0;
	while (idx)
	{
		ret += fen[idx];
		idx &= (idx - 1);
	}
	return ret;
}

void Add(int idx)
{
	while (idx <= N + 1)
	{
		fen[idx]++;
		idx += idx & -idx;
	}
}

ll f(int n)
{
	fen = vector<int>(100101, 0);
	vector<pair<int, int> > a(N + 1); //val, idx
	a[0] = { 0, 1 };
	for (int i = 1; i <= N; i++)
	{
		a[i].first = a[i - 1].first + (v[i] >= n ? 1 : -1);
		a[i].second = i + 1;
	}
	sort(a.rbegin(), a.rend()); //값의 내림차순, 인덱스의 내림차순

	ll ret = 0;
	for (int i = 0; i <= N; i++)
	{
		ret += Sum(N + 1) - Sum(a[i].second);
		Add(a[i].second);
	}

	return ret;
}

int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", &v[i]);
	M = (ll)N * (N + 1) / 2;
	
	int lo = 0, hi = 1'000'000'001;
	for (int i = 0; i < 32; i++)
	{
		int mid = (lo + hi) / 2;
		if (f(mid) >= (M + 1) / 2) lo = mid;
		else hi = mid;
	}
	printf("%d", lo);
	return 0;
}

Measured memory_bytes: 2180
def search(S, t, n):
    S.append(t)
    i = 0
    while S[i] != t:
        i += 1
    return i != n

n = int(input())
S = list(map(int, input().split(" ")))
q = int(input())
T = tuple(map(int, input().split(" ")))

counter = 0
for t in T:
    if search(S[:], t, n):
        counter += 1

print(counter)



Measured memory_bytes: 6552
#include<stdio.h>
int main(void){
   int d, m, n, i;
   while ( 1 ){
      scanf("%d %d", &m, &d);
      if ( m == 0) break;
      else if ( m == 1)  d = d;
      else if ( m == 2 ) d = d + 31;
      else if ( m == 3 ) d = d + 31 + 29;
      else if ( m == 4 ) d = d + 31 + 29 + 31;
      else if ( m == 5 ) d = d + 31 + 29 + 31 + 30;
      else if ( m == 6 ) d = d + 31 + 29 + 31 + 30 + 31;
      else if ( m == 7 ) d = d + 31 + 29 + 31 + 30 + 31 + 30;
      else if ( m == 8 ) d = d + 31 + 29 + 31 + 30 + 31 + 30 + 31;
      else if ( m == 9 ) d = d + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31;
      else if ( m == 10 )d = d + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30;
      else if ( m == 11 )d = d + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
      else if ( m == 12 )d = d + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;
      if ( d % 7 == 0 ) printf("Wednesday\n");
      else if ( d % 7 == 1 ) printf("Thursday\n");
      else if ( d % 7 == 2 ) printf("Friday\n");
      else if ( d % 7 == 3 ) printf("Saturday\n");
      else if ( d % 7 == 4 ) printf("Sunday\n");
      else if ( d % 7 == 5 ) printf("Monday\n");
      else if ( d % 7 == 6 ) printf("Tuesday\n");
   }
   return 0;
}

Measured memory_bytes: 1656
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 200005
#define mod 998244353
#include <bits/stdc++.h>
using namespace std;


int main() {

    ll n, a, b, d;
    cin >> n >> a >> b;
    if(a > b) swap(a, b);
    d = b - a;
    if( (d%2) == 0){
        cout << (d / 2) << endl;
    }
    else{
        ll x, y, res1, res2;
        x = a, y = b;
        res1 = x - 1;
        y -= x - 1;
        x = 1;
        res1 += ((y-x)/2) + ((y-x)%2);
        x = a, y = b;
        res2 = n - y;
        x += n - y;
        y = n;
        res2 += ((y-x)/2) + ((y-x)%2);
        cout << min(res1, res2) << endl;
    }
    return 0;
}


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

int n, w, h, sx, sy, gx, gy;
int t[102][102];

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

bool solve(int x, int y, int kind){
  if(x == gx && y == gy){
    return true;
  }
  t[y][x] = -1;

  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];

    if(0 <= nx && nx < w && 0 <= ny && ny < h && t[ny][nx] == kind){
      if(solve(nx, ny, kind)) return true;
    }
  }

  return false;
}

int main(){
  while(cin >> w >> h, w || h){
    memset(t, 0, sizeof(t));

    cin >> sx >> sy;
    cin >> gx >> gy;
    sx--;
    sy--;
    gx--;
    gy--;

    cin >> n;

    for(int i = 0; i < n; i++){
      int c, d, x, y;
      int ww, hh;
      cin >> c >> d >> x >> y;
      x--;
      y--;

      if(d == 0){
        ww = 4;
        hh = 2;
      }
      else{
        ww = 2;
        hh = 4;
      }

      for(int j = y; j < y + hh; j++){
        for(int k = x; k < x + ww; k++){
          t[j][k] = c;
        }
      }
    }

    /*
    for(int i = 0; i < h; i++){
      for(int j =0; j < w;j ++){
        cout<<t[i][j];
      }
      cout<<endl;
    }
    */

    bool ans = t[sy][sx] == 0 ? false : solve(sx, sy, t[sy][sx]);

    cout << (ans ? "OK" : "NG") << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll n,k;
    ll max = 0;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    for(ll i=0;i<=min(n,k);i++) {
        for(ll j=0;j<=i;j++) {
            vector<ll> have;
            for(ll l=0;l<j;l++) {
                have.push_back(v[l]);
            }
            for(ll l=0;l<i-j;l++) {
                have.push_back(v[n-1-l]);
            }
            sort(have.begin(),have.end());
            for(ll l=0;l<k-i;l++) {
                if(have.size()==0)break;
                if(have[0] < 0){
                    have.erase(have.begin());
                }else {
                    break;
                }
            }
            ll sum=0;
            for(ll vv:have) {
                sum+=vv;
            }
            if(max<sum)max=sum;
        }
    }
    cout << max<<endl;
}


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

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

    vector<pair<pair<string, int>, int>> data(n);
    string s;
    int x;
    for(int i = 0; i < n; i++){
        cin >> s >> x;
        data[i] = make_pair(make_pair(s, -x), i);
    }
    sort(data.begin(), data.end());

    for(int i = 0; i < n; i++){
        cout << data[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int factorial(int n){
	int sum=1;
	for(int i=n;i>0;i--){
		sum*=i;
	}
	return sum;
}
int getAbleOrder(int used[],int a){
	int ableOrder=1;
	for(int i=1;i<a;i++){
		if(used[i]==0){
			ableOrder++;
		}
	}
	return ableOrder;
}
int getOrder(int A[],int N){
	int order=1;
	int used[10]={};
	for(int i=0;i<N;i++){
		//cout << "b" << getAbleOrder(used,A[i])-1 << endl;
		//cout << "c" << factorial(N-i-1) << endl;
		order+=(getAbleOrder(used,A[i])-1)*factorial(N-i-1);
		used[A[i]]=1;
	}
	return order;
}
int main(){
	int N;
	cin >> N;
	int P[N],Q[N];
	for(int i=0;i<N;i++){
		cin >> P[i];
	}
	for(int i=0;i<N;i++){
		cin >> Q[i];
	}
	int Po=getOrder(P,N);
	int Qo=getOrder(Q,N);
	cout << abs(Po-Qo) << endl;
}
	


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

int main()
{
	stack<int>s1;
    stack<pair<int,int> >s2;
    char ch;
	int sum;
	for(int i =0;cin>>ch;i++)
    {
        if(ch =='\\')
            s1.push(i);
        else if(ch =='/'&&s1.size() >0)
        {
            int j = s1.top();
            s1.pop();
            sum += i-j;
            int a = i-j;
            while(s2.size()>0 && s2.top().first >j)
            {
                a+=s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j,a));
        }

    }
	vector<int> ans;
	while(s2.size() >0)
    {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout <<sum<<endl;
    cout<<ans.size();
    for(int i =0;i<ans.size();i++)
    {
        cout <<" ";
        cout <<ans[i];
    }
    cout <<endl;
	return 0;
}




Measured memory_bytes: 3204