akhauriyash/Code-Regression huggingface dataset:
HOPS =
  [[-1, -2], [0, -2], [1, -2], [-1, 2], [0, 2], [1, 2],
   [-2, -1], [-2, 0], [-2, 1], [2, -1], [2, 0], [2, 1]]

while true
  x, y = gets.chomp.split(" ").map{|s| s.to_i}
  break if x == 0 && y == 0

  n = gets.chomp.to_i
  xys = gets.chomp.split(" ").map{|s| s.to_i}

  spkl = (0..n).map{[]}

  for id in (1..n)
    x0 = xys.shift
    y0 = xys.shift

    min_x1 = [x0 - 1, 0].max
    max_x1 = [x0 + 1, 9].min
    min_y1 = [y0 - 1, 0].max
    max_y1 = [y0 + 1, 9].min

    for y1 in (min_y1..max_y1)
      for x1 in (min_x1..max_x1)
        spkl[id].push [x1, y1]
      end
    end
  end

  id = 1
  path = [[0, x, y]]

  while id > 0 && id <= n
    path[id] = [-1, 0, 0] if path[id].nil?

    di0, x, y = path[id - 1]

    di = path[id][0] + 1
    while di < HOPS.length
      x0 = x + HOPS[di][0]
      y0 = y + HOPS[di][1]
      path[id] = [di, x0, y0]

      if x0 >= 0 && x0 <= 9 && y0 >= 0 && y0 <= 9 &&
          spkl[id].include?([x0, y0])
        break
      end

      di += 1
    end

    if di >= HOPS.length
      path.pop
      id -= 1
    else
      id += 1
    end
  end

  puts (id > n) ? "OK" : "NA"
end

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

typedef long long ll;

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

    double l;
    scanf("%lf", &l);

    double third = l / 3;
    double val = third * third * third;

    printf("%lf", val);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    int n, m;
    cin >> n >> m;
    vector<vector<int>> A(n, vector<int>(m));
    vector<int> B(m);

    // input
    rep(i, n) rep(j, m) cin >> A.at(i).at(j);
    rep(i, m) cin >> B.at(i);

    // output
    rep(i, n) {
        int row = 0;
        rep(j, m) row += A.at(i).at(j) * B.at(j);
        cout << row << endl;
    }
}



Measured memory_bytes: 3228
# editorial

def main():
    X, Y = map(int, input().split())

    def solve(x, y):
        """手番が勝つか"""
        return not ((X + Y <= 1) or (abs(X - Y) <= 1))

    cond = solve(X, Y)
    print('Alice' if cond else 'Brown')


if __name__ == '__main__':
    main()

# e,e
# o,e
# o,o
# o,e遷移は今回は関係なかった

# 負け状態
# 0,0
# 0,1
# 1,1
# まとめると
# X+Y<=1
# abs(X-Y)<=1 <-> >1 と交互

# まとめ方
# 偶奇
# 和と差


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

#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define ld long double
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
#define sze(v) (int)(v.size())

typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<vector<int>>Vv;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue <int, vector<int>, greater<int>>PQL;
typedef unordered_map<int,int>ump;

const int mod=1e9+7;
const int modx=998244353;
const int Nx=1e5+2;
const int inf= (int)(1e19+10LL);

void solve(){
 int n,k;
 sl(n);sl(k);
 Vl arr(n);
 for(int i=0;i<n;i++)sl(arr[i]);
 sort(arr.begin(),arr.end());
 int sum=0;
 for(int i=0;i<k;i++)sum+=arr[i];
 cout<<sum<<endl;
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

    int n;
    int l;
    String[] s;

    Main(int n, int l, String[] s) {
        this.n = n;
        this.l = l;
        this.s = s;
    }

    String solve() {

        String ans = "";

        List<String> sList = new ArrayList<>(Arrays.asList(s));
        Collections.sort(sList);

        for (String si : sList) {
            ans += si;
        }

        return ans;
    }

    public static void main(String args[]) {
        // input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        sc.close();

        // solve
        String ans = new Main(n, l, s).solve();

        // display
        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	string S;
	cin >> S;

	ll len = S.size();

	ll cnt = 0;
	for (const auto& s : S)
	{
		if (s == '0') cnt--;
		if (s == '1') cnt++;
	}

	cout << len - abs(cnt) << endl;

	//cout << len - sss.size() << endl;

	//system("pause");
}

Measured memory_bytes: 512
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int h=in.nextInt();
			if((n|h)==0)
				return;
			boolean xy[][]=new boolean[501][501];
			boolean xz[][]=new boolean[501][501];
			boolean yz[][]=new boolean[501][501];
			int cnt=n*n*n;
			for(int i=0;i<h;i++)
			{
				String st=in.next();
				int a=in.nextInt();
				int b=in.nextInt();
				if(st.equals("xy"))
				{
					for(int z=1;z<=n;z++)
						if(xz[a][z]||yz[b][z])
							;
						else
							cnt--;
					xy[a][b]=true;
				}
				else if(st.equals("xz"))
				{
					for(int y=1;y<=n;y++)
						if(xy[a][y]||yz[y][b])
							;
						else
							cnt--;
					xz[a][b]=true;
				}
				else 
				{
					for(int x=1;x<=n;x++)
						if(xy[x][a]||xz[x][b])
							;
						else 
							cnt--;
					yz[a][b]=true;
				}
			}
			System.out.println(cnt);
		}
	}

	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 55876
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int N, M;
  cin >> N >> M;

  map<int, set<int>> edges;
  Rep(i, M) {
    int a, b;
    cin >> a >> b;
    edges[a].insert(b);
    edges[b].insert(a);
  }

  vector<int> nearest(N + 1, -1);
  queue<int> q;
  q.push(1);
  do {
    int current = q.front();
    q.pop();
    for (int to : edges[current]) {
      if (nearest[to] == -1) {
        nearest[to] = current;
        q.push(to);
      }
    }
  } while (!q.empty());

  cout << "Yes" << endl;
  For(i, 2, nearest.size()) {
    cout << nearest[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 32220
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
    return 0;
}

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

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

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

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

    int cnt = 0;
    for(int i = 1 ; i < n ; i++)
    {
        if(i + 1 < n)
        {
            int x = a[i - 1];
            int y = a[i];
            int z = a[i + 1];

            if(x > z) swap(x , z);

            if(y > x && y < z) cnt++;
        }
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = 0, m = 0,max = 0, index = 0;
			int i;
			for (i = 0; i < 5; i++)
			{
				n = sc.nextInt();
				m = sc.nextInt();
				if (n == 0 && m == 0) System.exit(0);
				if (n + m > max)
				{
					index = i;
					max = n + m;
				}
			}
			if (n + m > max)
			{
				index = i;
				max = n + m;
			}
			System.out.printf("%c %d\n", 'A' + index, max);
		}
	}
}

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

int main() {
    ll x;
    cin >> x;
    ll m = 100;
    int count = 0;
    while (m < x) {
        m *= 1.01;
        count++;
    }
    cout << count << endl;
    return 0;
}

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

namespace ABC099
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;
                list.Add(line);
            }
            List<int> ans = new List<int>();
            foreach (var item in list.Select((Value, Index) => new { Value, Index }))
            {
                if (item.Index!=0)
                {
                    ans.Add(int.Parse(item.Value));
                }
            }
            var ss = ans.OrderByDescending(Z => Z);
            int a = ss.First()/2;
            Console.WriteLine(ss.Sum() - a);
        }

    }
}


Measured memory_bytes: 13396
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = sorted([(k,v) for k,v in C.items() if v>=2], key = lambda x:-x[0])[:2]

if len(ans)<2:
  print(0)
elif ans[0][1]>=4:
  print(ans[0][0]**2)
else:
  print(ans[0][0]*ans[1][0])

Measured memory_bytes: 18592
def my_code():
    n,m = map(int, input().split())
    G = [[] for _ in range(m)]
    for i in range(m):
        G[i] = list(map(int, input().split()))[1:]
    p = list(map(int, input().split()))
    #print(G)

    res = 0
    for i in range(pow(2,n)):
        light = [0]*m
        switch = list(map(int, format(i, '0'+str(n)+'b')))
        for j in range(m):
            for connect in G[j]:
                light[j] += switch[connect - 1]
            light[j] += p[j]
            light[j] %= 2
        if sum(light)==0:
            res += 1
            #print(switch)
    print(res)

my_code()

Measured memory_bytes: 3316
#include <stdio.h>

int main() {
	int n,k,i,x,y;
	double a;
	scanf("%d", &n);
	scanf("%d", &k);
	a = 0;
	for(i=1;i<=n;i++){
		x = i;
		y = 1;
		while (x < k) {
			x *= 2; 
			y *= 2;
		}
		a += 1.0 / y;
	}
	printf("%13.12lf", a / n);
}

Measured memory_bytes: 128
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

a,b = list(map(int, stdin.readline().rstrip().split()))
aa = str(a)*b
ab = str(b)*a
print(min(aa,ab))


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const LL maxm = LL(1e18)+5;

const int maxn = 10005;

int N,P;

map<int,LL> mp;

int main()
{
    string s;
    cin >> N >> P >> s;
    int sz = s.size();
    reverse(ALL(s));
    LL ans = 0;
    LL k = 1;
    mp[0] = 1;
    LL ui = 0;

    if( (P == 2) || (P == 5)){
        int cnt = 0;
        _for(i,0,sz){
            int num = s[i] - '0';
            if(num % P == 0) cnt++;
            ans += cnt;
        }
    }
    else{
        _for(i,0,sz){
            int num = s[i] - '0';
            ui = (k*num + ui)%P;
            k = (k*10)%P;
            ans += mp[ui];
            mp[ui]++;
        }
    }

    cout << ans << endl;


    return 0;
}


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

N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A].append(B)
    G[B].append(A)
dist = [-1] * (N+1)
dist[1] = 0
queue = deque([1])
while queue:
    v = queue.popleft()
    for c in G[v]:
        if dist[c] == -1:
            dist[c] = dist[v] + 1
            queue.append(c)
print('Yes')
for v in range(2, N+1):
    for c in G[v]:
        if dist[c] < dist[v]:
            print(c)
            break

Measured memory_bytes: 92372
n, k = map(int, input().split())
a = list(map(int, input().split()))

# binary search
left = 1
right = 10 ** 9

while left < right:
    center = (left + right) // 2

    total = 0
    for i in a:
        if i % center == 0:
            i -= 1
        total += i//center
    
    if total > k:
        left = center + 1
    else:
        right = center

print(left)

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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << (char)(a[0]-'a'+'A');
  cout << (char)(b[0]-'a'+'A');
  cout << (char)(c[0]-'a'+'A');
  return 0;
}

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

#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
#define REPI(i,a,b) for(long long i=(long long)(a);i<(long long)(b);++i)


const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, std::string S){
  REP(i, A) {
    if(((S[i] - '0') < 0) || ((S[i] - '0') > 9)) goto error;
  }
  if(S[A] != '-') goto error;

  REPI(i, A+1, (A+B+1)) {
    if(((S[i] - '0') < 0) || ((S[i] - '0') > 9)) goto error;
  }

  cout << YES << endl;
  return;

  error:
  cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  std::string S;
  std::cin >> S;
    solve(A, B, S);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

using namespace std;

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

  bool easy = true;
  for (int i=0; i<s.length(); i++) {
    if (i%2 == 0 && s[i] == 'L')
      easy = false;
    if (i%2 == 1 && s[i] == 'R')
      easy = false;
  }

  if (easy)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
 
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, k;
    cin >> n >> k;
    int g = 0, mx = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        g = __gcd(g, x);
        mx = max(mx, x);
    }
    if (k <= mx && k % g == 0) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}

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

using namespace std;

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> x;
vector<int> y;
vector<int> h;

signed main()
{

    cin >> N;
    x.resize(N);
    y.resize(N);
    h.resize(N);
    rep(i, N)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    vector<int> temp = h;
    sort(all(temp));

    int m = temp[N - 1];

    for (int k = m; k <= m + 100; k++)
    {
        rep(i, 101)
        {
            rep(j, 101)
            {
                int cx = i;
                int cy = j;
                int ans = true;
                rep(s, N)
                {
                    int m2 = k - abs(cx - x[s]) - abs(cy - y[s]);
                    ans = (h[s] == max((int)0, m2));
                    if (!ans)
                    {
                        break;
                    }
                }

                if (ans)
                {
                    cout << cx << " " << cy << " " << k;
                    return 0;
                }
            }
        }
    }

    return 0;
}

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

int main() {
  int a, b, count = 0;
  cin >> a >> b;
  if(a <=0 && b >= 0){
    cout << "Zero" << endl;
  }
  else{
    for(int i = 0; i < b - a + 1; i++){
      if(a + i < 0){
        count++; 
      }
    }
    if(count % 2 == 0){
      cout << "Positive" << endl;
    }
    else{
      cout << "Negative" << endl;
    }
  }
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

f = 0
x = 0
for i in range(len(a)-1):
    if a[i] == a[i+1] != x:
        f += 1
    if f == 1:
        x = a[i]
        f += 1
        if a.count(x) >= 4:
          f = 3
    if f >= 3:
        print(x*a[i])
        exit()
print(0)

Measured memory_bytes: 62704
#include <stdio.h>

int main() {
  int W, H , x ,y ,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x-r<0 || x+r>W || y-r<0 || y+r>H) {
    printf("No\n");
  } else {
    printf("Yes\n"); 
  }


  return 0;
}


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

N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ks=make_divisors(N-1)
ks.remove(1)
#print(ks)
ans=ks

divs=make_divisors(N)
divs.remove(1)
for i in divs:
    divN=N
    while divN%i==0:
        divN=divN/i
    
    if (divN-1)%i==0:
        ans.append(i)

#print(ans)
print(len(ans))

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;

    vector<string> field(H+2, "");
    for(int i = 0; i < W+2; i++){
        field[0] = field[0] + ".";
        field[H+1] = field[H+1] + ".";
    }
    for(int i = 1; i <= H; i++){
        cin >> field[i];
        field[i] = "." + field[i] + ".";
    }

    bool flag = true;
    for(int i = 1 ; i <= H; i++){
        for(int j = 1; j <=W; j++){
            if(field[i][j] == '.') continue;

            int dx[4] = {1, 0, -1, 0};
            int dy[4] = {0, 1, 0, -1};
            bool check = false;
            for(int k = 0; k < 4; k++){
                if(field[i+dy[k]][j+dx[k]] == '#') check = true;
            }
            if(!check)flag = false;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  REP(i, k){
    ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <cstring>
using namespace std;

#define pi acos(-1)

int to_int(string s){
    int number = 0;
    for(int i=0;i<s.size();i++){
        number *= 10;
        number += s[i] - '0';
    }
    return number;
}

string to_str(int n){
    string s;
    while(n!=0){
        s += n % 10 + 48;
        n /= 10;
    }
    reverse(s.begin(),s.end());
    return s;
}

bool isLeapYear(int year)
{
    if(((year % 4 == 0 ) && (year % 100 != 0)) || (year % 400 == 0))
        return true;
    else
        return false;
}

bool isPrime(int n)
{
    if(n ==1)
        return false;
    if (n == 2)
        return true;
    if ((n & 1)==0)
        return false;
    for (int i = 3; i*i <= n;i+=2) {
        if (n%i == 0)
            return false;
    }

    return true;
}

bool isPalindrome(string s)
{
    for(int i=0,j=s.size()-1 ; i< s.size()/2 && j >= s.size()/2;i++,j--){
            if(s[i] == s[j])
                continue;
            else{
                return false;
            }
        }
    return true;
}

/*#define row 5001
#define col 10000

int arr[row][col];

void fib()
{
    arr[0][0] = 0;
    arr[1][0] = 1;
    for(int i=2;i<row;i++){
        for(int j=0;j<col;j++){
            if(arr[i-1][j] + arr[i-2][j] == 0)
                continue;
            arr[i][j] += arr[i-1][j] + arr[i-2][j];
            if(arr[i][j] > 9){
                arr[i][j+1] = arr[i][j]/10;
                arr[i][j] %= 10;
            }
        }
    }
}*/

bool comp(pair<pair<long long,long long>, long long> a, pair<pair<long long, long long>, long long> b)
{
    return a.second > b.second ;
}

int main()
{
    string s;
    cin >> s;
    int c=0;
    bool flag = true;
    if(s[0] == 'A' && s[1] != 'C' && s[s.size()-1] != 'C' ){
        if(s[1] >=97 && s[1] <= 122 && s[s.size()-1] >= 97 && s[s.size()-1] <=122){
            for(int i=2;i<s.size()-1;i++){
                if(s[i] == 'C')
                    c++;
                if(s[i] != 'C' && s[i] <=90){
                    flag = false;
                    break;
                }
                if(c > 1){
                    flag = false;
                    break;
                }
            }
        }
    }
    else{
        cout << "WA" << endl;
        return 0;
    }

    if(flag && c!=0)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;

	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int lim=1e6+1;
	vector <bool> isPrime(lim,true);
	for (int i=2;i<lim;i++){
	    if(isPrime[i]){
	        for (int j=2*i;j<lim;j+=i) isPrime[j]=false;
	    }
	}
	int freq[lim];
    for (int i=0;i<lim;i++) freq[i]=0;
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++){
	    cin>>a[i];
	    freq[a[i]]++;
	}    
	bool flag=true;
    for (int i=2;i<lim;i++){
        if(isPrime[i]){
            int cnt=freq[i];
            for (int j=2*i;j<lim;j+=i) cnt+=freq[j];
            if(cnt>1) flag=false;
        }
    }
    if(flag) cout<<"pairwise coprime\n";
    else{
        int gcd=a[0];
        for (int i=1;i<n;i++){
            gcd=__gcd(gcd,a[i]);
        }
        if(gcd==1) cout<<"setwise coprime\n";
        else cout<<"not coprime\n";
    }
	return 0;
}

Measured memory_bytes: 11580
N = int(input())
COUNT = 0
def dfs(num):
    if len(num) > 0:
        if int(num) > N:
            return 0
        elif "7" in num and "5" in num and "3" in num:
            return 1 + dfs(num + "7") + dfs(num + "5") + dfs(num + "3")
        else:
            return dfs(num + "7") + dfs(num + "5") + dfs(num + "3")
    else:
        return dfs(num + "7") + dfs(num + "5") + dfs(num + "3")
print(dfs(""))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int tall[] = {165, 170, 175, 180, 185};
    int n;
    cin >> n;

    vector<int> num(6);
    while(--n >= 0){
        int a, b;
        char c;
        cin >> a >> c >> b;

        int i = upper_bound(tall, tall+5, a) - tall;
        ++ num[i];
    }

    for(int i=0; i<6; ++i)
        cout << (i+1) << ':' << string(num[i], '*') << endl;

    return 0;
}

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

int main()
{

    int n;
    cin >> n;

    vector<int64_t> a(n+2);
    int sum=0,ans=0;

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

    for(int i=1;i<=n+1;i++) sum += abs(a[i]-a[i-1]);

    for(int i=1;i<=n;i++){
        ans = sum - abs(a[i+1]-a[i]) - abs(a[i]-a[i-1]) + abs(a[i+1] - a[i-1]);
        cout << ans << endl;
        ans=0;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// ll fun(ll a[], ll n)
// {
//     if(n<=0)
//     return 0;
//     if(dp[n]!=-1)
//     return 0;
//     return min(fun(a,n-1)+abs(a[n]-a[n-1]),fun(a,n-2)+abs(a[n]-a[n-2]));
// }
 
int main() {
   
   ll i,n,k,j;
   cin>>n>>k;
   ll a[n];
   ll dp[n+1];
   for(i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    // ll count;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        for(j=1;j<=k && i-j>=0; j++)
        {
            dp[i]=min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
            // count++;
        }
    }
    
    cout<<dp[n-1];
   
    
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int minp;
  minp = (2 * c <= a + b ? 2 * c : a + b);
  int res = 0;
  int cnt = 0;
  while (cnt < x && cnt < y) {
    res += minp;
    cnt++;
  }
  if (a > minp) a = minp;
  if (b > minp) b = minp;
  res += (x - cnt) * a + (y - cnt) * b;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3592
N,K=map(int,input().strip().split())

l=[n for n in range(1,N+1)]
for n in range(K):
    d=int(input())
    A=list(map(int,input().strip().split()))
    for n in range(d):
        if A[n] in l:
            l.remove(A[n])

print(len(l))

Measured memory_bytes: 9220
N, A, B = list(map(int, input().split()))
H = [int(input()) for _ in range(N)]

from math import ceil

def can_korosu(t):
    count = 0
    for h in H:
        count += ceil(max(0, h - t*B)/(A-B))
        if count > t:
            return False
    return True

lo = 0
hi = 10**9

p = (lo, hi)
for _ in range(50):
    mid = (hi + lo) // 2
    if can_korosu(mid):
        hi = mid
    else:
        lo = mid
    if p == (lo, hi):
        break
    p = (lo, hi)
print(hi)

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


long long myPow(long long x, long long n, long long mod){
    if(n == 0) {
        return 1;
    }
    if(n % 2 == 0) {
        return myPow(x * x % mod, n / 2, mod);
    }
    else {
        return x * myPow(x, n - 1, mod) % mod;
    }
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
	LL MOD = 1000000000 + 7;

	string S;
	cin >> S;
	int N = S.size();

    vector<LL> A(N), C(N);
    int num_q = 0;
    int num_a = 0;
    for(int i = 0; i < N; ++i) {
        if (S[i] == 'A') {
            num_a++;
        }
        else if (S[i] == '?') {
            num_q++;
        }

        A[i] += num_a * myPow(3, num_q, MOD);
        if (num_q > 0) {
            A[i] += (num_q) * (myPow(3, (num_q - 1), MOD));
        }

        A[i] %= MOD;
    }

    num_q = 0;
    int num_c = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (S[i] == 'C') {
            num_c++;
        }
        else if (S[i] == '?') {
            num_q++;
        }

        C[i] += num_c * myPow(3, num_q, MOD);
        if (num_q > 0) {
            C[i] += (num_q) * (myPow(3, (num_q - 1), MOD));
        }

        C[i] %= MOD;
    }

    LL ans = 0;
    FOR(i, 1, N - 1) {
        if (S[i] == 'B' or S[i] == '?') {
            ans = ans + (A[i - 1] * C[i + 1]);
            ans %= MOD;
        }
    }

    print(ans % MOD);
	return 0;
}

Measured memory_bytes: 2000
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define HUGE_NUM 9999999999999999
#define NUM 100000

struct Edge{
	Edge(int arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	ll cost;
};

struct Info{
	Info(int arg_node_id,ll arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{ //総コストの昇順(PQ)
		return sum_cost > arg.sum_cost;
	}

	int node_id;
	ll sum_cost;
};


int V,E,start,goal;
ll min_dist[NUM];
vector<Edge> G[NUM];


int main(){

	scanf("%d %d %d %d",&V,&E,&start,&goal);
	start--;
	goal--;

	int a,b,c;
	ll cost;

	for(int loop = 0; loop < E; loop++){
		scanf("%d %d %d %lld",&a,&b,&c,&cost);
		a--;
		b--;
		c--;
		G[a].push_back(Edge(b,cost));
		G[b].push_back(Edge(a,cost));
		G[a].push_back(Edge(c,cost));
		G[c].push_back(Edge(a,cost));
		G[b].push_back(Edge(c,cost));
		G[c].push_back(Edge(b,cost));
	}

	for(int i = 0; i < V; i++)min_dist[i] = HUGE_NUM;

	min_dist[start] = 0;
	priority_queue<Info> Q;
	Q.push(Info(start,0));

	int next_node;
	ll next_cost;

	while(!Q.empty()){

		if(Q.top().node_id == goal){
			printf("%lld\n",Q.top().sum_cost);
			return 0;
		}else if(Q.top().sum_cost > min_dist[Q.top().node_id]){
			Q.pop();
		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				next_node = G[Q.top().node_id][i].to;
				next_cost = Q.top().sum_cost+G[Q.top().node_id][i].cost;

				if(min_dist[next_node] > next_cost){
					min_dist[next_node] = next_cost;
					Q.push(Info(next_node,next_cost));
				}
			}
			Q.pop();
		}
	}
	return 0;
}



Measured memory_bytes: 23816
<?php
  list($N, $T) = explode(" ", trim(fgets(STDIN)));
  $ans = PHP_INT_MAX;
  for ($i=0; $i<$N; $i++) {
    list($c, $t) = explode(" ", trim(fgets(STDIN)));    
    if($T >= $t){
      $ans = min($ans, $c);
    }
  }
  echo $ans == PHP_INT_MAX ? "TLE" : $ans;

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001


bool sortbysec(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<1>(a) < get<1>(b)); 
}
void dfs(int s, graph &g, bool vis[]){
	vis[s] = true;
	for(int i=0;i<g[s].size();i++){
		if(!vis[g[s][i]]) dfs(g[s][i],g,vis);
	}
}

string common_prefix(vector<string>& strings){
	string prefix;
	for(string s : strings){
		for(int i=0;i<s.size() && s[i]!='*';++i){
			if(i<prefix.size()){
				if(s[i]!=prefix[i]) return "*";
			}
			else prefix+=s[i];
		}
	}
	return prefix;
}

void reverse(vector<string>& strings){
	for(string& s : strings){
		reverse(s.begin(),s.end());
	}
}

int spf[0];
void sieve(){
	spf[1] = 1;
	for(int i=2;i<MAXN;i++) spf[i] = i;

	for(int i=4;i<MAXN;i+=2) spf[i] = 2;

	for(int i=3; i*i<MAXN;i++){
		if(spf[i]==i){
			for(int j=i*i;j<MAXN;j+=i){
				if(spf[j]==j) spf[j] = i;
			}
		}
	}
}
vector<int> getFactorization(int x){

	vector<int> primeFactors;
	while(x>1){
		primeFactors.pb(spf[x]);
		x /= spf[x];
	}
	return primeFactors;
}



void solve(){
	// sieve(); 
	int s,w; cin>>s>>w;
	if(s<=w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;


}

int main() {
IOS;
	int t=1; 
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e18L+5;


vector<ll> val;
vector<ll> dp;

void rec_call_groups(int ind,const vector<int> &not_taken,ll score_so_far,int mask,int group){
	if(ind==not_taken.size()){
		dp[mask]=max(dp[mask],score_so_far+val[group]);
		return;
	}
	rec_call_groups(ind+1,not_taken,score_so_far,mask,group);
	rec_call_groups(ind+1,not_taken,score_so_far,mask ^ (1<<not_taken[ind]),group ^ (1<<not_taken[ind]));
}

void solve(){
    int n;cin>>n;
    ll a[n][n];
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		cin>>a[i][j];
    	}
    }
    val.resize(1<<n,0);
    dp.resize(1<<n,-INF);
    for(int mask=0;mask< 1<<n;mask++){
    	for(int i=0;i<n;i++){
    		if(mask & (1<<i)){
    			for(int j=i+1;j<n;j++){
    				if(mask & (1<<j)){
    					val[mask]+=a[i][j];
    				}
    			}
    		}
    	}
    }


    dp[0]=0;
    for(int mask=0;mask < (1<<n)-1;mask++){
    	vector<int> not_taken;
    	for(int i=0;i<n;i++){
    		if(!(mask & 1<<i)){
    			not_taken.pb(i);
    		}
    	}
    	int m=not_taken.size();
    	// for(int j=1;j< (1<<m);j++){
    	// 	int sup_mask=mask;
    	// 	int curr_mask=0;
    	// 	for(int k=0;k<m;k++){
    	// 		if(j & (1<<k)){
    	// 			sup_mask=sup_mask ^ (1<<not_taken[k]);
    	// 			curr_mask=curr_mask ^ (1<<not_taken[k]);
    	// 		}
    	// 	}
    	// 	dp[sup_mask]=max(dp[sup_mask],dp[mask]+val[curr_mask]);
    	// 	// cout<<sup_mask<<" "<<mask<<" "<<curr_mask<<" ! "<<dp[mask]<<" -> "<<dp[sup_mask]<<nl;
    	// }
    	rec_call_groups(0,not_taken,dp[mask],mask,0);
    }
    // for(int mask=0;mask<1<<n;mask++){
    	// cout<<mask<<" "<<dp[mask]<<nl;
    // }
    // cout<<1<<n-1;
    cout<<dp[((1<<n) -1)]<<nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1280
N=int(input())
N_sub=N

#f(N)を求める
f_sum=0
while(N>0):
    f_sum+=N%10
    N=int(N/10)
# print(f_sum)
# print(N_sub)
if N_sub%f_sum==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
S = input()
s = S[::-1]

word = ['maerd', 'remaerd', 'esare', 'resare']

T = []

now = 0
for i in range(10**5):
    if s[now:now+5] == 'maerd':
        now += 5
    elif s[now:now+5] == 'esare':
        now += 5
    elif s[now:now+7] == 'remaerd':
        now += 7
    elif s[now:now+6] == 'resare':
        now += 6
    else:
        break

if len(S) == now:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
    int a,b,c,i,x;
        scanf("%d%d%d",&a,&b,&c);
        for(x = a;x <= b;x++){
        if(c%x == 0)
            i++;
        }
        printf("%d\n",i);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N;
    cin >> N;
    VVI dp(N + 1, VI(3, 0));
    VI abc(3);
    FOR(i, 1, N + 1) {
        REP(j, 3) {
            cin >> abc[j];
        }
        REP(j, 3) {
            if (i == 1) {
                dp[i][j] = abc[j];
            } else {
                REP(k, 3) {
                    if (j == k) continue;
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[j]);
                }
            }
        }
    }

    cout << *max_element(ALL(dp[N])) << endl;

    return 0;
}


Measured memory_bytes: 5760
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import sys
input = sys.stdin.readline

n = int(input())
s= input()
ans = ""
for i in range(len(s)-1):
    ss=ord(s[i])
    #print(ss)
    if 65<=ss<=90-n:
        ss+=n
        #print(ss)
    else:
        ss+=-26+n
        #print(ss)
    ans+=chr(ss)
print(ans)

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

using namespace std;

int n, m;
int a[109][109];
string s;

int dp[109][109];

int dl[] = {0, 1};
int dc[] = {1, 0};

void solve()
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j ++)
            dp[i][j] = n * m + 1;
    }

    dp[1][1] = a[1][1];

    for(int x = 1; x <= 200; x ++)
    {
        for(int i = 1; i <= n; i ++)
        {
            for(int j = 1; j <= m; j ++)
            {

                for(int dir = 0; dir < 2; dir ++)
                {
                    int nl = i + dl[dir];
                    int nc = j + dc[dir];

                    int cost = (a[i][j] == 0 && a[nl][nc] == 1);

                    if(nl <= n && nc <= m && dp[i][j] + cost < dp[nl][nc])
                    {
                        dp[nl][nc] = dp[i][j] + cost;
                    }
                }
            }
        }
    }

    cout << dp[n][m] << "\n";
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
    {
        cin >> s;
        for(int j = 1; j <= m; j ++)
            a[i][j] = (s[j - 1] == '.' ? 0 : 1);
    }

    solve();

    return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

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

class CAlchemist {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<int> v(n);
        rep(i,n){
            in >> v[i];
        }
        sort(v.begin(),v.end());
        double ans=v[0];
        rep(i,n-1){
            ans=(ans+(double)v[i+1])/2.0;
        }
        out << ans << endl;
	}
};


int main() {
	CAlchemist solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define PI 3.14159265358979323846

using namespace std;

void solve()
{
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
using System;

namespace ABC085
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            Console.WriteLine(A_Already2018.ChangeYear(S));
        }
    }
  
      public class A_Already2018
    {
        public static string ChangeYear(string S)
        {
            var array = S.Split("/");
            var convertedYear = "";
            array[0] = "2018";
            convertedYear = array[0] + "/" + array[1] + "/" + array[2];

            return convertedYear;
        }
    }
}

Measured memory_bytes: 25776
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;

int main() {

	string s;
	cin >> s;
	ll ans = 0;
	int num = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'W') {
			ans += i - num;
			++num;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mod 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define setpres(x) fixed<<setprecision(x)
using namespace std;
bool isprime(int n)
{
    if(n==1)
        return false;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int32_t main()
{
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
            cout<<"ACL";
    }
}



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

int main() {
  int a,b,c;
  
  cin >> a >> b >> c;
  
  if((a == b + c) || (b == a + c) || (c == a + b)){
    cout << "Yes";
  }else{
    cout << "No"; 
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];

	//+-+-...
	ll cnt1=0, sum1=0;
	for(int i=0; i<n; i++){
		sum1+=a[i];
		if(i%2==0){
			cnt1+=max(1-sum1, 0ll);
			sum1+=max(1-sum1, 0ll);
		}else{
			cnt1+=max(1+sum1, 0ll);
			sum1-=max(1+sum1, 0ll);
		}
	}
	//-+-+...
	ll cnt2=0, sum2=0;
	for(int i=0; i<n; i++){
		sum2+=a[i];
		if(i%2==0){
			cnt2+=max(1+sum2, 0ll);
			sum2-=max(1+sum2, 0ll);
		}else{
			cnt2+=max(1-sum2, 0ll);
			sum2+=max(1-sum2, 0ll);
		}
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RMQ {
	int n;
	vector<int>d;
	RMQ(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int i, int x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)d[j] = min(d[2 * j], d[2 * j + 1]);
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return INF;
		if (a <= l&&r <= b)return d[k];
		else return min(find(a, b, 2 * k, l, (l + r) / 2), find(a, b, 2 * k + 1, (l + r) / 2, r));
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RMQ rmq(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << rmq.find(x, y + 1) << endl;
		else rmq.update(x, y);
	}
	return 0;
}

Measured memory_bytes: 3864