akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	string S;
	cin >> S;

	int kotae = 1;
	rep(i, N - 1) {
		if (S[i] != S[i + 1]) kotae++;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 512
N, K, Q = map(int, input().split())
A = []
result = [K] * N
answers = [0] * N

for _ in range(Q):
    A.append(int(input()) - 1)


for i in A:
    answers[i] += 1

result = list(map(lambda x: x-Q, result))

for i in range(N):
    result[i] += answers[i]

for i in list(map(lambda x: "Yes" if x > 0 else "No", result)):
    print(i)



Measured memory_bytes: 60376
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S = list(input())
N = len(S) - 1

ans = 0
for i in range(2 ** N):
    count = 0
    tmp = int(S[0])
    for j in range(N):
        if (i >> j) & 1:
            count += tmp
            tmp = int(S[j + 1])
        else:
            tmp = 10 * tmp + int(S[j + 1])
    count += tmp
    ans += count

print (ans)

Measured memory_bytes: 3064
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	a, b := readInt2()

	if a < b {
		fmt.Println(strings.Repeat(strconv.Itoa(a), b))
	} else {
		fmt.Println(strings.Repeat(strconv.Itoa(b), a))
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
const int maxn = 1+10e5;

vector<bool> visited(maxn,false);
vector<vector<int>> edges(maxn);
vector<long long int> dp(maxn);

void dfs(int u){
    visited[u] = 1;
    for(int v: edges[u]){
        if(!visited[v])
            dfs(v);
        
        dp[u] = max(dp[u],dp[v]+1);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
    }
    for(int i=1; i<=n;i++)
        edges[0].push_back(i);
    dfs(0);
    cout<<dp[0]-1<<endl;   
    return 0;
}

Measured memory_bytes: 37368
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int t;
    for(int i=1;i<=9;++i){
        int t=N/i;
        if(t<=9 && t*i==N){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        int[]A = new int[N+1];
        A[0] = 0;
        for(int i = 1; i <= N; i++) A[i] = K-Q;

        for(int i = 0; i < Q; i++){
            int a = sc.nextInt();
            A[a]++; 
        }

        for(int i = 1; i <= N; i++){
        if(A[i] > 0) System.out.println("Yes");
        else System.out.println("No");
    }


    }
} 

Measured memory_bytes: 67752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,x;cin >> n >> m >> x;
    vector<vector<pair<int,int>>> g(n);
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    for(int i=0;i<m;i++){
        int a,b,t;cin >> a >> b >> t;
        a--,b--;
        g[a].push_back({b,t});
        g[b].push_back({a,t});
    }
    priority_queue<pair<ll,pair<ll,ll>>,vector<pair<ll,pair<ll,ll>>>,greater<pair<ll,pair<ll,ll>>>> pq;
    vector<ll> d(n,INF);
    d[0]=0;
    pq.push({0,{0,x}});
    ll ans=INF;
    vector<int> r(n);
    while(!pq.empty()){
        ll u=pq.top().first,v=pq.top().second.first,w=pq.top().second.second;
        pq.pop();
        if(v==n-1){
            chmin(ans,u+h[n-1]-w);
        }
        for(auto x:g[v]){
            ll p=x.first,q=x.second;
            if(q>h[v]){
                continue;
            }
            if(w-q>h[p]){
                ll res=u+q+w-q-h[p];
                ll l=h[p];
                if(res<d[p]){
                    d[p]=res;
                    r[p]=l;
                    pq.push({res,{p,l}});
                }
                else if(res==d[p]){
                    if(r[p]<l){
                        r[p]=l;
                        pq.push({res,{p,l}});
                    }
                }
            }
            else if(w-q<0){
                ll res=u+q+abs(w-q);
                if(res<d[p]){
                    d[p]=res;
                    r[p]=0;
                    pq.push({res,{p,0}});
                }
            }
            else{
                ll res=u+q;
                ll l=w-q;
                if(res<d[p]){
                    d[p]=res;
                    r[p]=l;
                    pq.push({res,{p,l}});
                }
                else if(res==d[p]){
                    if(r[p]<l){
                        r[p]=l;
                        pq.push({res,{p,l}});
                    }
                }
            }
        }
    }
    if(ans==INF){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
}


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

// Macros
#define PRAGMA(x) _Pragma(#x)
//
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
//
#define ALL(container)   container.begin(),container.end()
#define MAKE_UNIQUE(vec) do { PRAGMA(message "DO NOT FORGET TO SORT THE VECTOR !!!"); vec.erase(unique(ALL(vec)),vec.end()); } while(0)
// vec.resize() sucks, use vec.assign()
// comparator -> return <

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v)  { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(__attribute__((unused)) istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

const ld PI = acosl(-1);

signed main() {
	std::ios::sync_with_stdio(false); //Warning: Do NOT use C I/O now.
	std::cin.tie(nullptr); //Note: Comment out this line for interactive questions.
	// std::cout.setf(std::ios::fixed); std::cout.precision(20); //Note: To output decimals correctly.

	// int tt; cin >> tt;
	// for(int test_no = 1; test_no <= tt; ++test_no){}

	int n, m;
	cin >> n >> m;

	vector<vector<int>> adj(n);
	while(m--){
		int u, v;
		cin >> u >> v;
		--u, --v;
		adj[u].PB(v);
		adj[v].PB(u);
	}

	vector<int> signposts(n, -1);

	queue<int> q;
	vector<bool> visited(n, false);

	visited[0] = true;
	q.push(0);

	while(not q.empty()){
		int curr = q.front();
		q.pop();

		for(auto ng: adj[curr]){
			if(visited[ng]) continue;
			visited[ng] = true;
			q.push(ng);
			signposts[ng] = curr + 1;
		}
	}

	trace(signposts);

	if(count(1 + ALL(signposts), -1)){
		cout << "No\n";
	}
	else{
		cout << "Yes\n";
		for(int i = 1; i < n; ++i) cout << signposts[i] << "\n";
	}
}


Measured memory_bytes: 10264
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    h,w = map(int, input().split())
    n = h*w
    if h == 1 or w ==1:
        print(1)
    elif n%2 == 0:
        print(n//2)
    else:
        print(n//2+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define N (1<<17)
#define pii pair<int, int>
#define F first
#define S second

using namespace std;

int n, m, d[N];
vector<int> g[N];
bitset<N> b;

int dfs(int i){
	if(b[i]) return d[i];
	b[i] = 1;

	for(int j : g[i]){
		d[i] = max(d[i], dfs(j)+1);
	}

	return d[i];
}

int main(){

	cin >> n >> m;

	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
	}

	int ans = 0;
	for(int i=1; i<=n; i++) ans = max(ans, dfs(i));

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 8192
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll n, k;
ll bit[100010], ans;
string S;

bool used[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	cin >> n >> k >> S;
	ll di = 1;
	for (int i = 1; i < S.length(); i++)
	{
		if (S[i] != S[i - 1])
		{
			di++;
		}
	}
	
	di -= 2 * k;

	cout << n - max((ll)1, di) << endl;

	int www;
	cin >> www;
}


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

int main()
{
	char card[201],temp[201];
	int h,m;
	while(1){
		cin >> card;
		if(card[0] ==  '-') break;
		cin >> m;
		int n = strlen(card);
		for(int i = 0;i < m;i++) {
			cin >> h;
			for(int j = 0;j < h;j++) temp[j] = card[j];
			for(int k = 0;k < n;k++){
				if(k < n - h) card[k] = card[k + h];
				else card[k] = temp[k + h - n];
				}
		}
			cout << card << endl;	
	}	
		
		return 0;
		}
		
	

Measured memory_bytes: 3056
from collections import deque
num=int(input())
a=deque()
for i in range(num):
    tmp=input().split()
    if tmp[0]=="insert":
        a.appendleft(tmp[1])
    if tmp[0]=="delete":
        if tmp[1] in a:
            a.remove(tmp[1])
    if tmp[0]=="deleteFirst":
        a.popleft()
    if tmp[0]=="deleteLast":
        a.pop()
print(" ".join(a))


Measured memory_bytes: 69732
n=int(input())
h=list(map(int,input().split()))

maxcnt=0
st=0
while st < n-1:
    cnt=0
    j=st
    while j < n-1:
        if h[j+1] <= h[j]:
            cnt +=1
            j += 1
        else:
            break
    if cnt>maxcnt:
        maxcnt=cnt
    st = j+1

print(maxcnt)

Measured memory_bytes: 63984
//break the given number into digits , check if that digit is present in the given number if flag==0 
//then skip and print else increase the number by 1 and check again.... 

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

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

  vector<int> v;
  
  for(int i = 0; i < k; ++i){
    int s;
    cin >> s;
    v.push_back(s);
  }

  while(true){
    int d = n;
    int flag = 0;
    while(d > 0){
      for(int i = 0; i < v.size(); ++i){
        if(d%10 == v[i])
          flag++;
      }
      d /= 10;
    }
    if(flag == 0)
      break;
    ++n;
  }

  cout << n << endl;

  return 0;
}


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

def main():
    a, b, c, d = map(int, input().split())

    if a + b > c + d:
        print('Left')
    elif a + b == c + d:
        print('Balanced')
    elif a + b < c + d:
        print('Right')


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b,i,j,n;
	cin>>n;
	
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes";return 0;
			}
		}
	}
	cout<<"No";
	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++)
using ll = long long;

int main() {
    int s,w;
    cin >> s >> w;

    if (w >= s) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;


template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  for(int i = 0; i*r <= n; ++i) {
    for(int j = 0; j*g+i*r <= n; ++j) {
      if((n-j*g-i*r)%b == 0) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> to(N), cost(N); //長さNのグラフ, コスト
  for(int i=0; i<N-1; i++){
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    to[a].push_back(b);
    cost[a].push_back(w);
    to[b].push_back(a);
    cost[b].push_back(w);
  }

  vector<int> ans(N, -1);
  queue<int> q;

  ans[0] = 0;
  q.push(0);

  while(!q.empty()) {
    int v = q.front(); // 先頭要素の参照
    q.pop(); // 先頭要素の削除

    for(int i=0; i<to[v].size(); i++) { // edge v につながっている辺i=0, 1, ...を見る
      int u = to[v][i]; //つながっている先のedge
      int w = cost[v][i]; // 距離

      if(ans[u]!=-1) continue; //すでに塗ってあれば飛ばす
      ans[u]=(ans[v]+w)%2; // uをvからの距離に応じて塗る．
      q.push(u); // 着目先についか
    }
  }

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


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> ans(N+1,0);
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,less<pair<ll,int>>> que;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        que.push(make_pair(a,-i-1));
    }
    que.push(make_pair(0,0));

    priority_queue<pair<ll,int>,vector<pair<ll,int>>,less<pair<ll,int>>> tmp;
    ll a=que.top().first;
    int pos=-que.top().second;
    ll cnt=1;
    que.pop();
    while((int)que.size()){
        ll b=que.top().first;
        int sec=-que.top().second;
        que.pop();
        //cout << a << ' ' << pos << ' ' << b << ' ' << sec << ' ' << cnt << endl;
        if(pos>sec){
            //cout << pos << ' ' << sec << ' ' << cnt << endl;
            ans[pos]=cnt*(a-b);
            while((int)tmp.size()&&tmp.top().first>=b){
                //cout << "tmp " <<  tmp.top().first << ' ' << tmp.top().second << endl;
                ans[pos]+=tmp.top().first-b;
                cnt++;
                tmp.pop();
            }
            cnt++;
            a=b;
            pos=sec;
        }else{
            tmp.push(make_pair(b,-sec));
        }
    }
    for(int i=1; i<=N; i++){
        cout << ans[i] << endl;
    }
}

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

import itertools
import copy

def calc_cost(l_list, x):
    return 10 * (len(l_list) - 1) + abs(sum(l_list) - x)

N, A, B, C = map(int, input().split())
ln = [int(input()) for _ in range(N)]

ans = 1e10
for i in range(1, len(ln) + 1):
    mp = 0
    tmp = copy.copy(ln)
    for tree_a in itertools.combinations(ln, i):
        for t in tree_a:
            tmp.remove(t)
        mp_a = calc_cost(tree_a, A)
        mp += mp_a
        for j in range(1, len(tmp) + 1):
            for tree_b in itertools.combinations(tmp, j):
                for t in tree_b:
                    tmp.remove(t)
                mp_b = calc_cost(tree_b, B)
                mp += mp_b
                for k in range(1, len(tmp) + 1):
                    for tree_c in itertools.combinations(tmp, k):
                        mp_c = calc_cost(tree_c, C)
                        ans = min(ans, mp + mp_c)
                tmp.extend(tree_b)
                mp -= mp_b
        tmp.extend(tree_a)
        mp -= mp_a
print(ans)

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

int main() {
  int n;cin>>n;
  string s;cin>>s;
//  cout << (int)'A' << endl << (int)'Z' << endl;
  for (int i=0; i<s.size();i++){
    if (n + (int)s[i] > 90) cout << (char)(n + (int)s[i] - 26);
    else cout << (char)(n + (int)s[i]);

  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

bool is_palindrome(const int x) {
    string s = to_string(x);
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main(void) {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        if (is_palindrome(i)) {
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3660
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
K = ARRAY[1]

$a = Array.new(N, 1)

K.times do
    gets
    tmp = gets.split.map(&:to_i)
    tmp.each do |e|
        $a[e - 1] = 0
    end
end

puts $a.select{|v| v == 1}.count


Measured memory_bytes: 14344
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0; i<=a; i++) {
		for(int j=0; j<=b; j++) {
			for(int k=0; k<=c; k++) {
				if(i*500+j*100+k*50==x) {
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<cmath>
using namespace std;
using ll = long long;
using P = pair<double,double>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(15);
}
double size(double x,double y){
  return sqrt(x*x+y*y);
}
void solve(P p,P p1,P p2){
  double nume = (p.first-p1.first)*(p2.first-p1.first) 
    + (p.second-p1.second)*(p2.second-p1.second);
  double deno = size(p2.first-p1.first,p2.second-p1.second);
  deno *= deno;
  double d = nume / deno;
  P m = P(p1.first + (p2.first-p1.first)*d ,
      p1.second + (p2.second-p1.second)*d);
  P ans = P(2*m.first - p.first ,
    2*m.second - p.second);
  if(abs(ans.first)<1e-15) ans.first = 0;
  if(abs(ans.second)<1e-15) ans.second = 0;
  cout << ans.first <<" "<<ans.second << endl;
}
signed main(){
  init_io();
  double xp1,yp1,xp2,yp2,x,y;
  cin >> xp1 >> yp1 >> xp2 >> yp2;
  P p1 = P(xp1,yp1),p2 = P(xp2,yp2);
  ll q;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> x >> y;
    solve(P(x,y),p1,p2);
  }
}



Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K-1]=S[K-1]+32;
    cout << S << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
using namespace std;

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

	vector<int>prime;
	for (int i = 2; i < 55555; i++) {
		int x = i;
		bool is_prime = true;
		for (int j = 2; j*j <= x; j++) {
			if (x%j == 0) {
				is_prime = false;
				while (x%j == 0)x /= j;
			}
		}
		if (is_prime)prime.push_back(x);
	}

	vector<int>prime5_1;
	vector<int>cnt(5);
	for (int i = 0; i < prime.size(); i++) {
		if (prime[i] % 5 == 1)prime5_1.push_back(prime[i]);
	}

	for (int i = 0; i < N; i++) {
		if (i)cout << " ";
		cout << prime5_1[i + 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())
d = list(map(int, input().split()))
counts = [0] * (max(d) + 1)
mod = 998244353

for i in d:
        counts[i] += 1

if counts[0] != 1 or d[0] != 0:
    print(0)
else:
    ans = 1
    for i in range(1, max(d) + 1):
        if counts[i] == 0:
            print(0)
            sys.exit()

        ans *= counts[i-1]**counts[i] % mod

    print(ans % mod)

Measured memory_bytes: 14396
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 31 , 2019
 * 
 */

#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto (i)=0 ; (i)<(x); ++(i))
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;






auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 

    ivv(n);ivv(m);
    cout<<n+(m/2)<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import itertools
ref={5:1,9:2,13:3}
dx=[0,0,1,0,-1,1,1,-1,-1,2,0,-2,0]
dy=[0,-1,0,1,0,-1,1,1,-1,0,2,0,-2]

def isOn(x,y):
    return 0<=x<10 and 0<=y<10

def minus(C,x,y,size):
    for i in range(size):
        C[y+dy[i]][x+dx[i]]-=1
def plus(C,x,y,size):
    for i in range(size):
        C[y+dy[i]][x+dx[i]]+=1

def canMinus(C,x,y,size):
    return all([isOn(x+dx[i],y+dy[i]) and C[y+dy[i]][x+dx[i]]>0 for i in range(size)])

def findAns(C,drops,sp):
    if len(drops)==0:
        return []
    for i in range(sp,100):
        if C[i/10][i%10]>0:
            break
        sp+=1
    for size in set(drops):
        for i in range(size):
            sx,sy=sp%10+dx[i],sp/10+dy[i]
            if isOn(sx,sy) and C[sy][sx]>0:
                if canMinus(C,sx,sy,size):
                    minus(C,sx,sy,size)
                    drops.remove(size)
                    ans=findAns(C,drops,sp)
                    if ans!=False:
                        ans.append([sx,sy,size])
                        return ans
                    drops.append(size)
                    plus(C,sx,sy,size)
    return False
        
n=int(raw_input())
C=[map(int,raw_input().split()) for i in range(10)]
sm=sum([sum(C[i]) for i in range(10)])
dropList=[list(a) for a in itertools.combinations_with_replacement([0,13,9,5],n) if sum(a)==sm]
for drops in dropList:
    ans=findAns(C,drops,0)
    if ans!=False:
        break
for a in ans:
    print a[0],a[1],ref[a[2]]
exit()

Measured memory_bytes: 6672
// diverta2019_2_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 30)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
//struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    int sm = accumulate(ALL(A), 0);

    int ans = -INF;
    int split_idx = -1;
    int tmp_sm = 0;
    REP(i, N-1){
        tmp_sm += A[i];
        if (sm - 2 * tmp_sm >= ans) {
            ans = sm - 2 * tmp_sm;
            split_idx = i;
        }
    }

    print(ans);

    int x = A[0];
    REPN(i, split_idx+1, N-1){
        printf("%d %d\n", x, A[i]);
        x -= A[i];
    }

    print(A[N-1], x);
    x = A[N-1] - x;

    REPN(i, 1, split_idx+1){
        printf("%d %d\n", x, A[i]);
        x -= A[i];
    }


    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    int x;
    cin >> x;

    int g = __gcd(x, 360);
    int l = (x * 360) / g;
    cout << l / x;
    return 0;
}


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

int main(){
	string a;
	cin>>a;
	reverse(a.begin(),a.end());
	int flg=0;
	while(a.size()){
		int az=a.size();
		if(a[0]=='m'){
			string m;
			for(int i=0;i<min(az,5);i++)m.push_back(a[i]);
			if(m=="maerd"){
				a.erase(0,5);
				}
			else{
				flg=1;
				break;
				}	
			}
		else if(a[0]=='e'){
			string m;
			for(int i=0;i<min(az,5);i++)m.push_back(a[i]);
			if(m=="esare")a.erase(0,5);
			else{
				flg=1;
				break;
				}
			}	
		else{
			string m;
			for(int i=0;i<min(az,6);i++)m.push_back(a[i]);
			if(m=="resare")a.erase(0,6);
			else if(m=="remaer"){
				a.erase(0,6);
				if(a.size()&&a[0]=='d'){
					a.erase(0,1);
				}
				else{
					flg=1;
					break;
					}
			}
			else{
				flg=1;
				break;
				}	
			}
		}
	if(flg)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;	
	}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N; cin>>N;
  N++;
  N/=2;
  cout<<N<<endl;
  

 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL n, u, v;
    cin>>n;
    VL g[n+1];
    loop(i,1,n)
    {
        cin>>u>>v;
        g[u].PB(v); g[v].PB(u);
    }

    LL cp, cc, sum = 0;
    cp = 0;
    loop(i,1,n+1)
    {
        cc = cp;
        for(int j : g[i])
        {
            if(j < i) ++cc;
        }
        sum += cc;
        cp = cc;
    }

    LL ne = sum, ans = 0, ans1;
    loop(i,1,n+1)
    {
        for(int j : g[i])
        {
            if(j > i) sum -= (n - j + 1);
        }
        ans1 = ((n - i + 1) * (n - i + 2))/2;
        ans += ans1;
        ne += sum;
    }

    ans -= ne;

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 15776
/*  
     author : masaow    
     g++ : 17.3.20 
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 2e5+7;  
/*  
    time : 09 : 50    
    date : 20.01.2020
*/    
// int L,R,mid,target,q,idx ;
int n ; 
ll W,a[103][2],dp[103][N] ;
ll solve(int idx,ll w) {
    if(idx == -1)
        return 0 ;
    if(dp[idx][w])
        return dp[idx][w] ; 
    ll best  = 0  ;     
    if( w - a[idx][0] >= 0 ) 
        best  += a[idx][1]+solve(idx-1,w-a[idx][0])  ;
    
    best  = max(best,solve(idx-1,w)) ;
    dp[idx][w] = best ;             
    return best  ; 
}    
int solve() {
    cin >> n  >> W ;
    int i,j ;
    forn(i,0,n)
        forn(j,0,2)
            cin >> a[i][j] ; 
 
    cout << solve(n-1,W) << '\n' ; 
  
    return 0 ;  
}
int32_t main(){
    I__O ;  
    int cases = 1 ;
 	// cin >> cases;  
    while(cases--)
	    solve(); 
	return 0 ; 
}

Measured memory_bytes: 155136
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 998244353;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// ll lpow(ll a, ll b){
//   if(b==0) return 1;
//   else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
//   else return lpow(a,b-1) * a;
// }


signed main(){
	int n; cin>>n;
  VI d(n); rep(i,n) cin>>d[i];
  if(d[0]!=0) return cout<<'0'<<endl,0;
  sort(ALL(d));
  ll cnt0=1, cnt1=1, ans=1;

  rep(i,n-1){
    // cerr << i SP d[i] SP cnt0 SP cnt1 SP ans<< endl;
    if(i!=0&&d[i]==0) return cout<<'0'<<endl,0;
    if(d[i]!=d[i+1]){
      if(d[i]+1!=d[i+1]) return cout<<'0'<<endl,0;
      ans *= cnt0;
      ans %= MOD;
      cnt0 = cnt1; cnt1 = 1;
    }else{
      ans *= cnt0;
      ans %= MOD;
      cnt1++;
    }
  }
  ans *= cnt0;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

struct Point {
	int id, x, y;

	bool operator<(const Point& right) const {
		return id < right.id;
	}
};

bool LESS_X(const Point& left, const Point& right) {
	return left.x < right.x;
}

bool LESS_Y(const Point& left, const Point& right) {
	return left.y < right.y;
}

struct Node {
	int location, l, r;
};

const int MAX = 500000;
const int NIL = -1;

Point P[MAX];
Node T[MAX];

vector<Point> ans;

void find(int v, int sx, int tx, int sy, int ty, int depth) {

	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}

	if (T[v].l != NIL) {
		if (depth % 2 == 0) {
			if (sx <= x) {
				find(T[v].l, sx, tx, sy, ty, depth + 1);
			}
		} else {
			if (sy <= y) {
				find(T[v].l, sx, tx, sy, ty, depth + 1);
			}
		}
	}

	if (T[v].r != NIL) {
		if (depth % 2 == 0) {
			if (x <= tx) {
				find(T[v].r, sx, tx, sy, ty, depth + 1);
			}
		} else {
			if (y <= ty) {
				find(T[v].r, sx, tx, sy, ty, depth + 1);
			}
		}
	}
}

int np = 0;
int makeKdTree(int l, int r, int depth) {

	if (!(l < r))
		return NIL;

	if (depth % 2 == 0)
		sort(P + l, P + r, LESS_X);
	else
		sort(P + l, P + r, LESS_Y);

	int t = np++;
	int mid = (l + r) / 2;
	T[t].location = mid;
	T[t].l = makeKdTree(l, mid, depth + 1);
	T[t].r = makeKdTree(mid + 1, r, depth + 1);

	return t;
}

int main() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);

		Point point;
		point.id = i;
		point.x = x;
		point.y = y;
		P[i] = point;

		Node node;
		node.location = node.l = node.r = NIL;
		T[i] = node;
	}

	makeKdTree(0, n, 0);

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);

		ans.clear();
		find(0, sx, tx, sy, ty, 0);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < (int) ans.size(); ++j) {
			printf("%d\n", ans[j].id);
		}
		printf("\n");
	}

	return 0;
}

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

char grade(int i, int j, int k){
    char g;
    if(i == -1 || j == -1) g = 'F';
    else if(i + j >= 80) g = 'A';
    else if(i + j >= 65) g = 'B';
    else if(i + j >= 50) g = 'C';
    else if(i + j >= 30){
        if(k >= 50) g = 'C';
        else g = 'D';
    }
    else g = 'F';
    
    return g;
}

int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        cout << grade(m, f, r) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
def num(card):
    return int(card[0][2:])

def partition(A, p, r):
    x = num(A[r])
    i = p - 1
    for j in range(p, r):
        if num(A[j]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q - 1)
        quicksort(A, q + 1, r)

def is_stable(A):
    for i in range(n - 1):
        if num(A[i]) == num(A[i + 1]) and A[i][1] > A[i + 1][1]:
            return False
    return True

n = int(input())
A = [(input(), i) for i in range(n)]
quicksort(A, 0, n - 1)

print("Stable" if is_stable(A) else "Not stable")
for card in A:
    print(card[0])

Measured memory_bytes: 23948
#include<stdio.h>
#include<string.h>
#define LEN 100005
int min(int x,int y){
  return x<y?x:y;
}
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail==LEN){
    tail=1;
  }
  else tail=tail+1;
}

P dequeue(){
  P x=Q[head];
  if(head==LEN)head=1;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail=n+1,head=1;
  }
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;;
    elaps+=c;
    if(u.t>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11880
/*
Original problem: https://atcoder.jp/contests/abc133/tasks/abc133_a
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int n, a, b;
		cin >>n >>a>>b;
		cout << min(n * a, b) << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())
XYH=[tuple(map(int,input().split())) for i in range(N)]
XYH.sort(key=lambda x:x[2])
a,b,c=XYH[-1]

import sys
for x in range(101):
    for y in range(101):
        H=abs(x-a)+abs(y-b)+c
        F=1
        for i in range(N):
            if max(H-abs(x-XYH[i][0])-abs(y-XYH[i][1]),0)!=XYH[i][2]:
                F=0
                break
        if F:
            print(x,y,H)
            sys.exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
vector<tii> G[100001];
ll x[100001] = {};
void check(int now){
  for(auto t:G[now]){
    int next,dd; tie(next,dd) = t;
    if(x[next] == -INF){
      x[next] = x[now] + dd;
      check(next);
    }
  }
}
int main(){
  int n,m; cin >> n >> m;
  rep(i,100001)  x[i] = -INF;
  rep(i,m){
    int l,r,d; cin >> l >> r >> d;
    G[l].pb(tii{r,d});
    G[r].pb(tii{l,-d});
  }
  for(int i = 1; i <= n; ++i){
    if(x[i] == -INF){
      x[i] = 0;
      check(i);
    }
  }
  
  /*
  for(int i = 1; i <= n; ++i){
    cerr << i << ":" << x[i] << endl;
  }
  */
  
  for(int i = 1; i <= n; ++i){
    for(auto t: G[i]){
      int ll,dd; tie(ll,dd) = t;
      if(x[ll] - x[i] != dd){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
}


Measured memory_bytes: 11392
//#include<bits/stdc++.h>
//using namespace std;
//const int MAXN=100005;
//int N;
//vector<int>adj[MAXN];
//int dist[2][MAXN];
//int type;
//int cnt;
//void dfs(int i,int last=-1)
//{
//	if(last!=-1)
//		dist[type][i]=dist[type][last]+1;
//	for(int j=0;j<adj[i].size();j++)
//		if(adj[i][j]!=last)
//			dfs(adj[i][j],i);
//}
//int main()
//{
//	scanf("%d",&N);
//	for(int i=0;i<N-1;i++)
//	{
//		int x,y;
//		scanf("%d%d",&x,&y);
//		adj[x].push_back(y);
//		adj[y].push_back(x);
//	}
//	type=0;
//	dfs(1);
//	type=1;
//	dfs(N);
//	for(int i=1;i<=N;i++)
//		if(dist[0][i]<=dist[1][i])
//			cnt++;
//	printf("%s\n",cnt>N/2?"Fennec":"Snuke");
//	return 0;
//}
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int N;
int frst;
vector<int>adj[MAXN];
vector<int>vec;
int cnt[MAXN];
void dfs(int i,int last)
{
	cnt[i]=1;
	vec.push_back(i);
	if(i==N)
		frst=vec[(vec.size()+1)/2];
	for(int j=0;j<adj[i].size();j++)
	{
		if(adj[i][j]==last)
			continue;
		dfs(adj[i][j],i);
		cnt[i]+=cnt[adj[i][j]];
	}
	vec.pop_back();
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(1,0);
	printf("%s\n",cnt[frst]*2>=N?"Snuke":"Fennec");
	return 0;
}

Measured memory_bytes: 11256
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    
    d = {}
    for i in range(N):
        if a[i] in d.keys():
            d[a[i]] += 1
        else:
            d[a[i]] = 1
        
        if a[i] + 1 in d.keys():
            d[a[i] + 1] += 1
        else:
            d[a[i] + 1] = 1
        
        if a[i] - 1 in d.keys():
            d[a[i] - 1] += 1
        else:
            d[a[i] - 1] = 1
    
    d_new = sorted(d.items(), key=lambda x: x[1])
    print(d_new[-1][1])

Measured memory_bytes: 23268
#include <iostream>
using namespace std;
int main(){
	int k,sum,t,ret;
	while(cin >> k && k){
		sum = ret = 0;
		for(int i=0;i<k*(k-1)/2;i++){
			cin >> t;
			sum += t;
		}
		cout << sum/(k-1) << endl;
	}
}

Measured memory_bytes: 0