akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#define INF 1e9
#define MAX_V 100001
using namespace std;
typedef pair<int,int> P;

struct edge{int to,cost;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> >que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
/*string s,t;
int longl;
bool f=false,af=true;
int main(){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<string>());
	longl=max(s.length(),t.length());
	for(int i=0;i<longl;i++){
	if(s[i]!=t[i]) af=false;
	if(s[i]<t[i]) f=true;
	}
	if(af=true){
		if(s.length()<t.length()) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else if(f==true) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}*/
int n,a[100001],f;
int ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int now=0,mcount=0;
	for(int i=0;i<n;i++){
		if(now!=a[i]) {
			if(mcount>now) ans+=mcount-now;
			else if(mcount<now) ans+=mcount;
			now=a[i];
			mcount=1;
		}
		else mcount++;
	}
	if(mcount>now) ans+=mcount-now;
	else if(mcount<now) ans+=mcount;
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 1e9 + 7;

ll N;
ll sum = 0;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    vl a(N); F0R(i, N) cin >> a[i];
    F0R(bits, 60) {
        ll zc = 0, oc = 0;
        ll idsum = 0;
        F0R(j, N) {
            if (a[j] & (1ll << bits)) oc++;
            else zc++;
        }
        idsum = ((oc % MOD) * (zc % MOD)) % MOD;
        idsum = ((idsum % MOD) * ((1ll << bits) % MOD)) % MOD;;
        
        sum = ((sum % MOD) + (idsum % MOD)) % MOD;
    }
    cout << sum % MOD;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 2560
s = input()
T = input()

sl = len(s)
Tl = len(T)
res = "UNRESTORABLE"
for i in range(sl)[::-1]:
    piece = s[i:i+Tl]
    if len(piece)<Tl:
        continue
    flag = True
    for j in range(Tl): 
        if piece[j]!='?' and piece[j]!=T[j]:
            flag = False 
            break
    if flag:
        res = s[:i]+T+s[i+Tl:]
        res = res.replace("?","a")
        break
print(res)


Measured memory_bytes: 3064
line = gets.split(' ').map(&:to_f)
a=line[0]
b=line[1]
c=0
d=0
while c==0 do
	if (d*0.08).floor==a.to_i && (d*0.10).floor==b.to_i then
      c=1
      puts d
    end
    d=d+1
    if d>=1010 then
      c=1
      puts -1
    end
end

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int main(){
    double r;
    cin >> r;
    cout << r * 2 * M_PI << endl;;

    return 0;
}

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

int main(){
	int a, n, i, j, z, s[10000], ans_max, ans_min;
	while(scanf("%d", &n) != EOF){
		ans_max = 2;
		ans_min = 0;
		s[0] = 2;
		a = 1;
		for(i = 3; i < 75000;i += 2){
			z = 0;
			for(j = 0; s[j] * s[j] <= i; j++){
				if(i % s[j] == 0){
					z = 1;
					break;
				}
			}
			if(z == 0){
				s[a] = i;
				a++;
				if(i < n) ans_max = i;
				else if(i > n){
					ans_min = i;
					break;
				}
			}
		}
		printf("%d %d\n", ans_max, ans_min);
	}
	return 0;
}

Measured memory_bytes: 620
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
int main()
{
	int n;
	int v;
	vector<int> a;
	vector<int> mp;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> v;
		a.push_back(v);
	}
	int cnt = 1;
	bool flg = false;
	rep(i, n) {
		if (a[i] == cnt)
		{
			cnt++;
			flg = true;
		}
	}
	if (flg) cout << n - cnt+1 << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int a[5] ;
    int index;
    for(int i = 0 ; i < 5; i++)
    {
        cin >> a[i];
        if(a[i]==0) index = i+1 ;
    }
    cout <<index<<endl ;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
AB = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)][::-1]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [-x for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

uf = UnionFind(N)
ans = []
cnt = N*(N-1)//2
for a, b in AB:
    ans.append(cnt)
    if uf.same(a, b):
        continue
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a, b)
for a in ans[::-1]:
    print(a)

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


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());

	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += vec[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
/*
ID: jerrywcy
LINK: https://atcoder.jp/contests/abc125/tasks/abc125_d
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

const int inf=0x3f3f3f3f;

int n;
int a[100010];
long long f[100010][2];

int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;i++)cin>>a[i];
	
	f[0][0]=0;f[0][1]=-inf;
	for (int i=1;i<=n;i++){
		f[i][0]=max(f[i-1][0]+a[i],f[i-1][1]-a[i]);
		f[i][1]=max(f[i-1][0]-a[i],f[i-1][1]+a[i]);
	}

	cout<<f[n][0]<<endl;

	return 0;
}



Measured memory_bytes: 2176
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[rune]int, 26)
	for _, r := range s {
		m[r]++
	}
	isBeautiful := true
	for _, v := range m {
		if v%2 != 0 {
			isBeautiful = false
			break
		}
	}
	if isBeautiful {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){

    char bee[3];
    int ans=0;
    for(int i = 0;i < 3;i++){
        scanf("%c", &bee[i]);
        if(bee[i]=='1') ans++;
    }

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

    return 0;
}

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

int main(){
    int a=1,ai1,ai2;
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ai1=a*2;
        ai2=a+k;
        if(ai1<ai2){
            a=ai1;
        }else{
            a=ai2;
        }
    }
    cout<<a<<endl;
    
}

    


Measured memory_bytes: 3608
using System;
using System.Text;
using System.Collections.Generic; 
using System.Linq; 
using E = System.Linq.Enumerable; 
class Program { 
  static int[] A;
  static int H = 0; 
  static void Main(string[] args) { 
    var NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); 
    var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); 
    //Aを初期化 
    A = new int[NM[0]+1]; H = NM[0]; 
    for(int i = 1; i < NM[0]+1 ; i++){ A[i] = input[i-1]; } 
    buildMaxHeap(A); 
    
    //割引を行う
    for(int i = 0;i<NM[1];i++){ 
      //最大値を2で割った後に再び挿入 
      Insert(extract(A)/2); 
    }
    long sum = 0; 
    for(int i = 1;i <= H;i++){
      sum += A[i]; 
    } //結果の合計を求める 
    Console.WriteLine(sum); 
  } 
  static void Insert(int key){ 
    H++; A[H] = -1;
    heapIncreaseKey(A,H,key); 
  } static void heapIncreaseKey(int[] A,int i,int key){ 
    A[i] = key; 
    while(i > 1 && A[i/2] < A[i]){ 
      var tmp = A[i]; 
      A[i] = A[i/2]; 
      A[i/2] = tmp; i = i/2; 
    } 
  } 
  static int extract(int[] A){ 
    var result = A[1];
    A[1] = A[H]; 
	H--; 
	var parent = 1;
	var child1 = 0;
	var child2 = 0; 
	var largest =parent; 
	while(true){
      child1 = 2*parent; 
      child2 = 2*parent+1; 
 
 	 if(child2 <= H && A[largest] < A[child2]){
 	  largest = child2;
	 }
	 if(child1 <= H && A[largest] < A[child1]){
	  largest = child1;
	 }
	 if(largest != parent){
 	  var tmp = A[parent];
	  A[parent] = A[largest];
	  A[largest] = tmp;
       parent = largest;
	 }else{
	  return result; 
	 }
    }
  }

  static void maxHeapify(int[] A,int i){ 
    var l = 2*i; 
    var r = 2*i+1; 
    var largest = i; 
    //三つのノードの中で最大のものを選ぶ 
    if(l <= H && A[l] > A[i] ){ 
      largest = l; 
    }else{ 
      largest = i; 
    } 
    if (r <= H && A[r] > A[largest]){ 
      largest = r; 
    } 
    //最大値を交換 
    if(largest != i){ 
      var tmp = A[largest]; 
      A[largest] = A[i]; 
      A[i] = tmp; 
      maxHeapify(A,largest); 
    }
  } 
  static void buildMaxHeap(int[] A){ 
    for(int k = H/2; k > 0;k--){ 
      maxHeapify(A,k); 
    }
  } 
}


Measured memory_bytes: 28636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)

const int N=2000005;

struct edge {int x,y,w;} ;

std:: vector <edge> v;

void add(int x,int y,int w) {
	v.push_back((edge) {x,y,w});
}

int main(void) {
	// freopen("data.in","w",stdout);
	int n,t=0; scanf("%d",&n);
	for (int x=n;x;) x>>=1,t++;
	rep(i,1,t-1) {
		add(i,i+1,(1<<i-1));
		add(i,i+1,0);
	}
	int w=(1<<t-1),x=n-w;
	rep(i,0,20) if (x>>i&1) add(i+1,t,w),w+=(1<<i);
	printf("%d %d\n", t,(int) v.size());
	for (int i=0;i<v.size();++i) {
		printf("%d %d %d\n", v[i].x,v[i].y,v[i].w);
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
 
H, W = map(int, input().split())
 
init_field = [list(input()) for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
 
def bfs(x, y):
    distance = [[-1]*W for _ in range(H)]
    que = deque([])
    que.append((y, x))
    distance[y][x] = 0
    res = 0
    while que:
        y, x = que.popleft()
        res = max(res, distance[y][x])
        for i, j in zip(dx, dy):
            nx = x + i
            ny = y + j
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] == "." and distance[ny][nx] == -1:
                distance[ny][nx] = distance[y][x] + 1
                que.append((ny, nx))
    return res

ans = 0
for sy in range(H):
    for sx in range(W):
        if init_field[sy][sx] == '#':
            continue
        field = [[i for i in row] for row in init_field]
        d = bfs(sx, sy)
        ans = max(ans, d)
print(ans)


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

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> A(n);
    
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }

    cout << (sum >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python
"""AtCoder nomura 2020: A - Study Scheduling - 
https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'

def main():
    H1, M1, H2, M2, K = list(map(int, input().split()))

    minuts = (H2 - H1) * 60 + (M2 - M1)
    print(minuts - K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep1(n) rep2(i,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
int f2(int n){
    return n/2;
}
int f3(int n){
    n=3*n+1;
    return n;
}
int main(){
    int s;
    cin>>s;
    int memo=s;
    int count=1;
    int count2=0;
    while(1){
        count++;
        //cout<<memo<<endl;
        if(memo%2==0)memo=f2(memo);
        else memo=f3(memo);
        if(memo==s)break;
        if(memo==4){
            count2++;
            if(count2==2)break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

class BIT {
public:
  int n;
  vector<int> bit;
  BIT(int n_) {
    n = n_;
    bit.resize(n + 1);
  }
  void add(int a, int w) {
    a += 1;
    if (a == 0 || a > n)
      return;
    for (int x = a; x <= n; x += x & -x)
      bit[x] += w;
  }
  int sum(int a) {
    if (a == 0)
      return 0;
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x)
      ret += bit[x];
    return ret;
  }
};

int main() {
  int n;
  cin >> n;
  vector<pair<char, int>> ca(n * 2);
  for (int i = 0; i < n * 2; i++)
    cin >> ca[i].first >> ca[i].second;
  vector<vector<int>> dp(2001);
  for (int i = 0; i < 2001; i++)
    dp[i].resize(2001);
  vector<int> binv(n), winv(n);
  for (int i = 0; i < n * 2; i++)
    if (ca[i].first == 'B')
      binv[ca[i].second - 1] = i;
    else
      winv[ca[i].second - 1] = i;
  BIT white(1 << 13), black(1 << 13);
  for (int i = 0; i < n * 2; i++) {
    if (ca[i].first == 'B')
      black.add(i, 1);
    else
      white.add(i, 1);
  }
  for (int i = 0; i <= n; i++) {
    BIT moved(1 << 13), moved2(1 << 13);
    for (int j = 0; j < i - 1; j++) {
      moved.add(winv[j], 1);
      moved2.add(winv[j], 1);
    }
    if (i == 0) {
      for (int j = 0; j < n; j++) {
        if (j == 0) {
          dp[0][1] =
              black.sum(binv[0]) + white.sum(binv[0]) - moved.sum(binv[0]);
          moved.add(binv[0], 1);
          continue;
        }
        dp[0][j + 1] = dp[0][j] + black.sum(binv[j]) + white.sum(binv[j]) -
                       moved.sum(binv[j]);
        moved.add(binv[j], 1);
        continue;
      }
    } else {
      for (int j = 0; j <= n; j++) {
        if (j == 0) {
          dp[i][j] = dp[i - 1][j] + black.sum(winv[i - 1]) +
                     white.sum(winv[i - 1]) - moved.sum(winv[i - 1]);
          continue;
        }
        moved.add(binv[j - 1], 1);
        dp[i][j] = dp[i - 1][j] + black.sum(winv[i - 1]) +
                   white.sum(winv[i - 1]) - moved.sum(winv[i - 1]);
      }
      moved2.add(winv[i - 1], 1);
      for (int j = 0; j < n; j++) {
        dp[i][j + 1] =
            min(dp[i][j + 1], dp[i][j] + black.sum(binv[j]) +
                                  white.sum(binv[j]) - moved2.sum(binv[j]));
        moved2.add(binv[j], 1);
      }
    }
  }
  cout << dp[n][n] << endl;

  return 0;
}


Measured memory_bytes: 16128
#include <stdio.h>

int main(void) {
	long int S;
	int d;
	int i;
	while (scanf("%d", &d) != EOF) {
		S = 0;
		for (i = 0; d*i < 600; i++)
			S += d * (d*i)*(d*i);
		printf("%ld\n", S);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>

using namespace std;

int main() {
	char in, out;
	scanf("%c", &in);
	switch(in) {
	case 'A':printf("T\n");
			 break;
	case 'T':printf("A\n");
			 break;
	case 'G':printf("C\n");
			 break;
	case 'C':printf("G\n");
	}
	return 0;
}


Measured memory_bytes: 256
def change(c)
  return 1 if c == 'I'
  return 5 if c == 'V'
  return 10 if c == 'X'
  return 50 if c == 'L'
  return 100 if c == 'C'
  return 500 if c == 'D'
  return 1000 if c == 'M'
  return 0
end

while gets do
  a = 0
  s = $_.split("")
  (s.size).times do |i|
    if change(s[i]) >= change(s[i+1]) then
      a += change(s[i])
    else
      a -= change(s[i])
    end
  end
  puts a
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	ll n,i,j,k,a[1000006],dp[1000006];
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	for(i=0;i<=k;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[j]<=i&&dp[i - a[j]]==0)
			dp[i]=1;
		}
	}
	if(dp[k])
	cout<<"First"<<endl;
	else
	cout<<"Second"<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 10112
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

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

using namespace std;
int main(){
  string input;
  cin >> input;
  if(input.find("a") <= 1000000 &&
	 input.find("b") <= 1000000 &&
	 input.find("c") <= 1000000 ){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  cin >> n >> m;
  if(n <= m)print(n);
  else print(n-1);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char C[2][4];
    rep(i, 0, 2) scanf("%s", C[i]);
    if(C[0][0]==C[1][2]&&C[0][1]==C[1][1]&&C[0][2]==C[1][0])
        printf("YES\n");
    else printf("NO\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc076/tasks/abc076_c

int main() {
    string S, T; cin >> S >> T;

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string min = "~";
    REP(i, S.length()-T.length()+1) {
        string sub = S.substr(i, T.length());

        bool can = true;
        REP(j, T.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }

        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }

            REP(j, P.length()) {
                if (P[j] == '?') P[j] = 'a';
            }

            min = std::min(min, P);
        }
    }

    if (min == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << min << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner; 
 public class Main {
   public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
       
    int h ;
    int w ;
       while(true){
           
            h = sc.nextInt();
            w = sc.nextInt();
           
           if(h==0&&w==0)break;
       for(int i=0;i<h;i++){
         for(int j=0;j<w;j++){
             
             if(i==0||i==(h-1)||j==0||j==(w-1)){
               System.out.print("#");
             }else{
               System.out.print(".");   
             }
             
         }
           System.out.println(); 
       }
           System.out.println();
       }
   }
 }


Measured memory_bytes: 34824
mod = 10 ** 9 + 7

N = int(input())
A = [(int(input()), -1) for _ in range(N)]
B = [(int(input()), 1) for _ in range(N)]

C = sorted(A + B)

res = 1
cnt = 0
for _, delta in C:
    if cnt != 0 and cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

Measured memory_bytes: 27652
n,c,k=map(int,input().split())
t=[]
for i in range(n):
    t.append(int(input()))
t.sort()
ans=0
i=0
y=c
while i<n:
    s=t[i]
    y=c-1
    i+=1
    while y>0 and i<n:
        if t[i]<=s+k:
            y-=1
            i+=1
        else:
            break
    ans+=1
print(ans)

Measured memory_bytes: 7384
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h,w,k;
	cin>>h>>w>>k;
	// int a[h][w];
	string s[h];
	rep(i,h){
		cin>>s[i];
	}
	int ans = 0;
	rep(maskrow,(1<<h)){
		rep(maskcol,(1<<w)){
			string temp[h];
			rep(i,h){
				temp[i] = s[i];
			}
			rep(i,w){
				if((1<<i) & maskcol){
					rep(j,h){
						temp[j][i] = '&';
					}
				}
			}
			rep(i,h){
				if((1<<i) & maskrow){
					rep(j,w){
						temp[i][j] = '&';
					}
				}
			}
			int c = 0;
			rep(i,h){
				rep(j,w){
					if(temp[i][j] == '#')c++;
				}
			}
			// rep(i,h){
			// 	cout<<temp[i]<<"\n";
			// }
			// cout<<"\n\n";
			if(c == k){
				ans++;
				// cout<<"{\n\n";
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a)%mod;
    return k%2 ? (a*n)%mod : a;
}

ll waru(ll n , ll m){
    ll M=ruijou(m,mod-2);
    return n*M%mod;
}

int main(){
    ll N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d[i];
    vec s;
    rep(i,N-1) s.pb(d[i+1]-d[i]);
    ll memory=1;
    ll ans=0;
    rep(i,N-1){
        ans=(ans+(memory*s[i])%mod)%mod;
        memory=(memory+waru(1,i+2))%mod;
    }
    REP(i,1,N) ans=(ans*i)%mod;
    cout<<ans<<endl;

}

Measured memory_bytes: 2168
//Optimize
#pragma GCC optimize("Ofast")

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

#define il inline

//Variable
#define ll long long
#define ull unsigned long long
#define db double
#define lb long double
#define ui unsigned int

//Debug
#define B cerr<<"Break Point"<<endl;
#define P(x) cerr<<#x<<' '<<"="<<' '<<(x)<<endl;
#define p(x) cerr<<#x<<' '<<"="<<' '<<(x)<<' ';
#define ml(x) cerr<<"Size of array is "<<x*4/1024/1024<<" MB"<<endl;

//Vector
#define vc vector
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define vbe(x) x.begin(),x.end()

//Memset
#define ms(x) memset(x,0,sizeof(x))
#define MS(x) memset(x,0x3f3f3f3f,sizeof(x))

//Pair
#define fi first
#define se second

//File

#define fin(x) freopen(x,"r",stdin)
#define fou(x) freopen(x,"w",stdout)
void fio()
{
    #ifndef ONLINE_JUDGE
    freopen("sample.in","r",stdin);
    freopen("sample.out","w",stdout);
    #endif
}
void pti()
{
    double timeuse = clock()*1000.0/CLOCKS_PER_SEC;
    cerr<<"Timeuse "<<timeuse<<"ms"<<endl;
}
void end()
{
    pti();
    exit(0);
}

//Inf
#define INF 0x3f3f3f3f
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))

//IO
#define pc(s) putchar(s)
#define say(s) cout<<s<<endl
namespace io
{
    const int SIZ=55;int que[SIZ],op,qr;char ch;
    template<class I>
    il void gi(I &w)
    {
        ch=getchar(),op=1,w=0;
	while(!isdigit(ch)){if(ch=='-') op=-1;ch=getchar();}
        while(isdigit(ch)){w=w*10+ch-'0';ch=getchar();}w*=op;
    }
    template<typename T,typename... Args>
    il void gi(T& t,Args&... args){gi(t);gi(args...);}
    template<class I>
    il void print(I w)
    {
        qr=0;if(!w) putchar('0');if(w<0) putchar('-'),w=-w;
	while(w) que[++qr]=w%10+'0',w/=10;
        while(qr) putchar(que[qr--]);
    }
}
using io::gi;
using io::print;

int n,r;

int main()
{
    gi(n,r);
    if(n>=10) print(r);
    else print(r+100*(10-n));
    end();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

struct HyperUnionFind {
	std::vector<int> data;
	std::vector<i64> w, sz;
	
	HyperUnionFind(int n) {
		data.assign(n, -1);
		w.assign(n, 0);
		sz.assign(n, 0);
	}
	void set(int k, int x) {
		w[k] = x;
	}
	i64 unite(int x, int y) {
		x = find(x); y = find(y);
		if(x == y) {
			sz[x]++;
			return w[x];
		}
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		w[x] += w[y];
		w[y] = 0;
		sz[x] += sz[y] + 1;
		sz[y] = 0;
		data[y] = x;
		return w[x];
	}
	int find(int k) {
		if(data[k] < 0) return k;
		return find(data[k]);
	}
	int get(int k) {
		k = find(k);
		int ret = sz[k];
		sz[k] = 0;
		return ret;
	}
};
	
int main() {
	int n, m; scanf("%d%d", &n, &m);
	HyperUnionFind uf(n);
	for(int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		
		uf.set(i, a);
	}
	std::vector<std::pair<int, std::pair<int, int>>> vec;
	for(int i = 0; i < m; i++) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		
		vec.push_back({c, {a - 1, b - 1}});
	}
	sort(begin(vec), end(vec));
	
	int ans = 0;
	for(auto v : vec) {
		int a = v.second.first, b = v.second.second, w = v.first;
		
		if(uf.unite(a, b) >= w) {
			ans += uf.get(a);
		}
	}
	printf("%d\n", m - ans);
	return 0;
}


Measured memory_bytes: 3832
#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>
#include<stdio.h>
#include <cstdint>
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;

int a, b, c, d;

int main(void) {

	cin >> a >> b >> c >> d;

	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([i32]);
    v.sort();
    // eprintln!("{:?}", v);
    let sum: i32 = v.iter().sum();
    let avg: i32 = (sum as f64 / v.len() as f64).round() as i32;
    // eprintln!("sum: {}, avg: {}", sum, avg);
    let mut ans = 0;
    for i in 0..n {
        let t = (avg - v[i]).abs().pow(2);
        ans += t;
    }
    println!("{}", ans);
}


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

const ll MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;

    vector<bool> issafe(n + 1, true);
    rep(i, m) {
        int a;
        cin >> a;
        issafe[a] = false;
    }

    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    if(issafe[1]) dp[1] = 1;

    for(int i = 2; i <= n; i++) {
        if(issafe[i - 1]) dp[i] += dp[i - 1];
        if(issafe[i - 2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }

    cout << dp[n] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <complex>
#include <regex>
#include <random>
using namespace std;

#define rep(i,n)	for(lint i = 0; i < n; i++)
#define repr(i,n)	for(lint i = n - 1; i >= 0; i--)
#define repi(i,ini,n)	for(lint i = ini; i < n; i++)
#define repir(i,ini,n)	for(lint i = n-1; i >= ini; i--)
#define repb(i,start,end)	for(lint i = start; i <= end; i++)
#define repbr(i,start,end)	for(lint i = end; i >= start; i--)

#define bit(n)				(1LL << (n))

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rg(v, ini, end) v.begin() + ini, v.begin()+end

#define ret return 0;
#define chmax(a, b) a=mmax(a,b)
#define chmin(a, b) a=mmin(a,b)

using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy
{
	lint x, y;
	xy() :x(0), y(0) {}
	xy(lint _x, lint _y) : x(_x), y(_y) {}
	xy operator+(const xy& p) const
	{
		return xy(x + p.x, y + p.y);
	}
	bool operator<(xy p) const
	{
		if (y == p.y)
			return x < p.x;
		return y < p.y;
	}
};
struct xyd
{
	ld x, y;
	xyd() :x(0), y(0) {}
	xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template<class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>>
{
public:
	vec2() {}
	vec2(lint n) : vector(n) {}
	vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
	vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};

template<class T> using priq = priority_queue<T>;
template<class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
template<class Key, class Val> using hashmap = unordered_map<Key, Val>;
template<class Key> using hashset = unordered_set<Key>;

mt19937 mtrand((random_device())());

const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;

constexpr lint div2(lint p, lint q)
{
	return (p + q - 1) / q;
}

#if(__cplusplus < 201703L)

	lint gcd(lint a, lint b) {
		while (1) {
			if (a < b) swap(a, b);
			if (!b) break;
			a %= b;
		}
		return a;
	}

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

#endif

template<class T>
struct nval {
	lint n;		// counts
	T val;
	nval() : n(0) {};
	nval(lint _n, T _val) : n(_n), val(_val) {};
};

template<class It, class It2>
auto spacel(It i, It2 end)
{
	if (i + 1 == end)
	{
		return '\n';
	}
	else
	{
		return ' ';
	}
}

ostream& setp(ostream& ost)
{
	cout << setprecision(60) << fixed;
	return ost;
}

const ulint mod = 1000000007;
//const ulint mod = 998244353;
const ld eps = 0.0000001;

int main()
{
	string s;
	cin >> s;
	s += s;
	string p;
	cin >> p;
	rep(i, s.length() - p.length() + 1)
	{
		if (s.substr(i, p.length()) == p)
		{
			cout << "Yes" << endl;
			ret;
		}
	}
	cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>

int main(void)
{
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  
  if((B / A) >= C){
    printf("%d", C);
  }
  else{
    printf("%d", (B / A));
  }
  
  return 0;
}

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

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

void solve(std::string S)
{
    int len = S.length();
    int center = (len - 1) / 2;

    for (int i = 0; i < len / 2; i++)
    {
        char left = S[i];
        char right = S[len - 1 - i];

        char cleft = S[center - 1 - i];
        char cright = S[center + 1 + i];

        if (left != right)
        {
            cout << NO << endl;
            return;
        }

        if (i < len / 4 && (left != cleft || right != cright))
        {
            cout << NO << endl;
            return;
        }
    }

    cout << YES << 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()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

int p[105];

int main(){
    int x, n;
    cin >> x >> n;
    rep(i, 105) p[i] = 0;
    rep(i, n){
        int pi;
        cin >> pi;
        p[pi] = 1;
    }

    int i = 0;
    while(1){
        if (p[x-i] == 0) {
            cout << x-i << endl;
            return 0;
        }
        if (p[x+i] == 0){
            cout << x+i << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstring>
using namespace std;
string s;int len,turn=0;
inline void game()
{
	for(int i=1;i<=len-1;++i)
	{
		if(s[i-1]!=s[i+1])
		{
			s.erase(s.begin()+i);
			len--;turn++;
			game();return;
		}
	}
	return;
}
int main()
{
	cin>>s;
	len=s.length()-1;
	game();
	if(turn%2==0)cout<<"Second";
	else cout<<"First";
	return 0;
}

Measured memory_bytes: 640
import java.util.*;


public class Main {
  static int N, K;
  static boolean[] D;
  static int A;

  public static boolean isOK() {
    int a = A;
    while(a > 0) {
      if(D[a % 10]) return false;
      a = a / 10;
    }
    return true;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    N = sc.nextInt();
    K = sc.nextInt();
    D = new boolean[10];
    for(int i = 0; i < K; i++) {
      int d = sc.nextInt();
      D[d] = true;
    }

    A = N;
    while(!isOK()) A++;

    System.out.println(A);
  }
}


Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define first    ff
#define second   ss
#define pi       acos(-1.0)
#define test     int t;cin>>t;while(t--)
typedef long long ll;
using namespace std;
int a[28],b[28];

int main()
{      
     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
     ll a,b,c,d;
     cin>>a>>b>>c>>d;

     cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
      
    
      return 0;
      
 }       


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    vector<int> key(n);
    rep(i,n) cin >> key[i];
    int x = 0;
    string str;
    cin >> str;
    while(key.size() < str.size()){
      if(x==key.size()) x = 0;
      key.push_back(key[x]);
      x++;
    }
    rep(i,str.size()){
      rep(j,key[i]){
        if(str[i]=='a') str[i] = 'Z';
        else if(str[i]=='A') str[i] = 'z';
        else str[i]--;
      }
    }
    rep(i,str.size()) cout << str[i];
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int v[] = getIntArray(n);
		Arrays.sort(v);
		double d = v[0];
		for ( int i = 1 ; i < n ; i++ ) {
			d += v[i];
			d /= 2D;
		}

		System.out.println( d );
	}
}


Measured memory_bytes: 21332
import math
x = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
a = 1

while a == 1:

    if  is_prime(x) == True:
        ans = x
        a = 0
    else:
        x += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    char c;
    cin >> c;
    /*cout << c << endl;//そのまま
    cout << char (c) << endl;//そのまま

    cout << int (c) << endl;
    cout << int(c)+1 << endl;
    cout << "What" <<c + 1 << endl;*/
    
    cout << char(int(c)+1) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;

    int s;
    if (n % 2 == 0) {
        cout << n * (n-1) / 2 - n/2 << endl;
        s = n+1;
    } else {
        cout << n * (n-1) / 2 - (n-1)/2 << endl;
        s = n;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            if (i + j == s) continue;
            cout << i << " " << j << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    set<int> S;
    rep(i, 0, 3) {
      int x; cin >> x;
      S.insert(x);
    }
    cout << S.size() << endl;
    return 0;
}



Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()
tmp = 1
spl = []
for i in range(1,n):
  if s[i-1] == s[i]:
    tmp += 1
  else:
    spl.append(tmp)
    tmp = 1
spl.append(tmp)
#print(spl)
l = len(spl)
acu = [0]
for m in range(l):
  acu.append(acu[-1]+spl[m])
acu = [0] + acu + [acu[-1]]
#print(acu)
can = []
if s[0] == '0':
  st = 0
else:
  st = 1
while True:
  try:
    can.append(acu[st+2*k+1]-acu[st])
    st += 2
  except:
    break
try:
  print(max(can))
except:
  print(n)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
const int N = 2e5 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll n, m, a, b, d[N], d2[N];
vector <int> g[N];
void dfs(int v, int p)
{
    d[v] = 1;
    for(auto to : g[v])
    {
        if(to != p)
        {
            dfs(to, v);
            (d[v] *= (d[to] + 1) % m) %= m;
        }
    }
}

void dfs2(int v, int p)
{
    ll l = 1;
    if(p == 0)d2[v] = 1;
    for(auto to : g[v])
    {
        if(p != to)
        {
            d2[to] = l;
            (l *= (d[to] + 1) % m) %= m;
        }
    }
    l = 1;
    reverse(g[v].begin(), g[v].end());
    for(auto to : g[v])
    {
        if(p != to)
        {
            (d2[to] *= l) %= m;
            (l *= (d[to] + 1) % m) %= m;

            (d2[to] *= d2[v]) %= m;
            (d2[to] += 1) %= m;
            dfs2(to, v);
        }
    }
}

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1, 0);
    dfs2(1, 0);
    for(int i = 1; i <= n; i++)cout << (d[i] * d2[i]) % m << endl;
}



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

int main(){
    ll n,k; cin >> n >> k;
    if(2*n < k) cout << 0 << endl;
    else{
        if(k % 2 == 1){
            ll a = n / k;
            cout << a*a*a << endl;
        }else{
            ll a = n / k;
            ll b = (n-k/2)/k + 1;
            cout << a*a*a + b*b*b << endl;
        }
    }
}

Measured memory_bytes: 256