akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d=0,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN(n);
  Vd v(n);
  VIN(v)
  SORT(v);
  FOR(i,1,n){
    v[i] = (v[i-1] + v[i]) / 2;
  }
  OUT(v[n-1]);
}

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

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, v[100000];
P a[100001], b[100001];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> v[i];
	REP(i, 100001) a[i] = b[i] = P{0, i};
	REP(i, n/2) ++a[v[i*2]].F;
	REP(i, n/2) ++b[v[i*2+1]].F;
	sort(a, a+100001); reverse(a, a+100001);
	sort(b, b+100001); reverse(b, b+100001);
	if (a[0].S == b[0].S) cout << min(n - a[0].F - b[1].F, n - b[0].F - a[1].F) << endl;
	else cout << (n - a[0].F - b[0].F) << endl;
	return 0;
}


Measured memory_bytes: 7448
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll n,max1=0,max2=0;
    cin>>n;
    vll a(n);
    rep(i,n){
        cin>>a.at(i);
        max1=max(max1,a.at(i));
    }
    
    rep(i,n){
        if(a.at(i)==max1){
            a.at(i)=0;
            break;
        }
    }
    rep(i,n){
        max2=max(max2,a.at(i));
    }
    rep(i,n){
        if(a.at(i)==0)cout<<max2<<endl;
        else cout<<max1<<endl;
    }
}
   



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 n,k;
    cin >> n >> k;
    vector<int64> h(n+1,0);
    REP(i,n)cin >> h[i+1];
    int64 ans = LLINF;
    vector<vector<int64>> dp(n+1,vector<int64>(n-k+1,LLINF));
    dp[0][0] = 0;
    FOR(i,1,n+1){
        FOR(j,1,n-k+1){
            REP(l,i)
                dp[i][j] = min(dp[i][j], dp[l][j-1] + max<int64>(0,h[i] - h[l]));
        }
    }
    FOR(i,0,n+1){
        ans = min(ans, dp[i][n-k]);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 1024
N,X = (int(T) for T in input().split())
A = [int(T) for T in input().split()]
Eat = 0
for AT in range(0,N-1):
    if A[AT]+A[AT+1]>X:
        Need = A[AT]+A[AT+1]-X
        Eat += Need
        A[AT] -= max(0,Need-A[AT+1])
        A[AT+1] = max(0,A[AT+1]-Need)
print(Eat)

Measured memory_bytes: 20064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)

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

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

#define MAX 16

int m, n;
double win[MAX][MAX];
double memo[MAX][(1 << MAX)];

inline double dfs(int room = 0, int rest = (1 << m) - 1) {
	if(memo[room][rest] >= 0.0)
		return memo[room][rest];

	double res = 0.0;
	for(int i = 0; i < m; ++i) {
		if(rest & (1 << i)) {
			const int next_rest = rest ^ (1 << i);
			double tmp = 0.0, p = 1.0;
			for(int j = room; j < n; ++j) {
				tmp += p * (1 - win[i][j]) * dfs(j, next_rest);
				p *= win[i][j];
			}

			chmax(res, tmp + p);
		}
	}

	return memo[room][rest] = res;
}

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

	for(int i = 0; i < m; ++i)
		for(int j = 0; j < n; ++j)
			scanf("%lf", &win[i][j]);

	memset(memo, -1, sizeof(memo));
	for(int i = 0; i < n; ++i)
		memo[i][0] = 0.0;

	printf("%.15lf\n", dfs());

	return EXIT_SUCCESS;
}

Measured memory_bytes: 9444
#include <iostream>
#include <cstdio>
#include <cstring>
#define fre
#define DEBUG
using namespace std;
int n, k, z = -1, t, ans = 1e9;
int a[100005];
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) 
    {
        scanf("%d", &t);
        if (t == 0) --k, --i, --n;
        else 
        {
            if ((i && a[i - 1] < 0 && t > 0) || (i == 0 && t > 0)) z = i;
            a[i] = t;
        }
    }
    if (z == -1) z = n;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] < 0)
        {
           // if (i >= k - 1) ans = min(ans, a[i] - a[i - k + 1]);
            if (z - i == k) ans = min(ans, -a[i]);
            else if (z - i < k && n - i >= k) ans = min(ans, -a[i] + 2 * a[k - 1 + i]); 
        }
        else 
        {
           // if (n - i >= k) ans = min(ans, a[i + k - 1] - a[i]);
            if (i + 1 - z == k) ans = min(ans, a[i]);
            else if (i + 1 - z < k && i + 1 >= k) ans = min(ans, a[i] + 2 * -a[i - k + 1]);
        }
    }
  //  cout << z << endl;
    printf("%d\n", (k == 0 ? 0 : ans));
}

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

int main(){
int n=0;
string s,t;
cin>>s;
t=s;
reverse(s.begin(),s.end());
rep(i,s.size()){
  if(s.at(i)!=t.at(i))n++;
}
n/=2;
cout<<n<<endl;
 return 0;
}


Measured memory_bytes: 256
import math

S = input()
S_list = []
N = len(S)
for i in range(N):
    S_list.append(S[i])

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.ceil(N/2)-odd_0, odd_0+math.trunc(N/2)-even_0), 0))

Measured memory_bytes: 4340
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;

int main()
{
	int nCnt;
	cin >> nCnt;
	int nL[10];
	int nMax = 0;
	int nMaxIdx = 0;
	for (int i = 0; i < nCnt; i++)
	{
		cin >> nL[i];
		if (nMax < nL[i])
		{
			nMax = nL[i];
			nMaxIdx = i;
		}
	}

	int nSum = 0;
	for (int i = 0; i < nCnt; i++)
	{
		if (nMaxIdx != i)
			nSum += nL[i];
	}

	if (nMax < nSum)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
max1 = 0
max2 = 0
for i in range(N):
  if max1 < A[i]:
    max2 = max1
    max1 = A[i]
  elif A[i] > max2:
    max2 = A[i]

for j in range(N):
  if A[j] == max1:
    print(max2)
  else:
    print(max1)

Measured memory_bytes: 12512
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,L,t,a[N],num;
int main()
{
	int i,x,y;
	cin>>n>>L>>t;
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		x+=(y==1 ? t : -t);
		(num+=x/L)%=n,x%=L;
		if(x<0) x+=L,num--;
		a[i]=x;
	  }
	sort(a,a+n);
	for(i=0;i<n;i++)
		printf("%d\n",a[(i+num+n)%n]);
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long n;
    cin >> n;

    vector<long> h(n, 0);
    vector<long> dp(n, 0);

    for (auto &item: h)
        cin >> item;

    dp[1] = abs(h[1] - h[0]);

    for (long i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import itertools

n,m = map(int,input().split())
H = list(map(int,input().split()))
memo = [0]*n

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if memo[b] < H[a]:
        memo[b] = H[a]
    if memo[a] < H[b]:
        memo[a] = H[b]

ans = 0
for i in range(n):
    if memo[i] < H[i]:
        ans += 1

print(ans)
        

Measured memory_bytes: 20180
//////////////////////////////
// Author: whatisit
// Date: 2020-05-14 21:03 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

const int N = 4, M = 6;
int n, m, s, c, num[N];

void solve() {
	cin >> n >> m;
	fill(num, num+n+1, -1);
	for (int i = 0; i < m; ++i) {
		cin >> s >> c;
		if (s > n) {
			cout << -1;
			return;
		}
		if (num[s] != -1 && num[s] != c) {
			cout << -1;
			return;
		}
		num[s] = c;
	}
	if (n > 1 && num[1] == 0) {
		cout << -1;
		return;
	}
	for (int i = 1; i <= n; ++i) {
		if (num[i] != -1) cout << num[i];
		else if (i == 1 && n == 1) cout << 0;
		else if (i == 1) cout << 1;
		else cout << 0;
	}
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

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

using namespace std;

int main(){
    int ans=0,min;
    vector<long long> a(305);
    vector<long long> b(305);
    vector<int> s(305);
    int N;

    cin >>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        while(a[i]>0){ 
            b[i]=a[i]/2;

            if(b[i]*2!=a[i]){
                break;
            }
            s[i]++;
            a[i]=b[i];
        }
        
    }


    min=s[0];
    for(int i=1;i<N;i++){
        if(s[i]<min){
            min=s[i];
        }
    }


    cout << min << endl;

    return 0;

}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	VecP a(n);
	rep(i, n){
		cin >> a[i].fs;
		a[i].sc = i;
	}
	sort(all(a));

	ll ans = 0;
	rep(i, n){
		if(abs(a[i].sc-i)%2 == 1) ans++;
	}
	co(ans/2);

	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

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


int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    Rep(i,n){
        cin >> d[i];
    }
    sort(All(d));
    cout << d[n/2]-d[n/2-1] << "\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   long long n;
   cin >> n;
   long long chart[9][9];
   for(int i = 0;i < 9;i++) {
       for(int j = 0;j < 9;j++) {
           chart[i][j] = 0;
       }
   }
   if(n<10) {
       cout << n << endl;
       return 0;
   } 
   //横方向を全て1で埋める
   for(int i = 0;i < 9;i++) {
       chart[i][i]=1;
   }
   for(long long i = 10;i <= n;i++) {
       string str = to_string(i);
       if(str[str.size()-1]-'0'-1>=0&&(int)(str[0]-'0'-1)>=0) chart[(int)(str[str.size()-1]-'0'-1)][(int)(str[0]-'0'-1)]++;
   }
//    for(int i = 0;i < 9;i++) {
//        for(int j = 0;j < 9;j++) {
//            cout << chart[i][j] << " ";
//        }
//        cout << '\n';
//    }
//    cout << "-------------------" << endl;
   long long result = 0;
   for(int i = 0;i < 9;i++) {
       for(int j = i;j < 9;j++) {
           if(i==j) {
               result+=pow(chart[i][j], 2);
           } else if(chart[i][j]!=0&&chart[j][i]!=0) {
               result+=chart[i][j]*chart[j][i]*2;
           }
       }
   }
   cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string L;
ll dp[100010][2];
int main(){
    cin>>L;
    for(ll i=0;i<L.length();i++){
        for(ll j=0;j<2;j++){
                dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(ll i=0;i<L.length();i++){
        for(ll j=0;j<2;j++){
            for(ll bit1=0;bit1<2;bit1++){
                for(ll bit2=0;bit2<2;bit2++){
                    if(bit1 && bit2)continue;
                    ll nextJ=j;
                    ll bit=bit1+bit2;
                    if(j==0){
                        if(bit>L[i]-'0')continue;
                        if(bit<L[i]-'0'){
                            nextJ=1;
                        }
                    }
                    dp[i+1][nextJ]=(dp[i+1][nextJ]+dp[i][j])%MOD;
                }
            }
        }
    }
    cout<<(dp[L.length()][0]+dp[L.length()][1])%MOD<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
#define scan1(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define scan2(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define assign1(a,n,x) for(int i=0;i<n;i++)a[i]=x;
#define assign2(a,m,n,x) for(int i=0;i<m;i++){ for(int j=0;j<n;j++){a[i][j]=x;}}
#define max3(a,b,c) max(a,max(b,c));
#define min3(a,b,c) min(a,max(b,c));
#define int long long
#define bn "\n"

long long power_mod(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int binarySearch(int arr[], int l, int r, int x) 
{ 
    while (l <= r) { 
        int m = l + (r - l) / 2; 
        // Check if x is present at mid 
        if (arr[m] == x) 
            return m; 

        // If x greater, ignore left half 
        if (arr[m] < x) 
            l = m + 1; 
  
        // If x is smaller, ignore right half 
        else
            r = m - 1; 
    } 
  
    // if we reach here, then element was 
    // not present 
    return -1; 
} 

int32_t main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        string a[n+1];
        int t=0;
        for(int i=1;i<=n;i++){
            if(i%15==0)a[i]="FizzBuzz";
            else if(i%3==0)a[i]="Fizz";
            else if(i%5==0)a[i]="Buzz";
            else a[i]="ss";
        }
        //for(int i=0;i<=n;i++)cout<<a[i]<<" ";
        for(int i=1;i<=n;i++){
            if(a[i]=="ss")t+=i;
        }
        cout<<t;
    }
    return 0;
}

Measured memory_bytes: 34820
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A, B, X = map(int, input().split())
    if A <= X and X - A <= B:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
map<int ,int> mp;
vi vr;
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int x,y;
cin>>y;
x=48-y;
cout<<x;
 
}


Measured memory_bytes: 256
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
n=int(input())
S=list(map(int,input().split()))
S=quick_sort(S)
word=n//int(2)
s=int(S[word])-int(S[word-1])
s2=int(S[word])-int(S[word-1])
print(s)


Measured memory_bytes: 14428
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/



int main() {

	ll l, r;
	cin >> l >> r;

	ll diff = r - l;
	ll mini = 2018;
	if (diff >= 2019) {
		cout << "0" << endl;
	}
	else
	{
		for (ll i = l; i <= r ;i++)
		{
			for (ll j = i + 1; j <= r; j++) {
				mini = min(mini, ((i%2019)*(j%2019)) % 2019);
			}
		}
		cout << mini << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846



int main(void) {
	char S[4];
	scanf("%s", &S);
	int count1 = 0;
	int count2 = 0;
	int count3 = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'a') {
			count1++;
		}
		else if (S[i] == 'b') {
			count2++;
		}
		else if (S[i] == 'c') {
			count3++;
		}
	}
	if (count1 == 1 && count2 == 1 && count3 == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}



	return 0;
}


Measured memory_bytes: 128
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#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;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a + b, b + c, a + c});

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int ans=a[1];
    for(int i=2;i<=n;i++) ans=min(ans,__gcd(ans,a[i]));
    cout<<ans<<endl;
}


Measured memory_bytes: 640
H, W = map(int, input().split())
vax = []
hax = []
a = [str(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            if i not in vax:
                vax.append(i)
            if j not in hax:
                hax.append(j)
vax.sort()
hax.sort()       
for i in vax:
    for j in hax:
        b = a[i][j]
        print(b,end="")
    print("")

Measured memory_bytes: 4468
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val line = (1..n).map { readLine()!!.split(" ")
        .map { it.toInt() }
        .filterIndexed { index, i -> index > 0 }}
        .flatten()
    val ans = line.groupBy { it }
        .filter { it.value.size == n }
        .count()
    println(ans)
}

Measured memory_bytes: 37748
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
 
// 入力
int n, W;
int weight[110], value[110];
 
// DPテーブル
int dp[110][110];
 
int main() {
  int H, W; cin >> H >> W;
  string S[H];
  for (int i = 0; i < H; ++i) cin >> S[i];
  
  // DP初期条件: dp[H][W] = 0
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) dp[i][j] = 0;
  }
  
  // left top corner
  if (S[0][0] == '#') dp[0][0] = 1;
  
  // top line
  for (int i = 1; i < W; ++i) {
    if (S[0][i] == '#') {
      if (S[0][i-1] == '#') {
        dp[0][i] = dp[0][i-1];

      } else {
        dp[0][i] = dp[0][i-1] + 1;
      }
    } else {
      dp[0][i] = dp[0][i-1];
    }
  }
  
  // left line
  for (int j = 1; j < H; ++j) {
    if (S[j][0] == '#') {
      if (S[j-1][0] == '#') dp[j][0] = dp[j-1][0];
      else dp[j][0] = dp[j-1][0] + 1;
    } else {
      dp[j][0] = dp[j-1][0];
    }
  }

  int tmpUp;
  int tmpLeft;
  for (int i = 1; i < H; ++i) {
    for (int j = 1; j < W; ++j) {
      if (S[i][j] == '#') {
        if (S[i-1][j] == '#') tmpUp = dp[i-1][j];
        else tmpUp = dp[i-1][j] + 1;

        if (S[i][j-1] == '#') tmpLeft = dp[i][j-1];
        else tmpLeft = dp[i][j-1] + 1;
        
        dp[i][j] = min(tmpUp, tmpLeft);

      } else {
        dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
      }
    }
  }   
   
  cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,a,b,c,d = (int(x) for x in input().split())
s = input()

ok1 = True
cnt = 0
for i in xrange(b,d):
    if s[i-1] == "#":
        cnt += 1
        if cnt == 2:
            ok1 = False
            break
    else:
        cnt = 0

ok2 = True
cnt = 0
for i in xrange(a,c):
    if s[i-1] == "#":
        cnt += 1
        if cnt == 2:
            ok2 = False
            break
    else:
        cnt = 0
if d > c: # a->c and b->d
    ok3 = True
else:
    cnt = 0
    ok3 = False
    for i in xrange(b-1,d+2):
        if s[i-1] == ".":
            cnt += 1
            if cnt == 3:
                ok3 = True
                break
        else:
            cnt = 0
if ok1 and ok2 and ok3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 85812
import fractions
h,w,t=map(int,input().split())
g=fractions.gcd(h,w)
def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
H=fractions.gcd(h,t)
W=fractions.gcd(w,t)
p=10**9+7
a=power_func(2,fractions.gcd(h//H,w//W),p)
b=power_func(2,h//H,p)
c=power_func(2,w//W,p)
d=(a+b+c-3)%p
print(power_func(d,H*W,p))


Measured memory_bytes: 5044
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<int> G[2000];
int U[2000], R[2000];
int MU[2000], MV[2000];
int ex[2000];
set<int> C[2000];
vector<int> leftE[2000], rightE[2000];
bool up[2000], down[2000];
bool dead[2000];
bool dir[2000];

void dfs(int x, int p, int r) {
  U[x] = p, R[x] = r;
  for (int t : G[x]) if (t != p) dfs(t, x, r+1);
}
void go(int id, bool d) {
  assert(!dead[id]);
  dead[id] = true;
  dir[id] = d;
  //cout<<"id="<<id<<": dir="<<d<<"\n";
  //if (dir[id]) cout << MU[id]+1 << "->" << MV[id]+1 <<"\n";
  //else cout << MV[id]+1 << "->" << MU[id]+1 <<"\n";

  for (int e : leftE[id]) {
    if (d) up[e] = true;
    else down[e] = true;
  }
  for (int e : rightE[id]) {
    if (d) down[e] = true;
    else up[e] = true;
  }
  rep(i, N) C[i].erase(id), C[i].erase(id+M);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  dfs(0, -1, 0);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (R[u] < R[v]) swap(u, v);
    MU[i] = u, MV[i] = v;
    while (R[u] != R[v]) leftE[i].pb(u), u = U[u];
    while (u != v) leftE[i].pb(u), u = U[u], rightE[i].pb(v), v = U[v];
    for (int x : leftE[i]) C[x].insert(i);
    for (int x : rightE[i]) C[x].insert(i+M);
  }
  rep(i, N) ex[i] = min((int)C[i].size(), 2);
  int s = 0;
  rep(i, N) s += ex[i];
  cout << s << "\n";

  int ctr = 0;
  while (ctr < M) {
    bool none = true;
    rep(i, N) if (ex[i]==2 && (up[i]^down[i]) && C[i].size() == 1) {
      int id = *C[i].begin();
      bool is_up = (!up[i]) ^ (id >= M);
      if (id >= M) id -= M;
      ctr++;
      none = false;
      go(id, is_up);
      break;
    }
    if (none) {
      int id = 0;
      while (id<M && dead[id]) id++;
      assert(id != M);
      //cout<<"none="<<id<<"\n";
      go(id, true);
      ctr++;
    }
  }
  rep(i, N) assert(ex[i] == 0+up[i]+down[i]);
  rep(i, M) {
    if (dir[i]) cout << MU[i]+1 << " " << MV[i]+1 <<"\n";
    else cout << MV[i]+1 << " " << MU[i]+1 <<"\n";
  }
  return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

void calc(vector<string> &ans, int &x, int &y, string z){
	x++;
	y--;
	ans.push_back(z);
}

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

	int n, a, b, c;
	cin >> n >> a >> b >> c;

	vector<string> s(n);
	rep(i, n) cin >> s[i];

	vector<string> ans;
	rep(i, n){
		if(s[i] == "AB"){
			if(a == 0 && b == 0){
				cout << "No" << endl;
				exit(0);
			}else if(a == 1 && b == 0){
				calc(ans, b, a, "B");
			}else if(a == 0 && b == 1){
				calc(ans, a, b, "A");
			}else if(a == 1 && b == 1){
				if(i < n - 1 && s[i+1] == "AC"){
					calc(ans, a, b, "A");
				}else if(i < n && s[i+1] == "BC"){
					calc(ans, b, a, "B");
				}else{
					calc(ans, a, b, "A");
				}
			}else{
				if(a >= b){
					calc(ans, b, a, "B");
				}else{
					calc(ans, a, b, "A");
				}
			}
		}

		if(s[i] == "BC"){
			if(c == 0 && b == 0){
				cout << "No" << endl;
				exit(0);
			}else if(c == 1 && b == 0){
				calc(ans, b, c, "B");
			}else if(c == 0 && b == 1){
				calc(ans, c, b, "C");
			}else if(c == 1 && b == 1){
				if(i < n - 1 && s[i+1] == "AC"){
					calc(ans, c, b, "C");
				}else if(i < n && s[i+1] == "AB"){
					calc(ans, b, c, "B");
				}else{
					calc(ans, c, b, "C");
				}
			}else{
				if(c >= b){
					calc(ans, b, c, "B");
				}else{
					calc(ans, c, b, "C");
				}
			}
		}

		if(s[i] == "AC"){
			if(a == 0 && c == 0){
				cout << "No" << endl;
				exit(0);
			}else if(a == 1 && c == 0){
				calc(ans, c, a, "C");
			}else if(a == 0 && c == 1){
				calc(ans, a, c, "A");
			}else if(a == 1 && c == 1){
				if(i < n - 1 && s[i+1] == "AB"){
					calc(ans, a, c, "A");
				}else if(i < n && s[i+1] == "BC"){
					calc(ans, c, a, "C");
				}else{
					calc(ans, a, c, "A");
				}
			}else{
				if(a >= c){
					calc(ans, c, a, "C");
				}else{
					calc(ans, a, c, "A");
				}
			}
		}
	}

	cout << "Yes" << endl;
	rep(i, n) cout << ans[i] << "\n";
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

int K;
set<ll> ss;

void dfs(string &S, int cur=0){
    if((int)S.size()){
        if(stoll(S) > (ll)1e10) return;
        else{
            ss.insert(stoll(S));
        }
    }
    for(int i=0; i<=9; i++){
        if(cur == 0 && i == 0) continue;
        if(cur != 0 && abs(S[cur-1]-'0'-i) > 1) continue;
        S.push_back(i+'0');
        dfs(S, cur+1);
        S.pop_back();
    }
}

int main(){
    cin >> K;
    string S="";
    dfs(S);
    ll res;
    for(auto &x: ss){
        K--;
        if(K == 0) res=x;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

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

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
    int n=5;
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i=0;i<s.length();i++)
    {
        s[i]=(((s[i]-'A')+n)%26+'A');
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "string.h"
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for(int i = 1;i < s.size();i++){
		string sPrime = s.substr(0,s.size() - i);
		if(sPrime.size() % 2 != 0) continue;
		if(sPrime.substr(0,sPrime.size()/2) == sPrime.substr(sPrime.size()/2)){
			cout << sPrime.size() << endl;
			return 0;
		}
	}

	return 0;
}

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

int main() {
  int n, x = 0, m, k;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &m, &k);
    while (m % k && m >= k) {
      m -= ((m - m / k * k - 1) / (m / k + 1) + 1) * (m / k + 1);
    }
    x ^= m / k;
  }
  puts(x ? "Takahashi" : "Aoki");
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc123/tasks/abc123_d

import itertools
import collections
import bisect

def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    # big value
    INF = int(1e15)
    x = 0
    y = 0
    AB = []
    for a in A:
        for b in B:
            AB.append(a + b)

    AB.sort(reverse=True)
    AB = AB[:K]
    # print(A)
    # print(B)
    # print(AB)

    ans = []
    for ab in AB:
        for c in C:
            ans.append(ab + c)

    ans.sort(reverse=True)
    for i in range(K):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 161864
from sys import stdin

# 標準入力の受取
sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
l = list(sdi)
l.reverse()
start = len(l)
i = 0
while len(l) - 1 >= i + 1:
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        i = max(i - 2, 0)
        continue
    i += 1
print(start - len(l))


Measured memory_bytes: 3956
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  S = input().strip()
  dp = [0 for _ in range(N)]
  nE = S.count('E')
  nW = 0
  for i in range(N):
    if S[i] == 'E':
      dp[i] = nE - 1 + nW
      nE -= 1
    else:
      dp[i] = nE + nW
      nW += 1
  print(min(dp))


if __name__ == '__main__':
  main()

Measured memory_bytes: 15520
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  string ans;
  stack<int> sta;
  int a=1;
  for(int i=0;i<N;i++){
    while(v[i]>=a){sta.push(a++);ans+='(';}
    int k=sta.top();sta.pop();
    if(k!=v[i]){cout<<":("<<endl;return 0;}
    ans+=')';
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4188
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n,m;
    cin>>n>>m;

    int a[3];
    zero(a);
    map<int,int> m1;
    vector< pair<int,int> > p;

    rep(i,0,m)
    {
        int a,b;
        cin>>a>>b;
        m1[a] = b;
        p.pb(mp(a,b));
    }
    int found = 0;
    if ( n == 1 && m1[1] == 0 )
    {
        cout<<"0"<<endl;
        return;
    }
    rep(i,0,p.size())
    {
        if ( (m1[p[i].ft] != p[i].sd ) || (p[i].ft == 1 && p[i].sd == 0) || (p[i].ft > n ))
        {
            found = 1;
            break;
        }
    }
    if ( found == 1 )
    {
        cout<<"-1"<<endl;
        return;
    }
    rep(i,0,p.size())
    {
        a[p[i].ft-1] = p[i].sd;
    }
    
    if ( a[0] == 0 )
    {
        a[0] = 1;
    }

    rep(i,0,n)
    {
        cout<<a[i];
    }

    cout<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int ma = max(a, b);
	ma = max(ma, c);
	cout << a + b + c - ma << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s,t;
	cin >> s >> t;
	int n = s.size();
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			bool flag = true;
			for(int k = 0;k < n;k++){
				int ni = (i + k) % n;
				int nj = (j + k) % n;
				if(s[ni] != t[nj])flag = false;
			}
			if(flag){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

enum Type {
  MALE,
  FEMALE,
};

Type Query(int idx) {
  cout << idx << endl;
  
  string type;
  cin >> type;
  
  if (type == "Vacant") {
    exit(0);
  }
  
  return type == "Male" ? MALE : FEMALE;
}

int main() {
//  ios_base::sync_with_stdio(false);
//  cin.tie(nullptr);
  
  int N;
  cin >> N;
  
  int lo = 0, hi = N;
  Type lo_type = Query(lo);
  Query(N - 1);
  
  while (lo + 1 < hi) {
    int med = (lo + hi) / 2;
    
    Type med_type = Query(med);
    int dist = med - lo;
    
    if ((dist % 2 == 0 && lo_type == med_type) || (dist % 2 != 0 && lo_type != med_type)) {
      lo = med;
      lo_type = med_type;
    } else {
      hi = med;
    }
  }
  
  Query(lo + 1);
  
  assert(false);
  
  return 0;
}


Measured memory_bytes: 852
function main()
  N,X,Y=map(x->parse(Int,x),split(readline()))
  cnt=zeros(Int,N-1)
  for i=1:N,j=i+1:N
    cnt[min(j-i,abs(X-i)+abs(Y-j)+1)]+=1
  end
  println.(cnt)
end
main()

Measured memory_bytes: 180492