akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
using namespace std;
int n,m;
char a[505][505];
char b[505][505];
char s[505][505];
int main()
{
    //freopen("input","r",stdin);  freopen("output","w",stdout);
    scanf("%d %d\n",&n,&m);
    m--;
    for(int i=1;i<=n;i++&&scanf("\n"))
        for(int j=0;j<=m;j++)
            scanf("%c",&s[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<m;j++)
        {
            a[i][j]=s[i][j];
            b[i][j]=s[i][j];
            if(i%2==0)a[i][j]='#';
            else b[i][j]='#';
        }
    for(int i=1;i<=n;i++)
    {
        a[i][0]='#';
        a[i][m]='.';
        b[i][0]='.';
        b[i][m]='#';
    }
    for(int i=1;i<=n;i++)
        printf("%s\n",a[i]);
    printf("\n");
    for(int i=1;i<=n;i++)
        printf("%s\n",b[i]);
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      
      int H = sc.nextInt();
      int A = sc.nextInt();
      System.out.printf("%d", ((H - 1) / A + 1));
      sc.close();
      
    }
}

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

int main(){
    int X; cin >> X;
    int tmp=X%100;
    int cnt=X/100;
    
    if(cnt*5<tmp) cout << "0";
    else cout << "1";
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int n,a,b,c,d;


int countOfChargeCoin(int charge){
  int count=0;
  count+=charge/500;
  charge%=500;
  count+=charge/100;
  charge%=100;
  count+=charge/50;
  charge%=50;
  count+=charge/10;
  return count;
}

void solve(){
  int m=1<<27;
  int mina,minb,minc,mind;
  REP(i,a+1)REP(j,b+1)REP(k,c+1)REP(l,d+1){
    int charge=i*10+j*50+k*100+l*500-n;
    if(charge<0)continue;
    int tmpm=countOfChargeCoin(charge)-i-j-k-l;
    if(m>tmpm){
      m=tmpm;
      mina=i;
      minb=j;
      minc=k;
      mind=l;
    }
  }
  if(mina>0)cout<<"10 "<<mina<<endl;
  if(minb>0)cout<<"50 "<<minb<<endl;
  if(minc>0)cout<<"100 "<<minc<<endl;
  if(mind>0)cout<<"500 "<<mind<<endl;
}

int main(){ _;
  bool first=true;
  while(cin>>n,n!=0){
    if(!first)cout<<endl;
    first=false;
    cin>>a>>b>>c>>d;
    solve();
  }
}

Measured memory_bytes: 1196
s = input()
atgc = set(['A', 'T', 'G', 'C'])
maxcnt = 0
cnt = 0
for i in s:
  if i in atgc:
    cnt += 1
    if cnt > maxcnt:
      maxcnt = cnt
  else:
    cnt = 0
print(maxcnt)

Measured memory_bytes: 9124
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
char s[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%s",s);int n=strlen(s);
    int w;
    scanf("%d",&w);
    for(int i=0;i<n;i+=w)
		printf("%c",s[i]);
	puts("");	
	return 0;
}
 

Measured memory_bytes: 384
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.reverse()
ans=0
for i in range(n):
  d=ab[i][0]+ans
  if d%ab[i][1]!=0:
    ans+=ab[i][1]-d%ab[i][1]
print(ans)

Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MAX = 10000;

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  ll ans = INF;

  reps1(i, MAX+1) {
    ll sum = 0;
    rep(j, n) {
      sum += pow(x[j]- i, 2);
    }
    chmin(ans, sum);
  }

  cout << ans << endl;


  return 0;
}


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

int main() {
    int a, b, n;
    while (scanf("%d%d%d", &a, &b, &n) != EOF) {
        int ans = 0;
        a %= b;
        rep (_, n) {
            a *= 10;
            ans += a/b%10;
            a %= b;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
from collections import Counter
from itertools import tee

N = int(input())
D = list(map(int, input().split(" ")))
R = 998244353


def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


def is_leap(distance):
    cc = Counter(distance)
    for x, y in pairwise(sorted(cc.keys())):
        if y - x > 1:
            return True
    else:
        return False


if D[0] > 0:
    """頂点1が根ではない"""
    print(0)
elif not all(D[1:]):
    """連結グラフではない"""
    print(0)
elif is_leap(D):
    """連結グラフではない"""
    print(0)
else:
    ans = 1
    c = Counter(D[1:])
    edges = [t[1] for t in sorted(c.items())]
    for d, e in pairwise(edges):
        ans *= pow(d, e)
        ans = ans % R
    print(ans % R)


Measured memory_bytes: 26840
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll cnt(ll x, ll y, ll z) {
    if (x % 2 != 0 || y % 2 != 0 || z % 2 != 0) return 0;
    if (x == y && y == z) return -1;

    return cnt((x + y) / 2, (y + z) / 2, (z + x) / 2) + 1;
}

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    cout << cnt(x, y, z) << endl;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
fridge_prices = list(map(int, input().split()))
microwave_prices = list(map(int, input().split()))
ans = min(fridge_prices)+min(microwave_prices)
for i in range(m):
    x,y,c = map(int, input().split())
    tmp_cost = fridge_prices[x-1]+microwave_prices[y-1] - c
    ans = min(tmp_cost, ans)
print(ans)

Measured memory_bytes: 18488
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
        else:
            self.p[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

n, m = map(int, input().split())
p = [int(v) for v in input().split()]

ds = DisjointSet()

for pi in p:
    ds.makeSet(pi)

for i in range(m):
    x,y = map(int, input().split())
    ds.unite(p[x-1], p[y-1])

ans = 0
for i,pi in enumerate(p):
    if ds.same(pi, i+1):
        ans += 1

print(ans)

Measured memory_bytes: 26844
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

l=[0]*(N+1)
temp=[]

for _ in range(M):
    a,b=map(int,input().split())
    l[a]=max(l[a],b)
    if a==1:
        temp.append(b)

for item in temp:
    if l[item]==N:
        print("POSSIBLE")
        exit()
        
print("IMPOSSIBLE")

Measured memory_bytes: 11800
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T> 
const T& clamp(const T &t, const T &low, const T &high) { 
    if(t < low) {
        return low;
    } else if(high < t) {
        return high;
    } else {
        return t;
    }
}

template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i) continue;
        ll a = i, b = N / i;
        DEBUG(a, b);
        b--;
        if(b > a) ans += b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;

        ll i,j,k,x,y,z,m,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
        string s,s1,str;
        map<ll,ll>MAP;
        vector<ll>v;

        cin>>n>>k>>c;

        a=n/k;
        if(n%k!=0)
            a++;

        cout<<a*c;
        nl;




}


Measured memory_bytes: 3636
#include <stdio.h>

int n, q, mx1, my1, mx2, my2, x1[10000], y1[10000], x2[10000], y2[10000], imos[10001];

int main()
{
	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &q);

		if (n == 0 && q == 0) break;

		mx1 = 10001;
		my1 = 10001;
		mx2 = -1;
		my2 = -1;

		for (int i = 0; i < n; i++)
		{
			scanf("%d", &x1[i]); mx1 = mx1 < x1[i] ? mx1 : x1[i];
			scanf("%d", &y1[i]); my1 = my1 < y1[i] ? my1 : y1[i];
			scanf("%d", &x2[i]); mx2 = mx2 > x2[i] ? mx2 : x2[i];
			scanf("%d", &y2[i]); my2 = my2 > y2[i] ? my2 : y2[i];
		}

		int ret1 = 0;
		int ret2 = 0;

		for (int i = my1; i < my2; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (y1[j] <= i && i < y2[j])
				{
					imos[x1[j]]++;
					imos[x2[j]]--;
				}
			}

			int sum = 0;

			for (int j = mx1; j <= mx2; j++)
			{
				if ((sum == 0 && sum + imos[j] > 0) || (sum > 0 && sum + imos[j] == 0)) ret2++;

				sum += imos[j]; imos[j] = 0;

				if(sum > 0) ret1++;
			}
		}

		for (int i = mx1; i < mx2; i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (x1[j] <= i && i < x2[j])
				{
					imos[y1[j]]++;
					imos[y2[j]]--;
				}
			}

			int sum = 0;

			for (int j = my1; j <= my2; j++)
			{
				if ((sum == 0 && sum + imos[j] > 0) || (sum > 0 && sum + imos[j] == 0)) ret2++;

				sum += imos[j]; imos[j] = 0;
			}
		}

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

		if (q == 2)
		{
			printf("%d\n", ret2);
		}
	}

	return 0;
}

Measured memory_bytes: 2796
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

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


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

    vector<int> grid(H * W);
    int idx = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a[i]; j++){
            grid[idx] = i + 1;
            idx++;
        }
    }
    vector<vector<int>> v(H, vector<int>(W));
    idx = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i % 2 == 0){
                v[i][j] = grid[idx];
            }else{
                v[i][W - j - 1] = grid[idx];
            }
            idx++;
        }
    }
    for(vector<int> row: v){
        print(row);
    }
    return 0;
}


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


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

int main() {
  int N;
  cin >> N;
  vector<int> swc(N);
  for (int i = 0; i < N; i++) {
    cin >> swc.at(i);
  }
  int x = 0;
  for (int i = 0; i < N; i++) {
    int x = swc.at(x) - 1;
    if (x == 1) {
      cout << i+1 << endl;
      break;
    }
    if (i == N-1) {
      cout << -1 << endl;
    }
  }    
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for (ll j = k; j <= n + 1; j++) {
    ll tmp = j * (n - j + 1) + 1;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,m=mii()
arra=limii()
arrb=limii()

ans=min(arra)+min(arrb)

for i in range(m):
    x,y,c=mii()
    ans = min(ans, arra[x-1]+arrb[y-1]-c)
print(ans)



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

struct Node {
  bool visited = false;
  int cnt = 0;
  std::vector<int> adj;
};

void dfs(std::vector<Node>& nodes, int idx, int cost) {
  if (nodes.at(idx).visited)
    return;
  
  nodes.at(idx).visited = true;
  
  nodes.at(idx).cnt += cost;
  
  for (auto &&i : nodes.at(idx).adj) {
    dfs(nodes, i, nodes.at(idx).cnt);
  }
}

int main() {
  int N, Q;
  std::cin >> N >> Q;
  
  std::vector<Node> nodes(N+1);
  
  for (int i=1, a, b; i<N; ++i) {
    std::cin >> a >> b;
    nodes.at(a).adj.push_back(b);
    nodes.at(b).adj.push_back(a);
  }
  for (int i=0, id, cnt; i<Q; ++i) {
    std::cin >> id >> cnt;
    nodes.at(id).cnt += cnt;
  }
  
  dfs(nodes, 1, 0);
  
  for (int i=1; i<=N; ++i) {
    std::cout << nodes.at(i).cnt;
    
    if (i != N)
      std::cout << " ";
    else
      std::cout << std::endl;
  }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int sum = 0;
  rep(i, N) sum += A[i];

  vector<int> d;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      d.eb(i);
      if (sum / i != i) {
        d.eb(sum / i);
      }
    }
  }

  sort(rall(d));

  rep(i, sz(d)) {
    int mod = d[i];
    vector<int> a;
    rep(j, sz(A)) if (A[j] % mod) a.eb(A[j] % mod);

    if (sz(a) == 0) {
      cout << mod << endl;
      return 0;
    }

    sort(all(a));
    ll m = 0, p = 0;
    rep(j, sz(a)) p += (mod - a[j]);

    rep(j, sz(a)) {
      m += a[j];
      p -= (mod - a[j]);
      // if (m <= K && p <= K) {
      if (m == p && m <= K) {
        cout << mod << endl;
        return 0;
      }
    }
  }

  cout << "-1" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>

using ll = long long;

int main() {

    int N, X;
    std::cin >> N >> X;
    if (X == 1 || X == 2 * N - 1) {
        std::cout << "No" << std::endl;
    }
    else {
        std::cout << "Yes" << std::endl;

        int step = 1;
        for (int i = 0; i < N - 2; i++) {
            if (step == X - 1)step += 3;
            std::cout << step << std::endl;
            step++;
        }
        std::cout << X - 1 << std::endl;
        std::cout << X << std::endl;
        std::cout << X + 1 << std::endl;
        for (int i = 0; i < N - 2; i++) {
            if (step == X - 1)step += 3;
            std::cout << step << std::endl;
            step++;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;


ll n;
ll a[100010];
ll l[100010];

ll flr(ll x){
    return max((ll)0,min((ll)(n+1),x));
}

int main(void){
    cin>>n;
    rep(i,n){
        cin>>a[i+1];
        l[a[i+1]]=i+1;
    }

    set<ll> s;
    s.insert(n+2);
    s.insert(n+1);
    s.insert(-1);
    s.insert(-2);
    
    s.insert(l[n]);
    ll c,w,x,y,z;
    long long ans=0;
    rep(i,n-1){
        ll ii=n-1-i;
        ll j=l[ii];
        s.insert(j);
        auto it=s.find(j);
        it--;
        it--;
        w=flr(*it);
        it++;
        x=flr(*it);
        it++;
        c=flr(*it);
        it++;
        y=flr(*it);
        it++;
        z=flr(*it);
        
        ans+=ii*((x-w)*(y-c)+(c-x)*(z-y));
    }
    cout<<ans;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    char s;
    cin>>s;
    s+=1;
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N,odd=0;
	long long A[100000];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 1)odd++;
	}

	if (odd % 2 == 1) cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 1024
def main():
    n, m, l = map(int, input().split())
    A, B = [], []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for _ in range(m):
        B.append(list(map(int, input().split())))
    C = [[0] * l for _ in range(n)]
    for i in range(n):
        for j in range(l):
            C[i][j] = sum(A[i][k] * B[k][j] for k in range(m))
    for line in C:
        print(' '.join(map(str, line)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6644
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  sc.Scan()
  k, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  s := sc.Text()

  for i, c := range s {
    if i == k - 1 {
      c += 'a' - 'A'
    }
    fmt.Print(string(c))
  }

  fmt.Println()

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    for(int i = 0;i < N;i++){cin >> T[i];sum += T[i];}
    cin >> M;
    for(int i = 0;i < M;i++){
        int a,b;
        cin >> a >> b;
        cout << sum - T[a-1] + b << endl;
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, h;
  cin >> n >> h;
  
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i);
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  
  int damage = 0, ans = 0;
  for(int i = n - 1; i >= 0; i--){
    if(a.at(n - 1) <= b.at(i)){
      damage += b.at(i);
      ans++;
    }
    else break;
    if(damage >= h){
      cout << ans << "\n";
      return 0;
    }
  }
  
  ans += ((h - damage) + a.at(n - 1) - 1) / a.at(n - 1);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  string a,b;
  cin >>a>>b;
  int result = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == b[i]) { result++; }
  }
  
  cout << result <<endl;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<int> a(N+1, 0);
	for (int i=1; i<=N; i++)
		cin >>a.at(i);
	int S=0;
	for (int i=1; i<=N; i++)
		if (i==a.at(a.at(i)))
			S++;
	cout <<S/2 <<endl;
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  int l[n];

  for(int i = 0; i < n; i++){
      cin >> l[i];
  }

  int kazu;
  kazu = 0;
  
  sort(l, l + n);
  for(int i = 0; i < n -1; i++){
        for(int j = i+1; j < n; j++){
              for(int k = j+1; k < n; k++){
        if( (l[i]+l[j] > l[k]) && (l[i] != l[j]) && (l[j] != l[k]) ){
          kazu += 1;
      }
        }
 
      }
  }

  cout << kazu << endl;
  }

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

#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

int main(void) {
	int i, flag = 0;
	char s[5];
	cin >> s;
	rpt(i, 4) {
		if (s[i] == s[i + 1]) {
			cout << "Bad";
			flag = 1;
			break;
		}
	}

	if (flag == 0)
		cout << "Good";

	return 0;
}

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

int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        string s;
        cin>>s;
        if(s[a]!='-')
        {
            printf("No\n");
            continue;
        }
        if(s.size()!=a+b+1)
        {
            printf("No\n");
            continue;
        }
        else
        {
            int flag=0;
            for(int i=0; i<a; i++)
            {
                if(s[i]<'0'||s[i]>'9')
                {
                    flag=1;
                    break;
                }
            }
            if(!flag)
            {
                for(int i=a+1; i<s.size(); i++)
                {
                    if(s[i]<'0'||s[i]>'9')
                    {
                        flag=1;
                        break;
                    }
                }
            }
            if(flag)
                printf("No\n");
            else
                printf("Yes\n");
        }
    }
}


Measured memory_bytes: 256
parseline(str=readline()) = parse.(Int, split(str))
function Line()
    N, X, Y = parseline()
    ans = zeros(Int, N-1)
    for i in 1:N-1
        for j in i+1:N
            d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(X-j))
            ans[d] += 1
        end
    end
    for a in ans
        println(a)
    end
end
Line()

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  int k, x;
  cin >> k >> x;
  rep(i, x - k + 1, x + k - 2) cout << i << " ";
  cout << x + k - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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 ** 18
MOD = 10 ** 9 + 7

def dijkstra(N: int, nodes: list, src: int) -> list:
    """ ダイクストラ高速化版(頂点数, 隣接リスト(0-indexed), 始点) """
    from heapq import heappush, heappop

    # 頂点[ある始点からの最短距離]
    res = [INF] * N
    # スタート位置
    que = [src]
    res[src] = 0
    # キューが空になるまで
    while len(que) != 0:
        # 距離*N + 現在のノード
        cur = heappop(que)
        # 距離とノードに分ける
        dist = cur // N
        cur %= N
        # 出発ノードcurの到着ノードでループ
        for nxt, cost in nodes[cur]:
            # 今回の経路のが短い時
            if dist + cost < res[nxt]:
                res[nxt] = dist + cost
                # 距離*N+ノード番号 の形でキューに詰める
                heappush(que, (dist+cost)*N+nxt)
    # ノードsrcからの最短距離リストを返却
    return res

N = INT()
nodes = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = MAP()
    a -= 1; b -= 1
    nodes[a].append((b, c))
    nodes[b].append((a, c))

Q, K = MAP()
K -= 1
res = dijkstra(N, nodes, K)
for i in range(Q):
    x, y = MAP()
    x -= 1; y -= 1
    ans = res[x] + res[y]
    print(ans)


Measured memory_bytes: 43904
function main(input) {
  const s = input.split(' ')
  
  const n1 = parseInt(s[0], 10)
  const n2 = parseInt(s[1], 10)
  const n3 = parseInt(s[2], 10)
  
  if (n1 < n3) {
    console.log(n3 <= n2 ? "Yes" : "No")
  } else if (n1 > n3) {
    console.log(n3 >= n2 ? "Yes" : "No")
  } else {
    console.log("Yes")
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rg register
#define f(i,a,b) for(rg int i=a;i<=b;++i)
#define df(i,a,b) for(rg int i=a;i>=b;++i)
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
template <typename T> inline void cmax(T &a,T b) {a=a>b?a:b;}
template <typename T> inline void cmin(T &a,T b) {a=a<b?a:b;}
template <typename T> inline void read(T &n) {
	n=0;rg char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=n*10+(ch^48));
}
typedef long long ll;
int n,m,t=1,b=0;
signed main() {
	read(n);
	f(i,1,n) {
		read(m);
		if(m!=t)++b;
		else ++t;
	} if(t>1) printf("%d",b);
	else printf("-1");
}


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

class Program
{
    static void Main(string[] args)
    {
        var io = new StandardIO();
        new Process(io).Run();
    }

}

class Process
{
    public Process(IIO io)
    {
        this.io = io;
    }

    IIO io;

    public void Run()
    {
        var ns = io.GetIntegerArray();
        int count = ns[0];
        int hp = ns[1];

        int[] a = new int[count];
        int[] b = new int[count];

        for (int i = 0; i < count; i++)
        {
            var damages = io.GetIntegerArray();
            a[i] = damages[0];
            b[i] = damages[1];
        }

        int maxA = a.Max();
        IEnumerable<int> validB = b.Where(d => d > maxA).OrderByDescending(d => d);

        int result = GetResult(hp, maxA, validB);
        io.Write(result.ToString());
    }

    int GetResult(int hp, int maxA, IEnumerable<int> validB)
    {
        int result = 0;
        int currentHp = hp;

        foreach (var damage in validB)
        {
            currentHp -= damage;
            result++;

            if (currentHp <= 0)
                return result;
        }

        result += (currentHp - 1) / maxA + 1;
        return result;
    }
}

public interface IIO
{
    string Get();
    void Write(string s);
    void Flush();
}

public class StandardIO : IIO
{
    string IIO.Get()
    {
        return Console.ReadLine();
    }

    void IIO.Write(string s)
    {
        Console.WriteLine(s);
    }

    void IIO.Flush()
    {
        Console.Out.Flush();
    }
}

public static class InputExtension
{
    public static int GetInteger(this IIO input)
    {
        return int.Parse(input.Get());
    }

    public static string[] GetStrings(this IIO input, char separator = ' ')
    {
        return input.Get().Split(separator);
    }

    public static int[] GetIntegerArray(this IIO input, char separator = ' ')
    {
        return input.GetStrings().Select(s => int.Parse(s)).ToArray();
    }
}



Measured memory_bytes: 18112
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;
typedef long long ll;

const ll INF = 1e18;

int X, Y, Z, K;
ll A[1000], B[1000], C[1000];
ll ans1[1000000], ans2[3000000];

int main() {
	cin >> X >> Y >> Z >> K;
	ll amax = 0, bmax = 0, cmax = 0;
	for (int i = 0; i < X; i++)cin >> A[i];
	for (int i = 0; i < Y; i++)cin >> B[i];
	for (int i = 0; i < Z; i++)cin >> C[i];
	
	//sort(A, A + X, greater<ll>());
	//sort(B, B + Y, greater<ll>());
	sort(C, C + Z, greater<ll>());

	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			ans1[i * Y + j] = A[i] + B[j];
		}
	}
	sort(ans1, ans1 + X * Y, greater<ll>());
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < Z; j++) {
			ans2[i * Z + j] = ans1[i] + C[j];
		}
	}

	sort(ans2, ans2 + K * Z, greater<ll>());

	for (int i = 0; i < K; i++) {
		cout << ans2[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 31488
#include <stdio.h>
#define MAX 100000

struct Node{
  int parent,right,left;
};

struct Node T[MAX];

int main(){
  int n,i,j,id,k,c[MAX],a,d[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = -1;
      T[i].right = T[i].left = -1;
      d[i] = 0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
  
    if(k != 0){
      for(j=0;j<k;j++){
        scanf("%d",&c[j]);
        T[c[j]].parent = id;
        if(j == 0){
          T[id].left = c[j];
        }
        else T[c[j-1]].right = c[j];
      
      }
    }
  }
  for(i=0;i<n;i++){
    j = i;
    while(1){
      if(T[j].parent == -1)break;
      j = T[j].parent;
      d[i]++;
    }
  }
 
  for(i=0;i<n;i++){
    printf("node %d:",i);
    printf(" parent = %d,",T[i].parent);
    printf(" depth = %d," ,d[i]);
    if(T[i].parent == -1){
      printf(" root, [");
    }
    else if(T[i].left != -1){
      printf(" internal node, [");
    }
    else printf(" leaf, [");
    id = T[i].left;
    j=0;
    while(1){
      if(id == -1) break;
      if(j != 0) printf(", ");
      printf("%d",id);
      id = T[id].right;
      j++;
    }
    printf("]\n");
  }

  return 0;
  
}




Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)

vector<pair<int,int> > pos;
vector<int> height;

int top_height(int x_cent, int y_cent, int x_pos, int y_pos, int h_pos)
{
  return h_pos + abs(x_cent-x_pos) + abs(y_cent-y_pos);
}

bool check(int x_cent, int y_cent, int h_top, int n)
{
  rep(n)
  {
    int x_pos = pos[i].first;
    int y_pos = pos[i].second;
    int h_pos = height[i];
    if ( h_top - abs(x_cent-x_pos) - abs(y_cent-y_pos) <= 0 ) 
    {
      if ( h_pos != 0 ) return false;
    } else {
      if ( h_pos + abs(x_cent-x_pos) + abs(y_cent-y_pos) != h_top) 
      return false;
    }
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  
  rep(n)
  {
    int x,y,h;
    cin >> x >> y >> h;
    pos.emplace_back(x,y);
    height.emplace_back(h);
  }

  int x_pos, y_pos, h_pos;

  rep(n)
  {
    if(height[i]!=0)
    {
      x_pos = pos[i].first;
      y_pos = pos[i].second;
      h_pos = height[i];
      break;
    }
  }

  pair<int,int> ans_pos;
  int ans_height;

  for (int i = 0; i < 101; i++)
  {
    for (int j = 0; j < 101; j++)
    {
      int h = top_height(i,j,x_pos,y_pos,h_pos);
      if(check(i,j,h,n))
      {
        ans_pos = make_pair(i,j);
        ans_height = h;
      }
    }
  }
  
  cout << ans_pos.first << " " << ans_pos.second << " " << ans_height << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    total = sum(a)

    min = total / (4*m)

    c = 0
    for i in range(n):
        if a[i] >= min:
            c += 1
    if c >= m:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 38384
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    s=input()
    for w in range((len(s)-1)//2,0,-1):
        if s[:w]==s[w:w*2]:
            print(w*2)
            break

main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	long a, b;
	String[] input;
	while (scan.hasNext()){
	    input = scan.nextLine().split(" ");
	    a = Integer.parseInt(input[0]);
	    b = Integer.parseInt(input[1]);
	    long lcm = solveLCM(a, b);
	    long gcd = solveGCD(a, b);
	    System.out.println(gcd + " " + lcm);
	}
    }
    static long solveGCD (long a, long b) {
	long gcd = a % b;
	if (gcd == 0) {
	    return b;
	}
	return solveGCD(b, gcd);
    }

    static long solveLCM (long a, long b) {
	if (a == 0 || b == 0) {
	    return 0;
	}
	long i = 1;
	long max = Math.max(a, b);
	long lcm = max * i++;
	long min = Math.min(a, b);
	while (lcm % min != 0) {
	    lcm = max * i++;
	}
	//return lcm;
	return a * b / solveGCD(a,b);
    }
}

Measured memory_bytes: 26296
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
	{
		cout<<a-b<<endl;
	}
	else
	{
		cout<<'0'<<endl;
	}
	return 0;
}

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

int main() {
	int ret = 0;
	int a, b, c, k;

	cin >> a >> b >> c >> k;

	if (a < k) {
		k -= a;
		ret = a;
	} else {
		ret = k;
		goto out;
	}

	if (b < k) {
		k -= b;
	} else {
		goto out;
	}

	if (c < k) {
		ret -= c;
	} else {
		ret -= k;
	}

out:
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int A,B;
	cin >> A >> B;
	if(A <= 8 && B <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl; 
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ng=['!']
for i in range(n):
  w=input()
  ng[0]+=w[0]
  if w in ng or w[0] != ng[-1][-1]:
    #print(w,ng[-1])
    print('No')
    break
  ng.append(w)
else:
  print('Yes')

Measured memory_bytes: 9164
//██████╗ ██╗   ██╗██╗      ██████╗ ███████╗
//██╔══██╗██║   ██║██║      ██╔══██╗██╔════╝
//██████╔╝██║   ██║██║█████╗██║  ██║█████╗
//██╔══██╗██║   ██║██║╚════╝██║  ██║██╔══╝
//██║  ██║╚██████╔╝██║      ██████╔╝███████╗
//╚═╝  ╚═╝ ╚═════╝ ╚═╝      ╚═════╝ ╚══════╝

#include <iostream>
#include <random>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <chrono>
#include <cstdio>
#include <map>
#include <memory.h>


// #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef  double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;

#define next ajksdslk
#define prev aklsfjk

mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());

template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }

const int maxn = (int) 5e6 + 100;
const int maxlog = 21;
const int base = 998244353;
const ld eps = (ld) 1e-9;
const ld PI = acos(-1.);
//const int pp = 41;
const int inf = 2e9;
const ll llinf = 1e18;

vector<string> w {
    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifdef LOCAL
  freopen ("input.txt", "r", stdin);
#endif
  int n; cin >> n;
  string s; cin >> s;

  for (int i = 0; i < sz(s); i ++) {
    int c = s[i] - 'A';
    c = (c + n) % 26;
    s[i] = 'A' + c;
  }
  cout << s ;

  return 0;
}

Measured memory_bytes: 888
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int K = scan.nextInt();
	int X = scan.nextInt();
	int Y = scan.nextInt();
	
	if(N-K>0)
			System.out.println(K*X+(N-K)*Y);
	else
		System.out.println(N*X);
				
	
			
	}
}


Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++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 FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll xs, ys, xt, yt, n;
ll x[1000], y[1000], r[1000];

struct Edge { int to; long double cost; };
vector<Edge> es[1002];

long double dist(ll x1, ll y1, ll r1, ll x2, ll y2, ll r2) {
	ll dx = x1 - x2, dy = y1 - y2, sr = r1 + r2;
	if (dx * dx + dy * dy <= sr * sr) return 0.0;
	else return sqrt(dx * dx + dy * dy) - sr;
}

long double d[1002];

typedef pair<long double, int> P;

int main(int argc, char **argv) {
	cin >> xs >> ys >> xt >> yt >> n;
	REP(i, n) cin >> x[i] >> y[i] >> r[i];
	REP(i, n) {
		long double d1 = dist(xs, ys, 0, x[i], y[i], r[i]);
		es[0].push_back({ 2 + i, d1 });
		es[2 + i].push_back({ 0, d1 });
		long double d2 = dist(xt, yt, 0, x[i], y[i], r[i]);
		es[1].push_back({ 2 + i, d2 });
		es[2 + i].push_back({ 1, d2 });
	}
	REP(i, n) REP(j, n) {
		long double d = dist(x[i], y[i], r[i], x[j], y[j], r[j]);
		es[2 + i].push_back({ 2 + j, d });
		es[2 + j].push_back({ 2 + i, d });
	}
	long double d12 = dist(xs, ys, 0, xt, yt, 0);
	es[0].push_back({ 1, d12 });
	es[1].push_back({ 0, d12 });
	REP(i, n + 2) d[i] = 3.0 * 1000000000;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(MP(0.0, 0));
	d[0] = 0.0;
	while (!q.empty()) {
		P t = q.top(); q.pop();
		long double c = t.first;
		int v = t.second;
		if (c > d[v]) continue;
		d[v] = c;
		REP(i, es[v].size()) {
			Edge e = es[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(MP(d[v] + e.cost, e.to));
			}
		}
	}
	cout << fixed << setprecision(11) << d[1] << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int k = 50;
  string grid[100];
  for (int i = 0; i < 2 * k; i++) {
    for (int j = 0; j < 2 * k; j++) {
      if (i < k)
        grid[i] += '.';
      else
        grid[i] += '#';
    }
  }
  a--;
  b--;
  for (int i = 0; i < 50; i += 2) {
    for (int j = 0; j < 100; j += 2) {
      if (b > 0) {
        grid[i][j] = '#';
        b--;
      }
    }
  }
  for (int i = 51; i < 100; i += 2) {
    for (int j = 0; j < 100; j += 2) {
      if (a > 0) {
        grid[i][j] = '.';
        a--;
      }
    }
  }
  cout << 100 << " " << 100 << '\n';
  for (auto s : grid)
    cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        String S;
        String T;
        try (Scanner sc = new Scanner(System.in)) {
            S = sc.next();
            T = sc.next();
        }


        System.out.println(T+S);
    }
}


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

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  ll atot = 0;
  REP(i, 0, n) {
    cin >> a[i];
    atot += a[i];
  }
  ll cur = 0;
  ll mi = 5e15;
  REP(i, 0, n) {
    if (i == n - 1) {
      break;
    }
    cur += a[i];
    ll diff = abs(cur + cur - atot);
    mi = min(mi, diff);
  }
  cout << mi << "\n";
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int p,q,r,maxx;
    scanf("%d%d%d",&p,&q,&r);
    maxx=max(p,max(q,r));
    printf("%d\n",p+q+r-maxx);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String str = scan.nextLine();
			char[] ch = new char[str.length()];
			for(int i = 0;i < str.length();i++){
				ch[i] = str.charAt(i);
			}
			int[] a = new int[ch.length];
			for(int i = 0;i < ch.length;i++){
				switch(ch[i]){
					case 'I': a[i] = 1;	break;
					case 'V': a[i] = 5; break;
					case 'X': a[i] = 10; break;
					case 'L': a[i] = 50; break;
					case 'C': a[i] = 100; break;
					case 'D': a[i] = 500; break;
					case 'M': a[i] = 1000; break;
					default: a[i] = 0; break;
				}
			}
			int sum = a[a.length-1];
			for(int i = a.length-2;i >= 0;i--){
				if(a[i] >= a[i+1]){
					sum += a[i];
				}else{
					sum -= a[i];
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17200