akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std ;

int main()
{
    long long int  a = 1, b = 1, count = 0,ans = 0;
    long long int M = 0,A = 0 ,R = 0,C = 0,H =0 ;
    long long int N ;
    string S ;
    string s ;

    cin >> N ;

    for(int i = 0 ; i < N ; i++)
    {
        cin >> S ;
        s = S[0];
        if(s == "M")
        {
            M++;
            if(M == 1)
            count++;
        }
        else if(s == "A")
        {
            A++;
            if(A==1)
            count++;
        }
        else if(s == "R")
        {
            R++;
            if(R==1) 
            count++;
        }
        else if(s == "C")
        {
            C++; 
            if(C == 1)
            count++;
        }
        else if(s == "H")
        {
            H++; 
            if(H == 1)
            count++;
        }  
    }

    for(int i = 0 ; i < 3 ; i++)
    {
        a*=count - i;
    }

    cout << M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H << endl;
    

}

Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e1 + 10;
int a[7];
int turn[4][7] = { 
	{4, 0, 2, 3, 5, 1},
	{1, 5, 2, 3, 0, 4},
	{3, 1, 0, 5, 4, 2},
	{2, 1, 5, 0, 4, 3} };
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	while (cin >> n)
	{
		if (n == 0) break;
		int a[7] = { 1,2,3,4,5,6 };
		int b[7];
		while (n--)
		{
			memcpy(b, a, sizeof(a));
			string str;
			cin >> str;
			int o = 0;
			if (str == "north") o = 0;
			if (str == "south") o = 1;
			if (str == "west") o = 2;
			if (str == "east") o = 3;
			for (int i = 0; i < 6; i++) a[i] = b[turn[o][i]];
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    long long a , b , c , d ;
    cin >> a >> b >> c >> d ;
    long  L , R , B ;
    R = c + d ;
    L = a + b ;
    if(L > R)
    cout << "Left" ;
    else if(L < R)
    cout << "Right" ;
    else
    cout << "Balanced" ;
    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int a = inint(), b = inint();
		int[] ar = {a+b, a-b, a*b};
		Arrays.sort(ar);
		out.println(ar[2]);
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 23764
n = int(input())
a = list(int(input()) for _ in range(n))

l = sorted(a)

max_num = l[-1]
sec_max = l[-2]

cnt = a.count(max_num)

for x in a:
    if x == max_num and cnt == 1:
        print(sec_max)
    else:
        print(max_num)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<int>h(N,0);
  for(int i=0;i<N;i++)cin>>h[i];
  vector<int>dp(N,INT_MAX);
  dp[0]=0;
  for(int i=0;i<N;i++){
    if(i+1<N)dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    if(i+2<N)dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }

  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		int n=gInt(),m=gInt();
		int[]lang=new int[m];
		Arrays.fill(lang,-1);
		UF uf=new UF(n);
		for(int p:rep(n)) {
			for(int v:rep(gInt())) {
				v=gInt()-1;
				if(lang[v]==-1)
					lang[v]=p;
				uf.connect(lang[v],p);
			}
		}
		System.out.println(uf.groupSize(0)==n?"YES":"NO");
	}
	class UF{
		public int[] uni;
		public UF(int size){
			uni=new int[size];
			Arrays.fill(uni,-1);
		}
		public int root(int t){
			if(uni[t]<0)
				return t;
			return uni[t]=root(uni[t]);
		}
		public boolean connect(int p,int c){
			p=root(p);
			c=root(c);
			if(p==c)
				return false;
			if(uni[p]>uni[c]){
				final int buf=c;
				c=p;
				p=buf;
			}
			uni[p]+=uni[c];
			uni[c]=p;
			return true;
		}
		public boolean isConnected(int a,int b){
			return root(a)==root(b);
		}
		public int groupSize(int t){
			return -uni[root(t)];
		}
	}


	public static void main(String[]$){
		new Main().solve();
		System.out.flush();
	}

	static Scanner s=new Scanner(System.in);

	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t){
		return new Range(f,t);
	}
	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
		int from,to,c;
		Range(int from,int to){
			this.from=from;
			this.to=to;
			this.c=from;
		}
		Range(int n){
			this(0,n-1);
		}
		@Override
		public Iterator<Integer> iterator(){
			return this;
		}
		@Override
		public boolean hasNext(){
			return c<=to;
		}
		@Override
		public int nextInt(){
			return c++;
		}
	}

	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}
	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}
}

Measured memory_bytes: 79684
using System;

namespace _1_4_B {
    class Program {
        static void Main(string[] args) {
            var radius = double.Parse(Console.ReadLine());
            var area = radius * radius * Math.PI;
            var circleLength = radius * 2 * Math.PI;
            Console.WriteLine($"{area:#.######} {circleLength:#.######}");
        }
    }
}



Measured memory_bytes: 15988
from itertools import combinations_with_replacement as cwr

N, M, Q, *Z = map(int, open(0).read().split())
*Z, = zip(*[iter(Z)]*4)

ans = 0
for A in cwr(range(M), N):
    score = 0
    for a, b, c, d in Z:
        if A[b-1]-A[a-1] == c:
            score += d

    if score > ans:
        ans = score

print(ans)


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll a,b,c,d,k;cin>>a>>b>>c>>d>>k;
	ll ans = (c-a) * 60 + d-b;
	cout<<ans - k<<'\n';
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>
#define MOD 1000000007
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, K; cin >> N >> K;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = K;
    int c=K-1;
    for(auto x:G[0]){
        dist[x]=c;
        c--;
        que.push(x);
    }

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(),u=K-2; // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = u;
            u--;
            que.push(nv);
        }
    }
    long long ans=1;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) {
        ans*=dist[v];
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


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

    for(int i = 1; i <= n; i++){
        ans += n-i;
    }
    for(int i = 1; i <= m; i++)
        ans += m-i;

    cout << ans << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] h = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                h[i] = int.Parse(words[i]);
            }
        }

        int before = 0;
        int now = 0;
        for (int i = 0; i < n; i++)
        {
            now = h[i];
            if (now < before)
            {
                Console.WriteLine("No");
                return;
            }
            else if (now == before)
            {
                before = now;
            }
            else
            {
                before = now - 1;
            }

        }

        Console.WriteLine("Yes");
    }
}

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

int main(){
  string N;
  cin >> N;
  char seven = '7';

  for (int i = 0; i < 3; i++) {
    if (N[i] == seven){
      cout << "Yes" << endl;
      return 0;
    }
	}
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    if(s.equals(u)){
      a--;
    }else{
      b--;
    }
    System.out.println(a);
    System.out.println(b);
  }
}


Measured memory_bytes: 21844
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split(''))
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

a = ns()
for i in range(2**3):
    ans = '{}'.format(a[-1])
    for j in range(3):
        if (i >> j) & 1:
            ans = a[-1-(j+1)] + '+' + ans
        else:
            ans = a[-1-(j+1)] + '-' + ans
    if eval(ans) == 7:
        print(ans+'=7')
        break

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

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

int main()
{
    lint nn;cin >> nn;
    lint ans=0;
    vector<vector<lint>> v(11, vector<lint>(11));

    FOR(i,1,nn+1){
        lint l, r, keta = 1;
        lint n = i;
        r = n % 10;

        while (true)
        {
            if (n / 10 == 0 && n < 10)
            {
                l = n;
                break;
            }
            n /= 10;
            keta++;
        }
        v[l][r]++;
    }
    

    REP(i, 11)
    {
        FOR(j,i, 11)
        {
                if(i==j){
                    ans += v[i][j] * v[j][i];
                }else{
                    ans += v[i][j] * v[j][i]*2;
                }
        }
    }

    

    // cout << l<<" "<<r<<" "<<keta << "\n";

    //ans += min(l, r) * ans;

    cout<< ans << "\n";

    return 0;
}

Measured memory_bytes: 256
N=input()
if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9":
    print("hon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9116
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
// clang-format on

constexpr int powint(int a, int b) {
  int c = 1;
  while (b) {
    if (odd(b)) c *= a;
    b >>= 1;
    a *= a;
  }
  return c;
}

main {
  int n, p;
  cin >> n >> p;
  vi a(n);
  rep(i, n) cin >> a[i];

  if (all_of(all(a), even)) {
    cout << (p ? 0 : powint(2, n)) << endl;
  } else {
    cout << powint(2, n - 1) << endl;
  }
}


Measured memory_bytes: 256
import numpy as np
M = np.array([list(map(int, input().split())) for _ in range(3)])
print('Yes' if (np.all(M[0,:]-M[0,0]==M[1,:]-M[1,0]) and
                np.all(M[0,:]-M[0,0]==M[2,:]-M[2,0]) and
                np.all(M[:,0]-M[0,0]==M[:,1]-M[0,1]) and
                np.all(M[:,0]-M[0,0]==M[:,2]-M[0,2])) else 'No')

Measured memory_bytes: 21004
#include <iostream>
using namespace std;
int main() {
	int N;
	int n4 = 0;
	int n2 = 0;
	int other = 0;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp % 4 == 0) {
			n4++;
		}
		else if (tmp % 2 == 0) {
			n2++;
		}
		else {
			other++;
		}
	}

	if (n2 == 0) {
		if (n4+1>= other) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (n4 >= other) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	

	return 0;
}

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

int main() {
 int N , A , Y ;
 string S; 
 cin >> N;
 A = 0;

 for ( int i = 0 ; i < N ; i++ ){
   cin >> S;
   if ( S == "Y" ){
     A = A + 1;
   }
 }

 if ( A == 0 ){
  cout << "Three" << endl;
 }

 else{
  cout << "Four" << endl;
 }

}

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

int main(){
string N;
  cin>>N;
  if(N.at(0)==N.at(1) && N.at(1)==N.at(2)){
  cout<<"Yes"<<endl;
  }
else if(N.at(1)==N.at(2) && N.at(2)==N.at(3)){
  
  cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int dp[11][1<<10][331];
int dpset(int n, int data, int sum);
int main(){
	int n,m;
	memset(dp,-1,sizeof(dp));
	while(cin>>n>>m){
		if(m>330 || n>10){cout<<"0"<<endl;}
		else{cout<<dpset(n,0,m)<<endl;}
	}
	return 0;
}
int dpset(int n, int data, int sum){
	int ans = 0;
	if(dp[n][data][sum]>=0){return dp[n][data][sum];}
	if(sum<0){return 0;}
	if(n == 1){
		if(sum<10 && !(data&(1<<sum))){ans = 1;}
	}
	else{
		for(int i=0; i<10; i++){
			if(!(data&(1<<i))){
				ans+=dpset(n-1,data|(1<<i),sum-i*n);
			}
		}
	}
	dp[n][data][sum] = ans;
	return ans;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



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

    int ans = 0;
    int search = 1;

    for(int i=0;i<n;i++){
        if(search==a[i]){
            search++;
        }else{
            ans++;
        }
    }

    if(ans==n){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
a, b = map(int, input().split())
h = [ 1 ]
for i in range(2, 1000):
    h += [ h[-1] + i ]
for h1, h2 in zip(h, h[1 :]):
    if h1 - a == h2 - b:
        print(h1 - a)
        break


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

class xy {
    private:
        static int max_x, min_x, max_y, min_y;

    public:
        int x, y;

        void set(int _x, int _y) {
            x = _x; y = _y;
            max_x = x > max_x ? x : max_x;
            min_x = x < min_x ? x : min_x;
            max_y = y > max_y ? y : max_y;
            min_y = y < min_y ? y : min_y;
        }
        static void reset() {
            max_x = 0; min_x = 0; max_y = 0; min_y = 0;
        }
        static int width() { return (max_x - min_x) + 1; }
        static int height() { return (max_y - min_y) + 1; }
};
int xy::max_x = 0;
int xy::min_x = 0;
int xy::max_y = 0;
int xy::min_y = 0;

int main() {
    while (true) {
        int N; cin >> N;
        if (N == 0) break;

        xy::reset();
        vector<xy> sq(N);
        for (int i=1; i<N; i++) {
            int n, d; cin >> n >> d;
            sq[i].set(sq[n].x+dx[d], sq[n].y+dy[d]);
        }

        cout << xy::width() << " " << xy::height() << endl;
    }

    return 0;
}

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

using namespace std;

int cmp(pair <int, int > a, pair <int,int > b){
	return a.first < b.first;
}

int memo[3123][3123],N,T;
vector <pair <int,int> > vet;


int Ray(int pos, int tempo){
	if (pos == N)
		return 0;
	if (tempo > T)
		return 0;
	if (pos != 0 && tempo > T-0.5)
		return 0;
	if (memo[pos][tempo] != -1)
		return memo[pos][tempo];

	return memo[pos][tempo]=max(Ray(pos+1,tempo+vet[pos].first)+vet[pos].second, Ray(pos+1,tempo));
}
int main() {
	int aux1,aux2;
	scanf("%d%d", &N, &T);
	memset(memo, -1, sizeof(memo));
	for (int i = 0;i < N;i++) {
		scanf("%d%d", &aux1,&aux2);
		vet.push_back(make_pair(aux1,aux2));
	}
	sort(vet.begin(),vet.end(),cmp);
	printf("%d\n",Ray(0,0));

	return 0;
}

Measured memory_bytes: 38528
N, M = map(int, input().split())
sc = [None]*M
for i in range(M):
    sc[i] = tuple(map(int, input().split()))

num = [None]*N
for i in range(M):
    if num[sc[i][0]-1] != None:
        if num[sc[i][0]-1] != sc[i][1]:
            print(-1)
            quit()
    num[sc[i][0]-1] = sc[i][1]

if num[0]==None:
    if N!=1:
        num[0] = 1
    else:
        num[0] = 0

if num[0] == 0 and N != 1:
    print(-1)
    quit()

for i in range(1, N):
    if num[i] == None:
        num[i] = 0


num = map(str,num)
ans = "".join(num)
if int(ans) == 0 and N != 1:
    print(-1)
    quit()
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vector<vector<pair<ll, bool>>> G(100005);
bool visit[100005];
bool color[100005];

void bfs(ll s){
    queue<ll> q;
    visit[s] = true;
    q.push(s);
    color[s] = false;
    while(!q.empty()){
        ll u = q.front(); q.pop();
        for(auto v : G[u]){
            if(visit[v.first]) continue;
            if(v.second) color[v.first] = color[u];
            else color[v.first] = !color[u];
            q.push(v.first);
            visit[v.first] = true;
        }
    }
}

int main(){
    ll n; cin >> n;
    ll u,v,w;
    rep(i,n-1){
        cin >> u >> v >> w; u--; v--;
        G[u].push_back(make_pair(v,w%2==0));
        G[v].push_back(make_pair(u,w%2==0));
    }
    bfs(0);
    rep(i,n) cout << color[i] << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int bit_count(int value) {
	return value == 0 ? 0 : value % 2 + bit_count(value >> 1);
}
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> cards(n); for (auto& c : cards) std::cin >> c;
	std::vector<bool> can_make(1 << n, false);
	for (auto i = 0; i < 1 << n; ++i) {
		if (!can_make[i]) {
			int sum = 0;
			for (auto j = 0; j < n; ++j) if ((i & (1 << j)) != 0) {
				sum += cards[j];
			}
			can_make[i] = sum == k;
		}
		if (can_make[i]) {
			for (auto j = 0; j < n; ++j) {
				can_make[i | (1 << j)] = can_make[i | (1 << j)] || can_make[i];
			}
		}
	}
	int max_bit = 0;
	for (auto i = 0; i < can_make.size(); ++i) if (!can_make[i]) {
		max_bit = std::max(max_bit, bit_count(i));
	}
	std::cout << n - max_bit << std::endl;
}


Measured memory_bytes: 3232
#include <cstdio>
#include <vector>
using namespace std;

int main() {
    int n, q, op, t, x;
    scanf("%d %d", &n, &q);
    vector<vector<int> > v(n);
    while (q--) {
        scanf("%d %d", &op, &t);
        if (op == 0) {
            scanf("%d", &x);
            v[t].emplace_back(x);
        } else if (op == 1) {
            if (!v[t].empty()) printf("%d", v[t][0]);
            for (int i = 1; i < v[t].size(); i++) printf(" %d", v[t][i]);
            printf("\n");
        } else {
            v[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct bipartite_matching{
    int n, x, y;
    VVI e;
    VI match;
    vector<bool> used;

    void init(int a, int b){
        x = a;
        y = b;
        n = x + y;
        e.resize(n);
        match.resize(n);
        used.resize(n);
    }

    void add_edge(int u, int v){
        e[u].push_back(v + x);
        e[v + x].push_back(u);
    }

    bool dfs(int v){
        used[v] = true;
        for (int u : e[v]){
            int w = match[u];
            if (w < 0 || (!used[w] && dfs(w))){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int calc_matching(){
        int res = 0;
        fill(ALL(match), -1);
        REP(v,n){
            if (match[v] < 0){
                used.assign(n, 0);
                if (dfs(v)) res++;
            }
        }
        return res;
    }
};

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    VI d;
    int ans = 0;
    REP(i,n){
        int x = in(), y = in();
        int p = x - y;
        if (abs(p) <= a || (abs(p) >= b && abs(p) <= 2 * a)) ans++;
        else d.push_back(p);
    }

    int m = d.size();
    bipartite_matching match;
    match.init(m, m);
    REP(i,m) REP(j,m) {
        if (d[i] < 0) continue;
        if (d[j] > 0) continue;
        int p = d[i] + d[j];
        if (abs(p) <= a || (abs(p) >= b && abs(p) <= 2 * a)){
            match.add_edge(i, j);
        }
    }

    // REP(i,m) cout << d[i] << endl;

    ans += match.calc_matching();
    cout << ans << endl;

    // REP(i,m){
    //     cout << match.match[i] - m << endl;
    // }

    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
  string s ,t;
  int n;
  string ne;

  cin >> n >> s >> t;

  for (int i = 0; i < n; i++){
    ne += s[i];
    ne += t[i];
  } 

  cout << ne << endl;

  return 0;
}

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

int main(void)
{
    int64_t S, W;

    std::cin >> S >> W;

    std::cout << (S > W ? "safe" : "unsafe") << std::endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll r, g;
  cin >> r >> g;
  print(2 * g - r);
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VVI a(n, VI(n, 0));
    REP(i, n) {
        REP(j, n) {
            char c;
            cin >> c;
            a[i][j] = (c == '#' ? 1 : 0);
        }
    }

//    不可能
    bool f = false;
    REP(i, n) {
        REP(j, n) {
            if (a[i][j] == 1) {
                f = true;
            }
        }
    }
    if (f == false) {
        cout << -1 << endl;
        return 0;
    }

//    最初からok
    f = true;
    REP(i, n) {
        REP(j, n) {
            if (a[i][j] == 0) {
                f = false;
            }
        }
    }
    if (f) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;

//    横一列の存在確認

    REP(i, n) {
        f = true;
        REP(j, n) {
            if (a[i][j] == 0) {
                f = false;
            }
        }
        if (f) {
            break;
        }
    }
    if (!f) {
        VI t(n);
        REP(i, n) {
            t[i] = accumulate(ALL(a[i]), 0);
        }
        ans += n - *max_element(ALL(t));

        bool ff = false;
        REP(k, n) {
            if (*max_element(ALL(t)) == t[k]) {
                f = false;
                REP(i, n) {
                    if (a[i][k] == 1) {
                        f = true;
                    }
                }
                if (f) {
                    ff = true;
                }
            }
        }
        if (!ff) {
            ans++;
        }

    }

    REP(j, n) {
        f = true;
        REP(i, n) {
            if (a[i][j] == 0) {
                f = false;
            }
        }
        if (!f) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main () { 
  int h, w;
  cin >> h >> w;
  vector<string> squ(h + 2);
  for (int i = 0; i < w + 2; i++)
    squ.at(0) += '.';
  for (int i = 1; i < h + 1; i++) {
    cin >> squ.at(i);
    squ.at(i) = '.' + squ.at(i) + '.';
  }
  for (int i = 0; i < w + 2; i++)
    squ.at(h + 1) += '.';
 
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      if (squ.at(i).at(j) == '.') {        
        int x = 0;
        for (int k = i - 1; k < i + 2; k++) {
          for (int l = j - 1; l < j + 2; l++) {
            if (squ.at(k).at(l) == '#')
              x++;
          }
        }
        cout << x;
      }
      else {
        cout << "#";
      }
      if (j == w)
        cout << endl;
    }
  }
}

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

int main(){
  int N;
  cin>>N;
  vector<int> b(N),an(0);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }
  int c=1;
  int n=N;
  for(int i=0;i<N;i++){
    for(int j=n-1;j>=0;j--){
      c=1;
      if(b.at(j)==j+1){
        for(int k=j;k<n-1;k++){
          b.at(k)=b.at(k+1);
        }
        c=0;
        an.push_back(j+1);
        b.at(n-1)=0;
        n--;
        break;
      }
    }
    if(c==1)break;
  }
  if(c==1){
    cout<<-1<<endl;
  }else{
    for(int i=N-1;i>=0;i--){
      cout<<an.at(i)<<endl;
    }
  }
    
    
          
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
string f,g;
int a,b;
cin>>f;
if (f[0]=='A')a=10;
else if (f[0]=='B')a=11;
else if (f[0]=='C')a=12;
else if (f[0]=='D')a=13;
else if (f[0]=='E')a=14;
else if (f[0]=='F')a=15;
cin>>g;
if (g[0]=='A')b=10;
else if (g[0]=='B')b=11;
else if (g[0]=='C')b=12;
else if (g[0]=='D')b=13;
else if (g[0]=='E')b=14;
else if (g[0]=='F')b=15;

if (a>b)cout<<">";
    else if (a<b)cout<<"<";
    else cout<<"=";

 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    string B = "bust", W = "win";
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22){
        cout << B << endl;
    }
    else{
        cout << W << endl;
    }
    
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
    int d, t, s;
    cin >> d >> t >> s;

    if (d / s > t) {
        cout << "No" << endl;
    } else if (d / s == t && d % s != 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
	int n, A[10101], h,ans = 1;
	string S;
	//cin >> S >> n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	sort(A, A + n);
	h = A[0];
	for (int i = 1; i < n; i++)
		if (A[i] != h) {
			h = A[i];
			ans++;
		}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void solve()
{
    int n, l;
    cin >> n >> l;
    vector<int> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    deque<pair<int, int>> dq;
    for (int i = 0; i < n; i++)
    {
        deque<pair<int, int>> ndq(dq);
        if (!dq.empty())
        {
            for (auto p : dq)
            {
                if (p.first >= as[i])
                {
                    ndq.pop_front();
                }
                else
                {
                    break;
                }
            }
        }
        ndq.push_front(make_pair(as[i], i));
        if (i + 1 >= l)
        {
            cout << ndq.back().first << " \n"[i == n - 1];
        }
        if (ndq.back().second == i - l + 1)
        {
            ndq.pop_back();
        }
        swap(dq, ndq);
    }
}

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



Measured memory_bytes: 6788
a,b = map(int,input().split())

a_list = [i for i in range(1,a+1)]
b_list = [i for i in range(1,b+1)]


a_len = len(a_list)
b_len = len(b_list)


if a_len < b_len:
    print(a_len)
elif a_len == b_len:
    print(a_len)
elif a_len>b_len:
    ans = a_len-1
    print(ans)

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

int main(){
    int n,a;
    set<int> s;
    int ans;

    cin >>n;
    for (int i = 0; i < n; i++){
        cin >> a;
        s.insert(a);
    }
    cout << s.size() <<endl;
    //cout <<fixed<<setprecision(10)<< ans <<endl;
    
    return 0;
}


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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl

string S;





int main()
{

	cin >> S;
	int N = S.length();
	int min1=-1,min0=-1;
	int offset = N%2-1;
	REP(i,N/2+1){
		if((S[N/2-i+offset]=='1')||(S[N/2+i]=='1')){
			min1 = i;
			break;
		}
	}
	REP(i,N/2+1){
		if(S[N/2-i+offset]=='0'||S[N/2+i]=='0'){
			min0 = i;
			break;
		}
	}

	int mi = max(min0,min1);
	if(min0==-1||min1==-1)
		cout << N;
	else
		cout << N/2+mi;
}



Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

vector<ll> table;

ll dp(ll n)
{
  if(table.at(n)>0) return table.at(n);
  if(n==0) return 1;
  if(n==1) return 1;
  if(n==2) return 2;
  
  table.at(n)=dp(n-1)+dp(n-2)+dp(n-3);
  return table.at(n);
}


int main() 
{
  table=vector<ll>(31,0);
  while(true)
  {
    ll N; cin>>N;
    if(N==0) break;
    cout<<(((dp(N)-1)/10+1)-1)/365+1<<endl;
  } 
  /*
  rep(i,31)
  {
    if(i!=0) cout<<" ";
    cout<<table.at(i);
  }
  cout<<endl;
  */
  return 0;
}


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

int R;

int main(){
	cin>>R;
	if(R<1200){
		cout<<"ABC"<<endl;
	}else if((1200<=R)&&(R<2800)){
		cout<<"ARC"<<endl;
	}else if(2800<=R){
		cout<<"AGC"<<endl;
	}
}

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

// D - Line++
#define MAX 2000
int ans[MAX];
int N, X, Y;

void calc(int nowPoint) {
    if (nowPoint == N) {
        return;
    }
    for (int i = nowPoint + 1; i < N; i++) {
        // cout << "nowPoint:" << nowPoint << ", X:" << X << endl;
        // cout << "i:" << i << ", Y:" << Y << endl;

        // cout << "(" << nowPoint << ", " << i << ")";
        // cout << "(" << nowPoint + 1 << ", " << i + 1 << ")";

        // これだと戻るケースが考慮されていない X -> Y - 1 みたいな
        // 開始地点 / 終了地点が X Yを跨ぐ
        if (nowPoint <= X && Y <= i) {
            // cout << " A: " << (X - nowPoint) + (i - Y) + 1;
            ans[(X - nowPoint) + (i - Y) + 1]++;

        // 開始地点 / 終了地点が X Yの間ではない
        } else if (i <= X || Y <= nowPoint) {
            // cout << " B: " << i - nowPoint;
            ans[i - nowPoint]++;

        // 開始地点 or 終了地点が X Yの間にあるとき
        } else {
            // ちょっと一旦雑に計算
            int minRoute = i - nowPoint;
            minRoute = min(abs(nowPoint - X) + 1 + abs(i - Y) ,minRoute);
            // cout << " : " << minRoute;
            // 開始地点がX 以上である場合
            /*if (nowPoint > X) {
                minRoute = ((nowPoint - X) + 1 + abs(i - Y) ,minRoute)
            } else {
                minRoute = (abs(nowPoint - X) + 1 + abs(i - Y) ,minRoute)
            }*/
            ans[minRoute]++;
        }
        // cout << endl;
    }
    calc(nowPoint + 1);
}

int main() {
    cin >> N >> X >> Y;
    X--;
    Y--;
    // cout << "X:" << X << ", Y:" << Y << endl;
    calc(0);
    for (int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c=Counter(s)
max_cnt=0
for key in c:
    max_cnt=max(max_cnt,c[key])
ans=[]
for key in c:
    if c[key]==max_cnt:
        ans.append(key)
    else:
        continue
ans.sort()
for item in ans:
    print(item)


Measured memory_bytes: 35572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {

	int n0 = (int)'A';
	int n;
	string s;
	cin >> n >> s;
	for (ll i = 0; i < s.size(); i++)
	{
		if ((int)s[i] - n0 + n >= 26) {
			s[i] = (char)((int)s[i] + n - 26);
		}
		else {
			s[i] = (char)((int)s[i] + n);
		}
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

const long long MOD = 1000000007;

int main() {
    long long N, K;
    cin >> N >> K;

    vector<long long> ascSums(N + 1, 0LL);
    vector<long long> descSums(N + 1, 0LL);
    ascSums[0] = 0;
    descSums[0] = N;
    for (long long i = 1; i < N + 1; ++i) {
        ascSums[i] = ascSums[i - 1] + i;
        descSums[i] = descSums[i - 1] + (N - i);
        ascSums[i] %= MOD;
        descSums[i] %= MOD;
    }

    long long patterns = 0;
    for (long long k = K; k <= N + 1; ++k) {
        patterns += descSums[k - 1] - ascSums[k - 1] + 1;
        patterns %= MOD;
    }
    if (patterns < 0) {
        patterns += MOD;
    }
    cout << patterns << endl;
    return 0;
}


Measured memory_bytes: 6424
// #pragma GCC optimize "trapv"

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define MAP map<ll ,ll>
#define UMAP unordered_map<ll , ll>
#define endl "\n"
#define SET set<ll> 
#define SETC set<char>
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
#define time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define ll long long int
const ll INF = 1e13+7;
const ll mod = 1e9+7;

vvll multiply(vvll a , vvll &b ){
    int n = a.size();
    vvll res(n , vll(n , 0));
    
    FOR(i , 0 , n-1){
        FOR(j , 0 , n-1){
            FOR(k , 0 , n-1){
                res[i][j] += (a[i][k] * b[k][j])%mod;
                res[i][j] %= mod;
            }
        }
    }

    return res;
}

vvll power(vvll &mat , ll exp ){

    if(exp == 1){
        return mat;
    }

    vvll sq = power(mat , exp/2); 

    if(exp & 1){
       return multiply(multiply(mat , sq) , sq);
    }
    else{
        return multiply(sq , sq);
    }
}

ll doSome(vvll &adj , ll k , int n){

    vvll ak = power(adj , k);
    ll ans = 0 ;
    FOR(i , 0 , n-1){
        FOR(j , 0 , n-1){
            ans = (ans + ak[i][j])%mod;;
        }
    }

    return ans;
}

void solv(){
    ll n , k ;
    cin >> n >> k;

    vvll adj(n , vll(n)) ;

    FOR(i , 0 , n-1){
        FOR(j , 0 , n-1){
            cin >> adj[i][j];
        }
    }

    cout << doSome(adj , k , n) << endl;
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




Measured memory_bytes: 3720
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, K = MAP()
A = LIST()

A.sort()
ans = sum(A[:K])
print(ans)


Measured memory_bytes: 9420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define mod 1000000007
#define ALL(v) v.begin(),v.end()
#define vi vector<int>
#define vll vector<ll>
using namespace std;
typedef long long ll;


int n,t;

main()
{
        cin>>n>>t;
        vi v(n);
        rep(i,n)cin>>v[i];
        int ans=t;
        for(int i=1;i<n;i++)ans+=min(t,v[i]-v[i-1]);
        cout<<ans<<endl;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
cnt = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt.append("1")
    else:
        cnt.append("0")
a = "".join(cnt).split("0")
ans = []
for j in a:
    ans.append(len(j))
print(max(ans))

Measured memory_bytes: 14252
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	w := io.ScanStrings(n)

	existWordMap := map[string]bool{
		w[0]: true,
	}
	lastChar := w[0][len(w[0])-1]
	for _, word := range w[1:] {
		if existWordMap[word] || word[0] != lastChar {
			fmt.Println("No")
			return
		}
		existWordMap[word] = true
		lastChar = word[len(word)-1]
	}
	fmt.Println("Yes")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2204