akhauriyash/Code-Regression huggingface dataset:
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
int n , ans;
int32_t main()
{
	cin >> n;
	while(n)
		ans += n % 10 , n /= 10;
	if(ans == 1)
		return cout << 10 << endl , 0;
	return cout << ans << endl , 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
#define DEBUG(x) ;

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


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N; cin >> N;
	vector<ll> tmp;
	while (N > 0)
	{
		ll t = N%26;
		if (t == 0) tmp.push_back(25);
		else tmp.push_back(t-1);

		if (N <= 26) break;

		N /= 26;
		if (t == 0) --N;
	}

	reverse(ALL(tmp));
	for (auto &nv : tmp)
	{
		std::cout << char('a' + nv);
	}
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cctype>
#include<cstring>
#include<set>
#include<algorithm>
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
using std::multiset;
const int MN=2e5+5;
int n,x[MN],y[MN],id[MN];
inline void swap(int& a,int& b){a^=b;b^=a;a^=b;}
inline bool cmp(int a,int b){return x[a]<x[b];}
inline ll min(ll a,ll b){return a<b?a:b;}
multiset<int>s1,s2;
int main(){
	n=read<int>();reg int cnt,i;reg ll ans;
	for(i=1;i<=n;++i){
		x[i]=read<int>(),y[i]=read<int>();id[i]=i;
		if(x[i]>y[i])swap(x[i],y[i]);s1.insert(x[i]);s2.insert(y[i]);
	}
	std::sort(id+1,id+1+n,cmp);
	ans=1ll*(*s1.rbegin()-*s1.begin())*(*s2.rbegin()-*s2.begin());
	for(i=1;i<=n;++i){
		s1.erase(s1.find(x[id[i]]));s2.insert(x[id[i]]);
		s2.erase(s2.find(y[id[i]]));s1.insert(y[id[i]]);
		ans=min(ans,1ll*(*s1.rbegin()-*s1.begin())*(*s2.rbegin()-*s2.begin()));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 21376
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <regex>
#include <cmath>
#include <bitset>
#include <array>
#include <deque>
#include <list>
#include <stack>
#include <iterator>
#include <random>

using namespace std;

extern void* enabler;

using LL=long long int;
using ULL=unsigned long long int;
using Complex=complex<double>;

template<class T>
using asc_pqueue=std::priority_queue<T,vector<T>, std::greater<T>>;
template<class T>
using desc_pqueue=std::priority_queue<T,vector<T>, std::less<T>>;
template<class T>
using asc_set=std::set<T,vector<T>, std::greater<T>>;
template<class T>
using desc_set=std::set<T,vector<T>, std::less<T>>;

const LL INF = (1ll << 62);

template<class T>
T read(){
    T tmp;
    cin >> tmp;
    return tmp;
}



int main(){
    int N, K;
    N = read<int>();
    K = read<int>();
    vector<int> a(N + 1);
    for(int i=0;i<N;i++){
        a[read<int>()-1]++;
    }
    std::sort(a.begin(), a.end());

    //dump(a);


    int num = 0;
    for(int i=0;i<=N;i++){
        if(a[i] > 0)
            num++;
    }
    //cerr << "num:" << num << endl;
    int res = 0;
    for(int i=0;i<=N;i++){
        if(num <= K)
            break;
        if(a[i] == 0)
            continue;
        res += a[i];
        num--;
    }
    cout << res << endl;

    return 0;
}
















Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int a[n+1];
    for(int i=1; i<=n; i++){
        scanf("%d", &a[i]);
    }
    int p=0, m=0;
    for(int i=1; i<=n; i++){
        if(i%2){
            p += a[i];
        }else{
            m += a[i];
        }
    }
    int ans[n+1];
    for(int i=1; i<=n; i++){
        ans[i] = p-m;
        p -= a[i];
        int buf = p;
        p = m;
        m = buf;
        p += a[i];
    }
    for(int i=1; i<=n; i++){
        printf("%d ", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 2048
#!/usr/bin/env python3
import bisect


def dist(tree, tree_i, tree_j, parent, a, b):
    i = tree_i[b]
    if tree_i[a] == i:
        return tree_j[b] - tree_j[a]
    else:
        branch = tree[i]
        branch_root = branch[0]
        if branch_root < a:
            return tree_j[b] - bisect.bisect_left(branch, a) + 1
        else:
            p = parent[branch_root]
            if p < a:
                return tree_j[b] + 1
            else:
                return tree_j[b] + 1 + dist(tree, tree_i, tree_j, parent, a, p)


def solve(n, x, l, q, qry):

    g = [[] for _ in range(n)]
    parent = [-1] * n
    weight = [1] * n

    for v in range(1, n):
        p = bisect.bisect_left(x, x[v] - l)
        g[p].append(v)
        parent[v] = p

    for v in range(n - 1, -1, -1):
        for w in g[v]:
            weight[v] += weight[w]

    tree = [[0]]
    tree_i = [-1] * n
    tree_j = [0] * n
    tree_i[0] = 0
    for v in range(n):
        mw = 0
        c = -1
        for w in g[v]:
            if mw < weight[w]:
                mw = weight[w]
                c = w
        if 0 <= c:
            i = tree_i[v]
            tree[i].append(c)
            tree_i[c] = i
            tree_j[c] = len(tree[i]) - 1
            for w in g[v]:
                if w != c:
                    tree.append([w])
                    tree_i[w] = len(tree) - 1

    for tpl in qry:
        a, b = tpl
        if b < a:
            a, b = b, a
        print(dist(tree, tree_i, tree_j, parent, a, b))


def main():
    n = input()
    n = int(n)
    x = list(map(int, input().split()))
    l = input()
    l = int(l)
    q = input()
    q = int(q)
    qry = []
    for _ in range(q):
        a, b = input().split()
        a = int(a) - 1
        b = int(b) - 1
        qry.append((a, b))

    solve(n, x, l, q, qry)


if __name__ == '__main__':
    main()



Measured memory_bytes: 50592
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++) {
            int l = in.nextInt(), r = in.nextInt();
            sum += r - l + 1;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 26348
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int gcd(int a,int b){
  if(a<b) {
    int swap;
    swap=a;
    a=b;
    b=swap;
  }

  int r=b%a;
  while(r){
    b=a;
    a=r;
    r=b%a;
  }
  return a;
}
int main(){
  int n ; cin >>n;
  int a[110000];
  for(int i=0; i<n;i++){
    cin >>a[i];
  }
  int r=gcd(a[0],a[1]);
  int k;
  for(int i=2; i<n; i++){
    r=gcd(r,a[i]);
  }

  cout<<r<<endl;


  }


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	string s;
	cin >> s;

	if(s.size()==2){
		cout << (s[0]==s[1]?"1 2\n":"-1 -1\n");
		return 0;
	}
	char a=s[0],b=s[1];
	for(int i=2;i<s.size();i++){
		if(a==s[i]){
			cout << i-1 << " " << i+1 << "\n";
			return 0;
		}
		if(b==s[i]){
			cout << i << " " << i+1 << "\n";
			return 0;
		}
		a=b; b=s[i];
	}
	cout << "-1 -1\n";

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005],dp[100005];
int main(){
	cin>>n; rep(i,n)cin>>a[i];
	for(int i=n-2;i>=0;i--){
		if(a[i] >= a[i+1]) dp[i] = dp[i+1]+1;
		else dp[i] = 0;
	}
	int ans = 0; rep(i,100005) ans = max(ans,dp[i]);
	cout << ans << endl;
}

Measured memory_bytes: 1024
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int ans = 2e9;
  for (int t = 1; t < n; t++) {
    int s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
      if (i < t) s1 += a[i];
      else s2 += a[i];
    }
    ans = min(ans, abs(s1 - s2));
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint n;
    cin >> n;

    lint ans=0;

    REP(i, n){
        ans += n - 1;
    }
    ans /= 2;

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int n=s.length()-1;
  for(int bit=0; bit < (1<<n); bit++){
    int sum=s[0]-'0';
    rep(i, n){
      if(bit &(1<<i)){
        sum+=s[i+1]-'0';
      } else {
        sum-=s[i+1]-'0';
      }
    }
    if(sum==7){
      cout << s[0] ;
      rep(i, n){
        if(bit &(1<<i)){
          cout << "+" << s[i+1];
        } else {
          cout << "-" << s[i+1];
        }
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))

if N == K:
	print(0)
	exit()

x = N
if N > K:
	x = N % K

min_x = x
h = {}
h[x] = 1
while True:
	x = abs(x-K)
	min_x = min(min_x, x)
	if x in h:
		break
	h[x] = 1

print(min_x)


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

#define N 21
#define INF 1000000007
#define min(a,b) (a>b?b:a)

int mat[N][N];

int main() {
	int n, m, a, b, c, d, x1, x2, y1, y2;
	char du;
	cin >> n >> m;
	for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) mat[i][j] = INF;
	for(int i=0; i<m; ++i) {
		cin >> a >> du >> b  >> du >> c >> du >> d; --a; --b;
		mat[a][b] = c;
		mat[b][a] = d;
	}
	cin >> x1 >> du >> x2  >> du >> y1  >> du >> y2; --x1; --x2;
	for(int k=0; k<n; ++k) {
		for(int i=0; i<n; ++i) {
			for(int j=0; j<n; ++j) {
				mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j]);
			}
		}
	}
	cout << y1 - y2 - mat[x1][x2] - mat[x2][x1] << endl;
	return 0;
}

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

int N2(){
  int n;cin>>n;
  vector<int>d;
  int b;
  for(int i=0; i<n; i++){
    cin>>b;
    d.push_back(b);
  }
  int s = d.size();
  int ans = 0;
  for(int i=0; i<s-1; i++)for(int j=i+1; j<s; j++){
    ans += d[i]*d[j];
  }
  return ans;
}

int N(){
  int n;cin>>n;
  vector<int> d;
  int b;
  for(int i=0; i<n; i++){
    cin>>b;
    d.push_back(b);
  }
  int s = d.size();
  int sum = d[0];
  int ans = 0;
  for(int i=1; i<s; i++){
    ans += d[i] * sum;
    sum += d[i];
  }
  return ans;
}

int main(){
  cout<<N2()<<endl;
}

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

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

    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "Yes" << endl;
    } else if (s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    ll x, a, b;
    cin >> x >> a>> b;

    if (abs(x-b) > abs(x-a))
        cout << 'A' << endl;
    else
        cout << 'B' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;

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

  map<int, int> m;
  vector<int> SUM(N + 1);
  SUM[0] = 0;
  for (int i = 0; i < N; i++) {
    SUM[i + 1] = (SUM[i] + A[i]) % M;
  }

  long long ans = 0;
  for(int i = 0; i < SUM.size(); i++) {
    ans += m[SUM[i]];
    m[SUM[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main(){
  string str1;
  int n =0;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> str1;
    stringstream ss;
    
    for(int i = 0; i< n; i++){
      char num = str1[0];
      int count = 1;
      for(int j = 1; j< str1.length(); j++){
	if(num == str1[j]) count++;
	else{
	  ss << count << num;
	  count = 1;
	  num = str1[j];
	}
      }

      ss <<count<< num;

      str1 = ss.str();
      ss.str("");
    }

    cout << str1 << endl;
  }

  return 0;
}
	

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

typedef long long ll;
const ll N = 4e5 + 77;
const ll inf = 1e18;

int main()
{
  long double a, b, ans = 1;
  scanf("%Lf%Lf", &a, &b);
  printf("%.0Lf\n", floor(a * b));
  return 0;
}

Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int main(void) {
    int N, H, W;
    int A, B;
    int countSize = 0;
    cin >> N >> H >> W;
    for(int i = 0; N > i; i++){
        cin >> A >> B;
        if(A >= H){
			if(B >= W){
              countSize = countSize + 1;
            }
        }
    }
    cout << countSize << endl;
}

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

using namespace std;

long long N, M, an;

bool check(long long v)
{
    return (M % v == 0 && M/v >= N);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    for (long long i = 1; i*i <= M; ++i) {
        if (check(i)) an = max(an, i);
        if (check(M/i)) an = max(an, M/i);
    }
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll k;
  string s;
  cin >> k >> s;
  ll n = s.size();
  if(n <= k) cout << s << endl;
  else cout << s.substr(0, k) + "..." << endl;
  return 0;
}

Measured memory_bytes: 3600
// AOJ ALDS1_13_C 15 Puzzle
// 2018.5.8 bal4u

#include <stdio.h>

typedef unsigned long long ull;

#define QMAX 100000
typedef struct { ull s; char x, v; char t; } QUE;  // t:ステップ数
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r;
	int min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

void deq()
{
  que[0] = que[--qsize];
  min_heapify(0);
}

void enq(ull s, int x, int v, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].x = x, que[i].v = v, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

#define HASHSIZ 200003
typedef struct { ull s; char v; } HASH;
HASH hash [HASHSIZ+3], *hashend  = hash +HASHSIZ;

int lookup(ull s)
{
	HASH *hp = hash + (int)(s % HASHSIZ);
	while (hp->s) {
		if (hp->s == s) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return -1;
}

void insert(ull s, char v)
{
	HASH *hp = hash + (int)(s % HASHSIZ);
	while (hp->s) {
		if (hp->s == s) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->v = v;
}

#define GOAL 0x123456789ABCDEF0LL
#define ABS(a) ((a)>=0?(a):-(a))

int hi[16] = {2,3,3,2,3,4,4,3,3,4,4,3,2,3,3,2};
int to[16][4] = {
{1,4},{0,2,5},{1,3,6},{2,7},
{0,5,8},{1,4,6,9},{2,5,7,10},{3,6,11},
{4,9,12},{5,8,10,13},{6,9,11,14},{7,10,15},
{8,13},{9,12,14},{10,13,15},{11,14}};

void toArray(char *p16, ull s)
{
	int i;
	
	for (i = 15; i >= 0; i--) {
		p16[i] = s & 0xf, s >>= 4;
	}
}

ull swap(char *p16, int zero, int nx)
{
	int i;
	ull res;
	
	res = 0;
	for (i = 0; i < 16; i++) {
		res <<= 4;
		if      (i == zero) res |= p16[nx];
		else if (i == nx)   res |= p16[zero];
		else                res |= p16[i];
	}
	return res;
}

int eval(ull s)
{
	int i, r1, c1, r2, c2;
	int e, t;

	e = 0;
	for (i = 15; i >= 0; i--) {
		t = s & 0xf, s >>= 4;
		if (t) {
			t--;
			r1 = i >> 2, c1 = i & 3;
			r2 = t >> 2, c2 = t & 3;
			e += ABS(r1-r2) + ABS(c1-c2);
		}
	}
	return e;

}

int main()
{
	int i, x, nx, v, nv, t;
	ull s, ns;
	char p16[16];
	double magic;

	s = 0; for (i = 0; i < 16; i++) {
		scanf("%d", &t);
		p16[i] = t, s <<= 4, s |= t;
		if (t == 0) x = i;
	}
	qsize = 0;
	t = eval(s);
	if      (t <= 22) magic = 1.1;
	else if (t <= 25) magic = 1.15;
	else              magic = 1.25;
	enq(s, x, 0, (int)(t*magic));

	insert(s, 0);
	while (qsize) {
		s = que[0].s, x = que[0].x, v = que[0].v, deq();
		if (s == GOAL) break;
		if (lookup(s) < v) continue;

		toArray(p16, s);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			ns = swap(p16, x, nx), nv = v+1;
			t = lookup(ns);
			if (t < 1 || nv < t) {
				enq(ns, nx, nv, (int)(eval(ns)*magic)+v);
				insert(ns,  nv);
			}
		}
	}
	printf("%d\n", v);
	return 0;
}



Measured memory_bytes: 6244
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from itertools import accumulate
def resolve():
    S=input()
    K,=pin()
    cnt=0
    for s in S:
        if s=="1":
            cnt+=1
            if cnt>=K:
                print(1)
                return
        else:print(s);return
#%%submit!
resolve()

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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    if (a + b < c && 4 * a * b < (c - a - b) * (c - a - b))
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> A;
  tools::read(A, N);

  std::sort(A.begin(), A.end(), std::greater<i64>());
  std::vector<i64> cumsum({0});
  std::partial_sum(A.begin(), A.end(), std::back_inserter(cumsum));
  const auto T_to_M = [&N, &A](const i64& T) {
    i64 result = 0;
    i64 y = N;
    for (i64 x = 0; x < N; ++x) {
      while (y - 1 >= 0 && A[x] + A[y - 1] < T) {
        --y;
      }
      result += y;
    }
    return result;
  };
  const auto T_to_ans = [&N, &A, &cumsum](const i64& T) {
    i64 result = 0;
    i64 y = N;
    for (i64 x = 0; x < N; ++x) {
      while (y - 1 >= 0 && A[x] + A[y - 1] < T) {
        --y;
      }
      result += A[x] * y + cumsum[y] - cumsum[0];
    }
    return result;
  };

  i64 ok = 0;
  i64 ng = A[0] * 2 + 1;
  while (ng - ok > 1) {
    const i64 center = (ok + ng) / 2;
    if (T_to_M(center) >= M) {
      ok = center;
    } else {
      ng = center;
    }
  }

  const i64 ok_M = T_to_M(ok);
  const i64 ng_M = T_to_M(ng);
  const i64 ok_ans = T_to_ans(ok);
  const i64 ng_ans = T_to_ans(ng);
  std::cout << ng_ans + (ok_ans - ng_ans) / (ok_M - ng_M) * (M - ng_M) << std::endl;
  return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	auto ts = vector<int>(3);
	for (int i = 0; i < 3; i++)cin >> ts[i];
	sort(ts.begin(), ts.end());
	cout << ts[0] + ts[1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

ll MOD = 1000000007;

int main() {
	int N, M;
	bool banned[100001] = {};
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		banned[a] = true;
	}
	int dp[100001] = {};
	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (banned[i])continue;
		if (i > 1) {
			dp[i] += dp[i - 2];
		}
		dp[i] += dp[i - 1];
		dp[i] %= MOD;
	}
	cout << dp[N] % MOD << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k;
    cin>>n>>k;
    Vec a(n);
    rep(i,n)cin>>a[i];
    Vec s(n+1);
    rep(i,n){
        s[i+1] = s[i]+a[i];
    }
    Vec v;
    rep(j,n+1)rep(i,j){
        v.pb(s[j]-s[i]);
    }
    sort(rALL(v));
    ll ans = 0;

    //ビットiをk個立てられるか。
    Vec x = v;
    per(bit,60){
        ll cnt=0;
        Vec c;
        rep(i,x.size()){
            if(x[i] & (1LL<<bit)){
                cnt++;
                c.pb(x[i]);
            }
        }
        if(cnt>=k){
            x = c;
            ans += (1LL<<bit);
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 9964
#include <stdio.h>

int main()
{
	long long n, x = 2, i;

	scanf("%lld", &n);
	//最短的一段最短（即为1）
	for (i = 0; i < n; i++)
		//短	中	长
		//1		x	x+1   
		x = 1 + x + (x + 1);
	printf("%lld\n", x);

	return 0;
}

Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 20.11.2019 07:47:29       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k;
  cin >> k;
  cout << 50 << '\n';
  vector<long long> a(50, 49);
  for (int i = 0; i < k % 50; i++) {
    a[i] += 50;
    for (int j = 0; j < 50; j++) if (i != j) a[j] -= 1;
  }
  for (int i = 0; i < 50; i++) a[i] += k / 50;
  for (int i = 0; i < 50; i++) cout << a[i] << " ";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define ll  long long
        #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define rep(i,a,b)  for(ll i=a;i<b;i++)
        #define pb push_back
        #define Max(x,y,z) max(x,max(y,z))
        #define f first
        #define s second
        #define lbd lower_bound
        #define sz(x)       (ll)x.size()
        #define pi 3.1415926536
        #define mod 1000000007
        #define MOD 998244353
        using namespace std;
        const int N=100000;
        void solve()
        {
            ll n,m,k,res=0,l=0,r=0,z,sum1=0,cnt1=0,h,res1,a,b,c,d,x,y;
            ll W;
            cin>>n>>W;
            vector<pair<ll,ll>> v(n);
            rep(i,0,n)
                cin>>v[i].f>>v[i].s;
            ll cnt[n+1][W+1];
            rep(i,0,n+1)
            {
                rep(w,0,W+1)
                {
                    if(i==0 || w==0) cnt[i][w]=0;
                    else if(v[i-1].f<=w)
                        cnt[i][w]=max((cnt[i-1][w-v[i-1].f]+v[i-1].s),cnt[i-1][w]);
                    else
                        cnt[i][w]=cnt[i-1][w];
                    //cout<<cnt[i][w]<<" ";
                }
                //cout<<"\n";
            }
            cout<<cnt[n][W];     
            
        
     
    }
        int main()
        {   
            /*#ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif*/
     
            speed_up
            ll t;
            //cin>>t;
            t=1;
            while(t--)
                solve();
        }

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> m;
	int w[n + 1], v[n + 1];
	w[0] = v[0] = 0;
	for (i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	int dp[n + 1][m + 1];
	memset(dp, 0, sizeof(dp));
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= m; j++) {
			if (j - w[i] >= 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
			if (j)
				dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]});
		}
	}
	cout << dp[n][m];
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 79232
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;


int32_t main() {
    input;
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0) {
        cout << 1;
    }
    else if(b == 0) { 
        cout << 2;
    }
    else if(c == 0) { 
        cout << 3;
    }
    else if(d == 0) { 
        cout << 4;
    }
    else if(e == 0) { 
        cout << 5;
    }


}

Measured memory_bytes: 3636
#include <iostream>
 
 
int main() {
    long long N, K, answer = 1;
    std::cin >> N >> K;
 
    for (int i = 0; i < N - 1; i++)
    {
        answer *= (K - 1);
    }
    answer *= K;
 
    std::cout << answer << std::endl;
 
    return 0;
}

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

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

int main(){
    int n,m;
    cin>>n>>m;
    if(n+m>9){
        cout<<"error"<<endl;
    }
    else{
        cout<<n+m<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n;
int cnt=0;
for(int i=0;i<5;i++){
n=Integer.parseInt(br.readLine());
cnt+=(n>=40)?n:40;
}
out.println(cnt/5);
out.flush();
}
}

Measured memory_bytes: 16888
/*input
20
0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0
1 1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1
1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0
0 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0
0 1 1 0 1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0 0 0 1
1 1 1 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 1 1
0 0 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0
0 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0 1 0 1 1
0 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 0 1 1 1
0 0 0 0 1 1 0 0 0 1 0 1 1 0 1 1 0 0 1 1
0 0 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1
0 1 1 0 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 1
1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 1 1 1 0 0
0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 0
1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 0
1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 1
0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0
1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 0
0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1

*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#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 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 ;
using namespace std;
#define N  22
lld dp[N][1<<N];
lld a[24][24];
lld n;
void init()
{
	rep(i,0,N)
	{
		rep(j,0,N)
		{
			a[i][j]=-1;
		}
		rep(j,0,1<<N)
		{
			dp[i][j]=-1;
		}
	}
}
lld func(lld prs,lld bitm)
{
	if(prs==n && bitm <= (1<<21) )
	{
		return 1;
	}
	if(prs==n)
	{
		return 0;
	}
	if(dp[prs][bitm]!=-1)
	{
		return dp[prs][bitm];
	}
	lld ans=0;
	rep(i,0,n)
	{
		if( ((1<<i)&bitm) == 0 && a[prs][i]==1)
		{
			ans=(ans+func(prs+1,bitm|(1<<i)))%hell;
		}
	}
	//cout << ans <<  endl;
 	dp[prs][bitm]=ans;
	return ans;
}
inline void solve()
{
	init();
	cin >> n;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			cin >> a[i][j];
		}
	}
	cout << func(0,0) << 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: 721152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// 桁数を返す
int cnt_digits(ll X){
    int cnt=0;
    while(X>0){
        X/=10;
        cnt++;
    }
    return cnt;
}

int cn(int x,int y){
    string t=to_string(x);
    return t[y-1]-'0';
}

int main(){
    int n,m;
    cin>>n>>m;
    int s[m],c[m];
    rep(i,m) cin>>s[i]>>c[i];
    //cout<<cnt_digits(0)<<endl;
    for(int i=0;i<=999;i++){
        if(i==0 && n!=1) continue;
        if(i!=0 && cnt_digits(i)!=n) continue;
        bool ok=true;
        rep(j,m){
            if(cn(i,s[j])!=c[j]) ok=false;
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	string a; cin >> a;
	string b; cin >> b;
	string con_ab = a + b;
	int connum = stoi(con_ab);
	int square = sqrt(connum);
	if (square * square == connum) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
	int N; string S; cin >> N >> S;
	
	rep(i, S.size()) {
		int x = (S[i] - 'A' + N) % 26;	
		cout << char('A' + x);
	}
	cout << endl;
	return 0;
}


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

S = list(map(int, input().split()))

num_t = int(input())

T = list(map(int, input().split()))

# Tの要素について、Sに含まれるものを探す

def binary_search(array, x):
    imin = 0
    imax = len(array) - 1
    
    while imin <= imax:
        imid = imin + int((imax - imin) / 2)
        if x > array[imid]:
            imin = imid + 1
        elif x < array[imid]:
            imax = imid - 1
        else:
            return True
    return False

counter = 0
for t in T:
    if binary_search(S, t):
        counter += 1

print(counter)


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

int main(){
  int n,t,a,log;
  double minnum = 1000.1;
  cin>>n>>t>>a;
  vector<int> num(n);
  double nums[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
    nums[i] = abs(a-(t - num[i] * 0.006));
    if(minnum>nums[i]){
      minnum = nums[i];
      log = i+1;
    }
  }
  cout<<log<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;++i)
#define repe(i,k,n) for(int i=k;i<=n;++i)

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> lig(n+1);
    repe(i,1,n)
    {
        cin >> lig[i];
    }
    
    
    int lighting = 1;
    
    repe(i,1,n)
    {
        lighting = lig[lighting];

        if (lighting == 2) {
            cout << i;
            return 0;
        }


    }
    cout << -1;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;



int n;
ll k, a[100010];

int main(void) {
	cin >> n >> k;
	rep(i, n) cin >> a[i];

	ll g = a[0];
	reps(i, 1, n) g = __gcd(g, a[i]);
	ll ma = 1;
	rep(i, n) chmax(ma, a[i]);
	if(k <= ma && k % g == 0) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a[55], c[2], cmb[55][55], ans;

int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		c[a[i]%2]++;
	}
	for(int i=0;i<=n;i++) {
		cmb[i][0] = 1;
		for(int j=1;j<=i;j++) {
			cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j];
		}
	}
	for(int i=m;i<=c[1];i+=2) {
		ans += cmb[c[1]][i];
	}
	for(int i=0;i<c[0];i++) ans *= 2;
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;
 
 
int main()
{
    string s;
    cin >> s;
 
    int m = 0;
    rep(i, s.size()){
        int j = 0;
        int min = 0;
        while(1){
            if(s[i+j]=='A' || s[i+j] == 'C' || s[i+j] == 'G' || s[i+j] == 'T'){
                j++;
                min++;
            }else{
                break;
            }
        }
        m = max(m, min);
    }
    cout << m;
 
}

Measured memory_bytes: 256
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("Yes\n")
#define no printf("No")
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    int d=7,n,c=1,p=11;
    cin>>n;
    if(n%2==0||n%5==0)
        cout<<-1<<endl;
    else
    {
        while(1)
        {
            if(d%n==0)
            {
                cout<<c<<endl;
                break;
            }
            if(c>n)
            {
                cout<<-1<<endl;
                break;
            }
                d=(d%n)*10+7;;
                c++;
        }
    }
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, K;
    cin >> A >> B >> K;
    rep(i, 0, K)
    {
        int& a = (i % 2 == 0) ? A : B;
        int& b = (i % 2 == 0) ? B : A;

        if (a % 2 == 1)
        {
            --a;
        }

        b += a / 2;
        a /= 2;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
int a[30];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0;
	for(int i=2;i<n;i++)if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1]))ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print('101')
    else:
        print(n)
elif d == 1:
    if n == 100:
        print('10100')
    else:
        print(n*100)
else:
    if n == 100:
        print('1010000')
    else:
        print(n*10000)


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

namespace ABC115B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = new List<int>();
            for(var i = 0; i < n; i++)
            {
                p.Add(int.Parse(Console.ReadLine()));
            }
            Console.WriteLine(p.Sum() - p.Max() / 2);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main(){
	int N,K;
	int A[100001];
	int Amax=0;
	ll GCD;
	scan(N);scan(K);
	rep(i,N){
		scan(A[i]);
		if(i!=0) GCD=gcd(GCD,A[i]);
		else GCD=A[i];
		Amax=max(Amax,A[i]);
	}
	if(K<=Amax&&K%GCD==0) prin("POSSIBLE");
	else prin("IMPOSSIBLE");
	return 0;
}


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

using namespace std;

const int N = 8008 , M = 16010;
bool dx[N][M] , dy[N][M] , d;
int x , y , cnt;
string s;
vector<int> xx , yy;

int main()
{
	cin >> s >> x >> y;
	for(int i = 0 ; i < s.size() ; i++)
	{
		if(s[i] == 'T' || i == s.size() - 1)
		{
			if(s[i] == 'F')
				cnt++;
			if(!d)
				xx.push_back(cnt);
			else
				yy.push_back(cnt);
			d ^= 1;
			cnt = 0;
		}
		else
			cnt++;
	}
	if(!xx.size())
		xx.push_back(0);
	if(!yy.size())
		yy.push_back(0);
	dx[0][xx[0] + 8000] = 1;
	dy[0][yy[0] + 8000] = 1;
	dy[0][8000 - yy[0]] = 1;
	for(int i = 1 ; i < xx.size() ; i++)
		for(int j = 0 ; j < 16008 ; j++)
		{
			if(j - xx[i] >= 0)
			{
				if(dx[i - 1][j - xx[i]])
					dx[i][j] = 1;
			}
			if(j + xx[i] < 16008)
			{
				if(dx[i - 1][j + xx[i]])
					dx[i][j] = 1;
			}
		}
	for(int i = 1 ; i < yy.size() ; i++)
		for(int j = 0 ; j < 16008 ; j++)
		{
			if(j - yy[i] >= 0)
			{
				if(dy[i - 1][j - yy[i]])
					dy[i][j] = 1;
			}
			if(j + yy[i] < 16008)
			{
				if(dy[i - 1][j + yy[i]])
					dy[i][j] = 1;
			}
		}
	if(dx[xx.size() - 1][x + 8000] && dy[yy.size() - 1][y + 8000])
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 125696