akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
#define N 206
int head[N],cnt=1,dis[N],n,m,v[N][N],as[N][N],as2[N][N],cur[N];
multiset<int> sb[N],vl[N][N];
struct edge{int t,next,v;}ed[N*N*3];
void adde(int f,int t,int v){ed[++cnt]=(edge){t,head[f],v};head[f]=cnt;ed[++cnt]=(edge){f,head[t],0};head[t]=cnt;}
bool bfs(int s,int t)
{
	queue<int> v;
	memset(dis,-1,sizeof(dis));
	memcpy(cur,head,sizeof(cur));
	v.push(s);dis[s]=1;
	while(!v.empty())
	{
		int r=v.front();v.pop();
		for(int i=head[r];i;i=ed[i].next)
		if(dis[ed[i].t]==-1&&ed[i].v)
		{dis[ed[i].t]=dis[r]+1,v.push(ed[i].t);if(ed[i].t==t)return 1;}
	}
	return 0;
}
int dfs(int u,int t,int f)
{
	if(!f||(u==t))return f;
	int as=0,tp;
	for(int &i=cur[u];i;i=ed[i].next)
	if(ed[i].v&&dis[ed[i].t]==dis[u]+1&&(tp=dfs(ed[i].t,t,min(ed[i].v,f))))
	{
		ed[i].v-=tp,ed[i^1].v+=tp,as+=tp,f-=tp;
		if(!f)return as;
	}
	return as;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		scanf("%d",&v[i][j]);
		int v1=(v[i][j]-1)/m+1;
		sb[i].insert(v1),vl[i][v1].insert(v[i][j]);
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n*2+2;j++)head[j]=0;
		cnt=1;
		for(int j=1;j<=n;j++)
		{
			adde(n*2+1,j,1);adde(j+n,n*2+2,1);
			for(int k=1;k<=n;k++)
			{
				multiset<int>::iterator it=sb[j].lower_bound(k);
				if(it==sb[j].end()||*it!=k)continue;
				adde(j,k+n,1);
			}
		}
		while(bfs(n*2+1,n*2+2))dfs(n*2+1,n*2+2,1e8);
		for(int j=1;j<=n;j++)
		for(int k=head[j];k;k=ed[k].next)
		if(!ed[k].v)
		{
			int l=j,r=ed[k].t-n;
			as[l][i]=as2[i][l]=*vl[l][r].begin();
			vl[l][r].erase(vl[l][r].begin());
			sb[l].erase(sb[l].find(r));
		}
	}
	for(int i=1;i<=n;i++,printf("\n"))
	for(int j=1;j<=m;j++)
	printf("%d ",as[i][j]);
	for(int i=1;i<=m;i++)sort(as2[i]+1,as2[i]+n+1);
	for(int i=1;i<=n;i++,printf("\n"))
	for(int j=1;j<=m;j++)
	printf("%d ",as2[j][i]);
}//

Measured memory_bytes: 3712
s = list(input())
t = list(input())

mapping = {}
for i in range(len(s)):
    if s[i] in mapping:
        if mapping[s[i]] == t[i]:
            continue
        else:
            print('No')
            break
    elif t[i] in mapping.values():
        print('No')
        break
    else:
        mapping[s[i]] = t[i]
else:
    print('Yes')

Measured memory_bytes: 6704
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> z_algo(const V<int> &s){
    int n=s.size();
    V<int> prefix(n);
    for(int i=1,j=0;i<n;i++){
        if(i+prefix[i-j]<j+prefix[j]){
            //すでに計算済みの場所である
            prefix[i]=prefix[i-j];
        }else{
            // わからないところを愚直に調べる
            int k=max(0,j+prefix[j]-i);
            while(i+k<n&&s[k]==s[i+k])k++;
            prefix[i]=k;
            j=i;
        }
    }
    prefix[0]=n;
    return prefix;
}
int main(){
    int n;
	cin>>n;
	V<int> a(n),b(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	V<int> s(3*n);
	for(int i=0;i<n;i++){
		s[i]=(b[i]^b[(i+1)%n]);
	}
	for(int i=0;i<n;i++){
		s[i+n]=(a[i]^a[(i+1)%n]);
		s[i+2*n]=(a[i]^a[(i+1)%n]);
	}
	V<int> res=z_algo(s);
	int cnt=0;
	for(int i=n;i<2*n;i++){
		if(res[i]>=n){
			cout<<i-n<<" "<<(a[i-n]^b[0])<<endl;
		}
	}
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

//idea check how many times each number 1 to n appears as a divisor in number<=N
//and calculate sum
//example 1 divides every number 1 to n
//add 1+2+...+n to answer
//2 add 2+4+6+...+n to answer which is the same thing as 2*sum(1 to n/2)
//3 add 3+6+9+12+n to answer which is the same thing as 3*sum(1 to n/2)
//...

ll calcsum(ll n) {
    //basic formula
    ll r = (n*(n+1))/2;
    return r;
}

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll res = 0;
    for(ll a = 1; a<=N; a++) {
        res+=a*calcsum(N/a);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&a[i]);
	a[1]=a[n+1]=1000000000;
	int ans=0;
	for(int i=1;i<=n;i++)ans+=min(a[i],a[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
  int parent,left,right;
};
struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent==NIL)printf("root, ");
  else if(T[u].left==NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
  /* while(c!=NIL){
    printf("%d",c);
    c=T[c].right;
    }*/

int getdepth(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL) getdepth(T[u].right,p);
  if(T[u].left!=NIL) getdepth(T[u].left,p+1);
}

int main(){
  int i,v,l,r,root,d,c,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	T[v].left=c;
      }
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }
  
  getdepth(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}

 



Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
const int MOD = 1e9 + 7;
const int LEN = 1000; 
const int INF = 1e9 + 5;
// repeating
int n,m,L;
int a[305][305], b[305][305];
int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n>>m>>L;
   int A,B,C;
   int q,s,t;

   for(int i = 1;i <= n;i++) {
      for(int j = 1;j <= n;j++) {
         a[i][j] = INF;
         //v[i][j] = INF;
      }
   }

   for(int i =0;i<m;i++) {
   		cin>>A>>B>>C;
   		a[A][B] = C;
   		a[B][A] = C;
   }
   for(int k =1;k<=n;k++) {
      for(int i = 1; i <= n;i++) {
         for(int j = 1;j <= n;j++)
            a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
   }

   for(int i =1;i <= n;i++) {
      for(int j = 1;j <= n;j++) {
         b[i][j] = (a[i][j] <= L) ? 1 : INF;
        // cout<<a[i][j]<<" ";
      }
      //cout<<endl;
   }

   for(int k =1;k<=n;k++) {
      for(int i = 1; i <= n;i++) {
         for(int j = 1;j <= n;j++)
            b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
      }
   }

   /*for(int i =1;i<=n;i++) {
      for(int j = 1;j <=n;j++)
         cout<<b[i][j]<<" ";
      cout<<endl;
   }
*/
   cin>>q;
   while(q--) {
   //	int ans = INT_MAX;
   	cin>>s>>t;
      if(b[s][t] == INF) cout<<-1<<"\n";
      else
         cout<<b[s][t]-1<<"\n";

   }





   return 0;   
}

Measured memory_bytes: 1280
#include  <bits/stdc++.h>
using namespace std; 
int main()
{
	char a;
	cin>>a;
	if(a>=97&&a<=122)
	{
		cout<<'a';
		return 0;
	}
	else if(a>=65&&a<=90)
	{
		cout<<'A';
		return 0;
	}
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 300009
ll m,a,b,c,d,n,arr[sz],i,k,j,x,y,l;
ll brr[sz],vis[sz];
int main()
{
scanf("%lld %lld",&n,&m);
for(i=1;i<=n;i++)
    scanf("%lld",&arr[i]);
i=1;
while(vis[i]==0)
{
    vis[i]=1;
    i=arr[i];
    m--;
    if(m==0)
    {
        printf("%lld\n",i);
        return 0;
    }
}
k=0;
while(vis[i]<=1)
{
    k++;
    vis[i]=2;
    i=arr[i];
}
m=m%k;
while(m>0)
{
    i=arr[i];
    m--;
    if(m==0)
    {
        printf("%lld\n",i);
        return 0;
    }
}
if(m==0)
{
    printf("%lld\n",i);
}
return 0;
}


Measured memory_bytes: 6960
/////////////==========================
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================


int main(){
    long long n , k;
    cin >> n >> k;
    long long ans; 
    
    if(n > k){
        ans = min( n%k , k - (n%k));
    }
    else if( n== k || n==0){
        ans = 0;
    }
    else //n < k
    {
        ans = min(n, k-n);
    }


    cout << ans;
}



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

#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
const int M = 100000;

int gcd(int x, int y) {
	if (x < y)gcd(y, x);
	int r;
	if(y==0)return x;
	while (r = x % y) {
		x = y;
		y = r;
	}
	return y;
}
 
 
int main() {
	int n, a[M],l[M],r[M],c[M];
 
	cin >> n;
	rep(i, n)cin >> a[i];
 
	l[0]=0,r[n+1]=0;
	rep(i,n)
		l[i+1]=gcd(l[i],a[i]);
	for(int i=n;i>=0;i--)
		r[i]=gcd(r[i+1],a[i]);
	rep(i,n)c[i]=gcd(l[i],r[i+1]);
	sort(c,c+n);
		
  
	cout << c[n-1] << endl;
}

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

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

int main(){ 
  ll a,b; cin >> a >> b;
  ll c = gcd(a,b);
  
  cout << (a*b)/c << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
inline int abs(int x) {
  return(x>0?x:-x);
}

using namespace std;



int main(){
  int n, x0, y0;
  cin >> n >> x0 >> y0;
  for (int i=0;i<n-2;i++) {
    int tmp;
    cin >> tmp;
  }
  int an_1, an;
  if (n > 1) {
  cin >> an_1 >> an;
  
  if (abs(an_1 - an) > abs(an - y0)) {
    cout << abs(an_1 - an) << endl;
  } else {
    cout << abs(an - y0) << endl;
  }
  } else {
    cin >> an; 
    cout << abs(an - y0) << endl;
  }
  
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<ll> data(n);
    ll takahashi = 0, aoki = 0;
    for (int i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        aoki += b;
        data[i] = a + b;
    }
    sort(data.begin(), data.end());
    reverse(data.begin(), data.end());
    for (int i = 0; i < n; i += 2)
    {
        takahashi += data[i];
    }
    cout << takahashi - aoki << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u){
      a -= 1;
  }else{
      b -= 1;
  }

  cout << a << " " << b << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const  int N=2e5+10;
const int mod = 998244353;


int main()
{
    int n,m;
    cin >> n >> m;
    int ans1 = max(0,n*(n-1)/2);
    int ans2 = max(0,m*(m-1)/2);
    cout << ans1 + ans2;
    return 0;
}


Measured memory_bytes: 256
def solve(H, W, M, h, w):
    f = [0] * (H+1)
    g = [0] * (W+1)
    for r, c in zip(h, w):
        f[r] += 1
        g[c] += 1
    p = max(f)
    q = max(g)
    num = len(list(filter(p.__eq__, f))) * len(list(filter(q.__eq__, g)))
    num -= len(list(filter(lambda _: f[_[0]] + g[_[1]] == p + q, zip(h, w))))
    return p + q - (num <= 0)

H, W, M = map(int, input().split())
h, w = zip(*[map(int, input().split()) for i in range(M)])
print(solve(H, W, M, h, w))

Measured memory_bytes: 166020
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#include <cstdlib>
using namespace std;
int brr[100000];
int find(int arr[],int n,int p)
{
	if(brr[p]!=-1)
	{
		return brr[p];
	}
	if(p+2<n){
	 brr[p]= min(abs(arr[p+1]-arr[p])+find(arr,n,p+1),abs(arr[p+2]-arr[p])+find(arr,n,p+2));
	 return brr[p];
	}
	else if(p+1<n&&p+2>=n)
	{
		brr[p]=abs(arr[p+1]-arr[p])+find(arr,n,p+1);
		return brr[p];
	}
	else
	{
		brr[p]=0;
		return brr[p];
	}
}
int main() {
	// your code goes here
	ll n;
	cin>>n;
	int arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		brr[i]=-1;
	}
	int r=find(arr,n,0);
	cout<<r;

	return 0;
}

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

using namespace std;

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

    vector<int> C(H);
    vector<pair<int, int>> AB(M);

    for (int i = 0; i < M; i++)
        cin >> AB[i].first >> AB[i].second;

    for (int i = 0; i < M; i++)
    {
        if (H[AB[i].first - 1] > H[AB[i].second - 1])
            C[AB[i].second - 1] = -1;
        if (H[AB[i].first - 1] < H[AB[i].second - 1])
            C[AB[i].first - 1] = -1;
        if (H[AB[i].first - 1] == H[AB[i].second - 1])
        {
            C[AB[i].second - 1] = -1;
            C[AB[i].first - 1] = -1;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
        if (C[i] != -1)
            ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4780
import java.util.Scanner;

public class Main{
     public static void main(String[] args){
          Scanner kb = new Scanner(System.in);
          int i, N, x, y, z, longest;
          
          N = kb.nextInt();
          
          for(i = 0 ; i < N ; i++){
               x = kb.nextInt();
               y = kb.nextInt();
               z = kb.nextInt();
               longest = x;
               if (longest < y){
                    longest = y;
               }
               if (longest < z){
                    longest = z;
               }
               if (longest == x){
                    if ((x * x) == (y * y + z * z)){
                         System.out.println("YES");
                    }
                    else{
                         System.out.println("NO");
                    }
               }
               else if (longest == y){
                    if ((y * y) == (x * x + z * z)){
                         System.out.println("YES");
                    }
                    else{
                         System.out.println("NO");
                    }
               }
               else if (longest == z){
                    if ((z * z) == (x * x + y * y)){
                         System.out.println("YES");
                    }
                    else{
                         System.out.println("NO");
                    }
               }
          }
     }
}

Measured memory_bytes: 33436
#include<stdio.h>
int main() {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (((A == B && A== 5) && (A != C)) || ((A == C && A == 5) && (A != B)) || ((B == C && B == 5) && (B != A))) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
def f(d1, t1, d2, t2):
    print(d1 * t1, end="")
    print(d2 * t2, end="")


def main():
    U, D, L, R = "U", "D", "L", "R"
    sx, sy, tx, ty = map(int, input().split())
    f(R, tx - sx, U, ty - sy)
    f(L, tx - sx, D, ty - sy)
    f(D, 1, "", 0)
    f(R, tx + 1 - sx, U, ty + 1 - sy)
    f(L, 1, "", 0)
    f(U, 1, "", 0)
    f(L, tx + 1 - sx, D, ty + 1 - sy)
    f(R, 1, "", 0)
    print()
    return


main()


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

int main() {
  int N, K, Q;
  int arr[N];
  cin >> N >> K >> Q;
  for(int i = 0; i < N; i++) {
    arr[i] = 0;
  }
  for(int i = 0; i < Q; i++) {
    int q;
    cin >> q;
    arr[q - 1]++;
  }
  for(int i = 0; i < N; i++) {
    if(arr[i] - Q + K > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2816
from collections import deque
import sys
input = sys.stdin.readline

f_inf = float('inf')

def push(v, d):
    if dist[v] != f_inf: return
    dist[v] = d
    que.append(v)

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0]*n
for sv in range(n):
    dist = [f_inf] * n
    que = deque([])
    push(sv, 0)

    while que:
        v = que.popleft()
        d = dist[v]+1
        if v-1 >= 0: push(v-1, d)
        if v+1 < n: push(v+1, d)
        if v == x: push(y, d)
        if v == y: push(x, d)

    for i in range(n):
        ans[dist[i]] += 1
        
for i in range(n):
    ans[i] = ans[i]//2

for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 55388
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
using namespace std;
const int N = 2e5+5;
typedef long long ll;
bool check(string a)
{
	string b=a;
	reverse(a.begin(),a.end());
	return a==b;
}
int main()
{
	int len;
	string ans;
	cin>>ans;
	len=ans.length();
	if(check(ans)&&check(ans.substr(0,(len-1)/2))&&check(ans.substr((len+3)/2-1)))
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

  n = N;

  while(sqrt(n) - (int)sqrt(n) != 0){
      n--;
  }

  N = n;

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

  return 0;
}


Measured memory_bytes: 128
"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const arg_str_array = arg_str.split('\n')
const arg_str_line1 = arg_str_array[0]
const arg_str_line2 = arg_str_array[1]
const arg_str_line1_array = arg_str_line1.split(' ')

const n = arg_str_line1_array[0]
const k = arg_str_line1_array[1]
const target_str = arg_str_line2

let return_val = target_str

if(n != target_str.length){
  return return_val
}

if(0 < k && k <= n){
  return_val = `${target_str.slice(0, k-1)}${target_str.slice(k-1, k).toLowerCase()}${target_str.slice(k)}`
}

console.log(return_val)

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

constexpr int MAX=200000;
constexpr int SENTINEL=2000000000;
using ll = long long;

int L[MAX/2+2];
int R[MAX/2+2];

ll Merge(int A[], int left, int mid, int right){
   int n1=mid-left;
   int n2=right-mid;
   ll cnt = 0;
   for(int i=0; i<n1; i++) L[i] = A[left+i];
   for(int i=0; i<n2; i++) R[i] = A[mid+i];
   L[n1] = R[n2] = SENTINEL;
   int i=0;
   int j=0;
   for(int k=left; k<right; k++){
      if(L[i] <= R[j]){
         A[k] = L[i++];
      }else{
         A[k] = R[j++];
         cnt += n1-i; //mid+j-k-1
      }
   }
   return cnt;
}

ll Merge_Sort(int A[], int left, int right){
   int mid;
   ll v1, v2, v3;
   if(left+1 < right){
      mid=(left+right)/2;
      v1=Merge_Sort(A, left, mid);
      v2=Merge_Sort(A, mid, right);
      v3=Merge(A, left, mid, right);
      return v1 + v2 + v3;
   } else return 0;
}

int main(){
   int A[MAX], n;

   cin >> n;
   for(int i=0; i<n; i++) cin >> A[i];

   ll ans=Merge_Sort(A, 0, n);
   cout << ans << endl;

   return 0;
}


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

int n, counts=0;
long long int ans, sum = 0;
vector<long long int> a(500000);

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a.at(i);

    long long int mina = 2000000000;
    for (int i = 0; i < n; ++i)
    {
        if (a.at(i) < 0)
        {
            counts ++;
        }

        sum += abs(a.at(i));
        if (mina > abs(a.at(i)))
        {
            mina = abs(a.at(i));
        }
    }

    if (counts%2 == 0)
    {
         ans = sum;
    } else {
        ans = sum - 2*mina;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<ctype.h>

int main(void)
{
	char ch;
	
	while(1) {
		scanf("%c", &ch);
		if(islower(ch)) printf("%c", toupper(ch));
		else if(isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);
		
		if(ch=='\n') break;
	}
	
	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N, M; cin >> N >> M;
    vector<bool> s(200050, false), t(200050, false);
    rep(i, M) {
        ll a, b; cin >> a >> b;
        if (a == 1) t[b] = true;
        if (b == N) s[a] = true;
    }

    rep(i, 200050) {
        if (s[i] && t[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3616
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n,m;
    cin>>n>>m;
    vector<int> height(n);
    for(int i = 0; i < n; i++) {
        cin>>height[i];
    }
    vector<int> arr[n];
    for(int i = 0; i < m; i++) {
        int u, v;
        cin>>u>>v;
        u--; v--;
        arr[u].push_back(v);
        arr[v].push_back(u);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        bool flag = true;
        for(int j = 0; j < arr[i].size(); j++) {
            if(height[arr[i][j]] >= height[i]) {
                flag = false;
            }
        }
        ans += flag;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8756
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
x,y=reada(N,2)
function d(x1,y1,x2,y2)return math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))end

s=0
for i=1,N do
for j=1,i-1 do
s=s+d(x[i],y[i],x[j],y[j])
end
end
print(s/N*2)

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

using namespace std;

int N;
list<int> Cards;
list<int>::iterator CurPosA, CurPosB;

void shuffleCards() {
	
	CurPosB = Cards.begin();
	advance(CurPosB, N);

	CurPosA = Cards.begin();
	for (int i = 0; i < N; ++i) {
		Cards.insert(CurPosB, *CurPosA);
		CurPosA = Cards.erase(CurPosA);
		++CurPosB;
	}
}

int main() {
	int m, k;

	cin >> N >> m;
	for (int i = 1; i <= 2 * N; ++i) {
		Cards.push_back(i);
	}
	for (int i = 0; i < m; ++i) {
		cin >> k;
		if (k == 0) {
			shuffleCards();
			continue;
		}
		for (int i = 0; i < k; ++i) {
			Cards.push_back(Cards.front());
			Cards.pop_front();
		}
	}

	CurPosB = Cards.end();
	for (CurPosA = Cards.begin(); CurPosA != CurPosB; ++CurPosA) {
		cout << *CurPosA << endl;
	}

	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
random_device rnd;
int main() {
    clock_t start = clock();
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    vector<int> last(26, -1);
    auto calc = [&](int day, int type) {
        int ret = 0;
        ret += s[day][type];
        rep(i, 26) if (i != type) ret -= c[i] * (day - last[i]);
        return ret;
    };

    int score = 0;
    vector<int> t(D);
    rep(d, D) {
        int MAX = -INF;
        rep(i, 26) if (chmax(MAX, calc(d, i))) t[d] = i;
        last[t[d]] = d;
        score += MAX;
    }

    vector<set<int>> st(26);
    rep(i, D) st[t[i]].insert(i);
    auto diff = [&](int d, int q) {
        int p = t[d];
        t[d] = q;
        int ret = 0;
        ret -= s[d][p];
        ret += s[d][q];
        {
            int d1 = (st[p].find(d) == st[p].begin() ? -1 : *(--st[p].find(d)));
            int d2 = (st[p].find(d) == --st[p].end() ? D : *(++st[p].find(d)));
            ret -= c[p] * (d - d1) * (d2 - d);
        }
        st[p].erase(d);
        st[q].insert(d);
        {
            int d1 = (st[q].find(d) == st[q].begin() ? -1 : *(--st[q].find(d)));
            int d2 = (st[q].find(d) == --st[q].end() ? D : *(++st[q].find(d)));
            ret += c[q] * (d - d1) * (d2 - d);
        }
        return ret;
    };

    while (1) {
        int d = uniform_int_distribution<int>(0, D - 1)(rnd);
        int q = uniform_int_distribution<int>(0, 25)(rnd);
        int p = t[d];
        int x = diff(d, q);
        if (x < 0) {
            t[d] = p;
            st[p].insert(d);
            st[q].erase(d);
        } else {
            score += x;
        }
        clock_t end = clock();
        const double time =
            static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
        if (time > 1900) break;
    }
    rep(i, D) cout << t[i] + 1 << '\n';
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,n,b,bb,i;
  cin>>a>>n;
  int r=0,l=0;
  for(i=0;i<n;i++){
    cin>>b>>bb;
    if(b>0)r+=b*bb;
    if(b<0)l-=b*bb;
  }
  if(r==l)cout<<0;
  else if(r>l)cout<<1<<endl<<-1<<" "<<r-l<<endl;
  else cout<<1<<endl<<1<<" "<<l-r<<endl;
  return 0;
}
 

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC045_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = Console.ReadLine();
            var L = t.Length;
            var now = 0;
            long ans = 0;
            for (int S = 0; S < 1 << L-1; S++)
            {
                var H = new List<int>();

                H.Add(0);
                var cnt = 1;
                int Z = S;

                while (Z > 0)
                {
                    if((Z & 1) == 1)
                    {
                        H.Add(cnt);
                    }
                    Z = Z >> 1;
                    cnt++;
                }

                H.Sort();
                H.Reverse();


                for (int i = 0; i < H.Count; i++)
                {
                    var k = L - H[i];
                    //Console.WriteLine(k);
                    for (int j = k; j >= 1; j--)
                    {
                        ans += int.Parse(t[now].ToString()) * (long)Math.Pow(10,j-1);
                        now++;
                        //Console.WriteLine(ans);
                    }
                    //now = 0;
                    L = L - k;
                }
                now = 0;
                L = t.Length;
                //Console.WriteLine(ans);
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdint>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int64_t> aa;
	for(int i = 0; i < n; ++i) {
		int64_t t;
		cin >> t;
		aa.push_back(t);
	}
	sort(aa.begin(), aa.end());
	int64_t sum = 0;
	if(n % 2 == 0) {
		for(int i = 0; i < n; ++i) {
			if(i < n / 2 - 1) {
				sum -= aa[i] * 2;
			} else if (i == n / 2 - 1) {
				sum -= aa[i];
			} else if (i == n / 2) {
				sum += aa[i];
			} else {
				sum += aa[i] * 2;
			}
		}
	} else {
		for(int i = 0; i < n; ++i) {
			if(i < (n - 3) / 2) {
				sum -= aa[i] * 2;
			} else if(i > (n + 1) / 2) {
				sum += aa[i] * 2;
			}
		}
		sum += max(
				2 * aa[(n+1)/2] - aa[n/2] - aa[n/2-1],
				    aa[(n+1)/2] + aa[n/2] - aa[n/2-1] * 2);
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1400
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# 頂点1から頂点kまでの最短パス上
# ルートはO(n)で求められる
N = getN()
A = getList()
query = [getList() for i in range(N - 1)]

dist = [[] for i in range(N)]
for i in range(N - 1):
    a, b = query[i]
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)

ignore = [0] * N
ignore[0] = 1
lis = [A[0]]
rec = [0] * N
rec[0] = 1

# 行きがけ帰りがけの要領
def dfs(u):
    global lis
    for i in dist[u]:
        if ignore[i] != 1:
            ignore[i] = 1
            # 巻き戻し用
            plus = 0 # true or false
            change = (0, 0, 0) # true or false, 変更した場所、変更した数値

            if A[i] > lis[-1]:
                lis.append(A[i])
                plus = 1
            else:
                index = bisect_left(lis, A[i])
                change = (1, index, lis[index])
                lis[index] = A[i]
            rec[i] = len(lis)
            dfs(i)
            # 巻き戻す
            if plus:
                lis.pop()
            else:
                lis[change[1]] = change[2]

dfs(0)
for i in rec:
    print(i)

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

using namespace std;
int main(){
    int x, h, m, s;
    cin >> x;
    h = x / 3600;
    x = x - h * 3600;
    m = x / 60;
    s = x - 60*m;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;string S;cin>>N>>S;int WW=0;
  vector<int>V(N+1),A(N);
  for(int X=0;X<N;X++){
    if(S[X]=='W'){
      V[X+1]++;V[N]--;
    }
    else{
      V[0]++;V[X]--;
    }
  }
  int R=0;
  for(int X=0;X<N;X++){
    R+=V[X];
    A[X]=R;
  }
  sort(A.begin(),A.end());
  cout<<A[0]<<endl;
}


Measured memory_bytes: 6156
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final long MOD = 1000000007L;


  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int w = sc.nextInt();
    int h = sc.nextInt();

    int x = sc.nextInt();
    int y = sc.nextInt();

    double area = (double) w * (double) h;
    area /= 2;

    int divide = (x * 2 == w) && (y * 2 == h) ? 1 : 0;

    os.print(String.format("%.6f", area) + " ");
    os.println(divide);
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

bool check(int a[], int n, int k)
{
    int sum1 = 0, sum2 = 0;
    for(int i = 0; i < n; i++)
        sum1 += k - a[i], sum2 += a[i];
    return sum1 > sum2;
}

template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}

ll dp[101][100001];

int main()
{
    int n, W;
    cin >> n >> W;
    int w[n + 1], v[n + 1];
    for(int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    dp[0][0];
    for(int i = 0; i <= W; i++) dp[0][i] = 0;
    for(int i = 0; i <= n; i++) dp[i][0] = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= W; j++)
        {
            if(j >= w[i])
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    cout << dp[n][W];
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> a(h, vector<char>(w,'*'));

  rep(i,h) rep(j,w) cin >> a[i][j];

  rep(i,h) {
      bool flag = true;
      rep(j,w) if (a[i][j] == '#') flag = false;
      if (flag) rep(j,w) a[i][j] = 'o';

  }
  rep(i,w) {
      bool flag = true;
      rep(j,h) if (a[j][i] == '#') flag = false;
      if (flag) rep(j,h) a[j][i] = 'o';
  }
  
  rep(i,h){
    rep(j,w) {
      if (a[i][j] != 'o') cout << a[i][j];
    }
    rep (j,w) {
      if (a[i][j] != 'o') {
        cout << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=8&&b<=8){
        cout << "Yay!";
    }else{
        cout <<":(";}
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    b = []
    for i in range(N):
        if((N-1)-i*2>0):
            b.append(a[(N-1)-i*2])
        else:
            b.append(a[max(0,i*2-N)])
    print(' '.join(str(_) for _ in b))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 29236
<?php
  list($n, $m, $q) = explode(" ", trim(fgets(STDIN)));


  $a = [];
  $b = [];
  $c = [];
  $d = [];
  for($i=0;$i<$q;$i++){
     list($a[], $b[], $c[], $d[]) = explode(" ", trim(fgets(STDIN)));
  }

  $pattern = f($n, $m, 0, "0");
/*
  for($i=0;$i<count($pattern);$i++){
    echo $pattern[$i].PHP_EOL;
  }
exit;
*/
  $max_point = 0;
  for($i=0; $i<count($pattern); $i++){
    $point = 0;
    $p = $pattern[$i];
    for($j=0; $j<$q; $j++){
      if($p[$b[$j]-1] - $p[$a[$j]-1] == $c[$j]){
        $point += $d[$j];
//        echo $point.PHP_EOL;
      }
    }
    $max_point = max($max_point, $point);
  }

  echo $max_point;
  

  function f ($n, $m, $ma, $pattern) {
//    echo strlen($pattern).PHP_EOL;
    if($n <= strlen($pattern)){
      return [$pattern];
    }
    $array = [];
    for($i=0; $i<$m-$ma; $i++){
      $array = array_merge($array, f($n, $m, $ma+$i, $pattern.($ma+$i)));
    }
    return $array;
  }


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if (k <= a) 
    cout << k << endl;
  else {
    int res, x;
    x = k - a;
    res = a;
    if (x <= b)
      cout << res << endl;
    else {
      x -= b;
      cout << res - x << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3640
n = gets.to_i
a = gets.split.map(&:to_i)
cnt = Hash.new(0)
a.map { |ai| cnt[ai] += 1 }
all = 0
cnt.each do |k, v|
  all += v * (v - 1) / 2
end
n.times do |i|
  p all - (cnt[a[i]] - 1)
end

Measured memory_bytes: 52584
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, s.size()) {
    int x = s[i] - 'A';
    int y = (x + n) % 26;
    s[i] = y + 'A';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N, M;
    scan(N, M);
    vector<ll> a(N);
    scan(a);
    vector<pair<ll, ll>> v(M);
    rep(i, M) scan(v[i].second, v[i].first);
    sort_(a);
    rsort(v);
    int now = 0;
    rep(i, N) {
        if (a[i] < v[now].first && now < M) {
            a[i] = v[now].first;
            v[now].second--;
        }
        if (v[now].second == 0) {
            now++;
        }
    }
    ll ans = 0;
    for (auto &&i : a) {
        ans += i;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define os_find(k) find_by_order(k)
//#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int dp[3001][3001];

signed main()
{
    fast

    string s,t;
    cin>>s>>t;

    f1(i,0,s.length()) dp[0][i] = 0;
    f1(i,0,t.length()) dp[i][0] = 0;

    f1(i,1,s.length())
    {
        f1(j,1,t.length())
        {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1] == t[j-1])
            dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
    }
    int i = s.length(), j = t.length();
    stack<char> st;
    while(i!=0&&j!=0)
    {
        if(dp[i-1][j-1]+1 == dp[i][j] && s[i-1]==t[j-1])
        {
            st.push(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i][j-1])
        {
            j--;
        }
        else
        {
            i--;
        }
    }
    while(!st.empty())
    {
        cout<<st.top();
        st.pop();
    }
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::string s1, s2;
	std::cin >> s1 >> s2;
	std::string s = s1 + s2;

	int	number = 0;

	for (auto c : s)
		number = number * 10 + c - '0';
	if ((int)sqrt((double)number) == sqrt((double)number))
		pnl("Yes");
	else
		pnl("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};


const int MAXI = 100005;
ll memo[MAXI];
ll N, A, B;

vector<ll> X;
int main() {
    
    cin >> N >> A >> B;
    X.resize(N+1);
    for(auto i = 1; i<=N; i++){
        cin >> X[i];
    }
    
    memo[1] = 0;
    for(auto i = 1; i<=N; i++){
        
        memo[i+1] = min(memo[i] + B , memo[i] + A*(X[i+1]-X[i]));
        
    }
    
    cout << memo[N] << endl;

  
    return 0;
}









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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  cout << (n >= 30 ? "Yes" : "No") << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3632
n = gets.to_i
a = gets.split.map(&:to_i)
num_4=a.count{(_1%4).zero?}
num_2=a.count{(_1%2).zero?}-num_4
if num_2 > 1
    n=n-num_2-1
    num_4-=1
end
th=n/2
if num_4 >= th
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 20840