akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


#define int long long 


const int N = 55, inf = 1e17;

int cost[N], n;

string str[N];


int is_pallindrome(string str) {
	string ss = str;
	reverse(ss.begin(), ss.end());
	return ss == str;
}


int dp[52][21][2][2][10001];




int f(int idx, int len, int pref, int suff, int dep) { 
	if(len <= 1) {
		return 0;
	}
	if(pref && is_pallindrome(str[idx].substr(0, len))) {
		return 0;
	}
	if(suff && is_pallindrome(str[idx].substr(str[idx].size() - len, len))) {
		return 0;
	}
	if(dep > 10000) {
		return inf;
	}
	if(~dp[idx][len][pref][suff][dep]) {
		return dp[idx][len][pref][suff][dep];
	}
	int res = inf;
	for(int i = 1; i <= n; i++) {
		if(pref) {
			int k = min(len, (int)str[i].size());
			if(is_pallindrome(str[i].substr(0, k) + str[idx].substr(len - k, k))) {
				if(k < str[i].size()) {
					res = min(res, cost[i] + f(i, str[i].size() - k, 0, 1, dep + 1));
				} else {
					res = min(res, cost[i] + f(idx, len - k, 1, 0, dep + 1));
				}
			}
		} else {
			int k = min(len, (int)str[i].size()), pos = str[idx].size() - len;
			if(is_pallindrome(str[idx].substr(pos, k) + str[i].substr(str[i].size() - k, k))) {
				if(k < str[i].size()) {
					res = min(res, cost[i] + f(i, str[i].size() - k, 1, 0, dep + 1));
				} else {
					res = min(res, cost[i] + f(idx, len - k, 0, 1, dep + 1));
				}
			}
		}
	}
	return dp[idx][len][pref][suff][dep] = res;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	int ans = inf;
	for(int i = 1; i <= n; i++) {
		cin >> str[i] >> cost[i];
		if(is_pallindrome(str[i])) {
			ans = min(ans, cost[i]);
		}
	}
	memset(dp, -1, sizeof dp);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			int n = str[i].size(), m = str[j].size();
			if(n <= m) {
				if(is_pallindrome(str[i] + str[j].substr(m - n, n))) {
					ans = min(ans, cost[i] + cost[j] + f(j, m - n, 1, 0, 1));
				}	
			} else {
				if(is_pallindrome(str[i].substr(0, m) + str[j])) {
					ans = min(ans, cost[i] + cost[j] + f(i, n - m, 0, 1, 1));
				}
			}
		}
	}
	if(ans >= inf) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 347324
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const double pi=acos(-1);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,sum=0,x;
    cin>>n>>m;
    while(m--){ 
        cin>>x;
        sum+=x;
    } 
    ll rem=n-sum;
    cout<<(rem<0?-1:rem)<<'\n';

    return 0;
}


Measured memory_bytes: 3640
package main

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

const mod = 1000000007

func main() {
	stdin.Split(bufio.ScanWords)
	X := getStdin()
	Y := getStdin()

	remainder1 := (2*Y - X)
	remainder2 := (2*X - Y)

	if remainder1 >= 0 && remainder2 >= 0 && remainder1%3 == 0 && remainder2%3 == 0 {
		Goal := factorial(remainder1/3, remainder2/3)
		fmt.Println(int(Goal))
	} else {
		fmt.Println(0)
	}
}

var stdin = bufio.NewScanner(os.Stdin)

func getStdin() int {
	stdin.Scan()
	if err := stdin.Err(); err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	line, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return line
}

func getStd() string {
	stdin.Scan()
	if err := stdin.Err(); err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	line := stdin.Text()
	return line
}

//Combination:b+cCc
func factorial(b int, c int) int {
	var sum, csum, bsum = 1, 1, 1
	for j := 0; j < c; j++ {
		csum = (csum * (c - j)) % mod
		bsum = (bsum * (b + c - j)) % mod
	}
	sum = div(bsum, csum)
	return sum
}

func mul(a int, b int) int {
	return ((a % mod) * (b % mod)) % mod
}

func div(a int, b int) int {
	return mul(a, power(b, mod-2))
}

func power(x int, y int) int {
	if y == 0 {
		return 1
	}
	if y == 1 {
		return x % mod
	}
	a := power(x, y/2) % mod
	if y%2 == 0 {
		b := a * a % mod
		return b
	}
	b := ((a * a) % mod) * x % mod
	return b
}


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

int main() {
  int N,M;
  scanf("%d %d", &N,&M);
  int P[M],Y[M];
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &P[i],&Y[i]);
  }

  vector<int> yd[100001];
  for (int i = 0; i < M; ++i){
    yd[P[i]].push_back(Y[i]);
  }
  for (int i = 0; i < N; ++i){
    sort(yd[i+1].begin(),yd[i+1].end());
  }

  for (int i = 0;i < M;++i) printf("%06d%06d\n", P[i],int(lower_bound(yd[P[i]].begin() ,yd[P[i]].end(), Y[i]) - yd[P[i]].begin())+1);
  

}



Measured memory_bytes: 7808
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int N = 3000;
ll dp[N+1][N+1][2];

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        dp[i][i][0] = a[i];
        dp[i][i][1] = -a[i];
    }
    for (int d = 2; d <= n; ++d) {
        for (int i = 0; i+d-1 < n; ++i) {
            int j = i+d-1;
            dp[i][j][0] = max(dp[i+1][j][1] + a[i], dp[i][j-1][1] + a[j]);
            dp[i][j][1] = min(dp[i+1][j][0] - a[i], dp[i][j-1][0] - a[j]);
        }
    }
    cout << dp[0][n-1][0] << endl;
    return 0;
}


Measured memory_bytes: 139648
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, Z, W;
  cin>>N>>Z>>W;
  ll a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  if(N==1) cout<<abs(a[N-1]-W)<<endl;
  else cout<<max(abs(a[N-1]-W), abs(a[N-1]-a[N-2]))<<endl;
}



Measured memory_bytes: 3600
/*input
1 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	cout<<1110-n;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x.at(i);
  int ans = 1001001001;
  rep(p,105) {
    int tairyoku = 0;
    rep(j,n) {
      tairyoku += (x.at(j) - p)*(x.at(j) - p);
    }
    ans = min(ans, tairyoku);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
#define mp make_pair

ll s, n, ans=1e18;

int main(){

cin >> n >> s;



for(ll i =2; i*i <=n ; i++){
    ll sum =0;
    ll b = i;
    ll k = n;
    while (k>0){
        sum+= k%b;
        k/=b;
    }
    if(sum==s){
        cout << b << endl;
        return 0;
    }
}



if(n==s)ans=n+1;

for(int p = 1; p<=1010101; p++ ){
    ll r = s-p;
    if(r<0)break;
    if(n-r<=0)continue;
    if((n-r)%p!=0)continue;

    ll b = (n-r)/p;
    if(b<=1)continue;
    //cout << b << endl;

    ll k = n;
    ll sum=0;
    while(k>0){
        sum+=k%b;
        k/=b;
    }

    if(sum==s)ans = min(ans, b);

}

if(ans>=1e18)cout << "-1" ;
else cout << ans << endl;

return 0;}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
    }
    let min = (n - 1) as f64 / 1.08;
    let max = n as f64 / 1.08;
    let min = (min + 1.0) as usize;
    let max = (max + 1.0) as usize;
    for x in min..=max {
        if (x as f64 * 1.08) as usize == n {
            println!("{}", x);
            return;
        }
    }
    println!(":(");
}


Measured memory_bytes: 2176
//我是菜鸡
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 10+5;
const int MOD = 9973;
const double exps = 1e-6;
void deprint() {
	ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, k, cnt = 0; cin >> n >> k;
	while (n) {
		cnt++;
		n /= k;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int w;
    string S;
    cin >> S >> w;
    for(int i = 0; i < S.length(); i += w){
        cout << S[i];
        if(i+w > S.length())
            break;
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int weight;
	int n[10];
	int arr[10];
	vector<int> ans;

	for(int i=0,j=1;j<=512;j*=2){
		arr[i++]=j;
	}
	while(cin>>weight){
		ans.clear();
		for(int i=9;i>-1;i--){
			if(weight<=1){
				if(weight==1){
					ans.push_back(weight);
					break;
				}
			}else if(weight>=arr[i]){
				weight-=arr[i];
				ans.push_back(arr[i]);
			}
		}
		for(int i=ans.size()-1;i>-1;i--){
			cout<<ans[i];
			(i==0)? cout<<endl:cout<<" "; 
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {

  string inp, rev, half1, half2;
  cin >> inp;
  rev = inp;
  reverse(rev.begin(), rev.end());
  if(rev != inp){cout << "No";return 0;}
  for(int i = 0;i < (inp.size()-1)/2;i++){
    half1.push_back(inp[i]);
  }
  for(int i = (inp.size()+3)/2 - 1;i < inp.size();i++){
    half2.push_back(inp[i]);
  }
  rev = half1;
  reverse(rev.begin(), rev.end());
  if(rev != half1){cout << "No";return 0;}
  rev = half2;
  reverse(rev.begin(), rev.end());
  if(rev != half2){cout << "No";return 0;}
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll A, B, C;
    cin >> A >> B >> C;

    cout << max ((ll)0, C - (A - B)) << "\n";

}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    string S;cin >> S;
    int ans = 0;
    string prv = "";
    string now = "";
    for(int i = 0;i<S.size();i++){
        now += S.at(i);
        if(now != prv){
            prv = now;
            now = "";
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int x;
	int cube;
	
	
	
	
	scanf("%d", &x);
	while(1){
	if(x<=100 && x>=1){
		cube=x*x*x;
		break;
	}else{
		
	    scanf("%d", &x);
	    continue;
	}
	}
	printf("%d\n", cube);
		
	return 0;
}

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

using namespace std;

int main(){
        int a[3],k;
        cin >> a[0] >> a[1] >> a[2] >> k;
        sort(a,a+3);
        cout << a[0]+a[1]+a[2]*pow(2,k) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<(n)); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  int n;
  cin >> n;
  vecd x(n), y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }

  vec v;
  rep(i,n){
    v.pb(i);
  }

  double ans=0.0;
  double num=0.0;
  do {
    //prtall(v);
    rep(i,n-1){
      double d=0;
      d += (x[v[i+1]] - x[v[i]])*(x[v[i+1]] - x[v[i]]);
      d += (y[v[i+1]] - y[v[i]])*(y[v[i+1]] - y[v[i]]);
      d = sqrt(d);
      ans+=d;
    }
    num+=1.0;
  } while(next_permutation(all(v)));
  ans /= num;
  prtd(10, ans);
}


Measured memory_bytes: 256
S=str(input())
k=len(S)
dic = {"o":0,"x":0}
for character in S:
    dic[character] +=1
    
if dic["o"]>=8:
    print("YES")
else:
    if (15-k)>=(8-dic["o"]):
         print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdint.h>

int main(void){
  int n, i, count = 0;
  int64_t d, x, y;
  scanf("%d%lld", &n, &d);
  d = d*d;
  for(i = 0; i < n; i++){
    scanf("%lld%lld", &x, &y);
    if(x*x + y*y <= d) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
 
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
     
    ll n,a,b;
    cin>>n>>a>>b;
    
    ll diff = b-a-1;
    if(diff%2) cout<<diff/2 + 1;
    else
    {
        ll ans1 = a;
        if(b-a > 1)
        {
            ans1 += (b-a-2)/2 + 1;
        }
        ll ans2 = n-b+1;
        if(a+n-b+1 < n)
        {
            ans2 += (b-a-2)/2 + 1;
        }
        cout<<min(ans1,ans2);
    }
}

Measured memory_bytes: 256
N = gets.to_i
dp = Array.new(N + 1){ Array.new(6, 0) }

(1 .. N).each do |i|
  t,a = gets.split.map(&:to_i)
  dp[i][0] = t
  dp[i][1] = a
  dp[i][2] = t + a
end
3.times{|i| dp[1][i + 3] = dp[1][i] }

(2 .. N).each do |n|
  m = 3.times.map{|i| (dp[n - 1][i + 3] + dp[n][i] - 1) / dp[n][i] }.max
  3.times{|i| dp[n][i + 3] = dp[n][i] * m }
end
puts dp[N][5]


Measured memory_bytes: 2172
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int main(void) {
    ll a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string s;
	cin >> n >> s;
	
	for (auto &i : s){
		i += n;
		if (i > 'Z')
			i -= 26;
	}
	cout << s;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

D = {}
for i in range(N):
    K, *A = map(int, input().split())
    for a in A:
        if a not in D:
            D[a] = 0
        D[a] += 1
        
ans = 0
for v in D.values():
    if v == N:
        ans += 1
        
print(ans)

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

using namespace std;

#define llong long long int
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<llong> A(n);
    rep(i, n) {
        cin >> A[i];
    }

    sort(all(A));
    vector<llong> Cum(n, 0);
    Cum[0] = A[0];
    rep(i, n - 1) {
        Cum[i + 1] += Cum[i] + A[i + 1];
    }

    int check[100001] = {};
    for (int i = 0; i < n; ++i) {
        if (i == n - 1) {
            check[i] = 1;
        } else {
            if (Cum[i] * 2 >= A[i + 1]) {
                check[i] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (check[i]) ++ans;
        else break;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	// sengen
	long long n;
	// nyuryoku
	cin >> n;
	// keisan
	if(n%2 == 1){
		cout << '0';
		return 0;
	}
	if(n < 10){
		cout << '0';
		return 0;
	}
	long long count = 0;
	long long wari = 10;
	while(n >= wari){
		long long keep = n;
		keep = keep/wari;
		count += keep;
		wari *= 5;
	}
	// syutsuryoku
	cout << count;
}

Measured memory_bytes: 3628
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    d = defaultdict(lambda:0)
    for i in range(n):
        d[a[i]] += 1
    if max(d.values()) >1:
        print("NO")
    else:
        print("YES")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 35864
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

const ll LLINF = -100100100;


int main() {
    int n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(2, LLINF));
    dp[0][0] = 0;
    dp[0][1] = LLINF;
    rep(i, n) {
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }
    cout << dp[n][0] << endl;

    return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/python3

import sys
from bisect import bisect_left

sys.setrecursionlimit(1000000)

n = int(input())
a = [int(i) for i in input().split()]

nbs = [ [] for _ in range(n) ]

for _ in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


mlen = [ 0 ] * n
dp = [ float('inf') ] * n

def getmlen(cur, p, ctail):
    for ch in nbs[cur]:
        if ch == p:
            continue

        idx = bisect_left(dp, a[ch])
        ov = dp[idx]

        ntail = max(ctail, idx)
        dp[idx] = a[ch]
        mlen[ch] = ntail + 1
        getmlen(ch, cur, ntail)
        dp[idx] = ov

        

dp[0] = a[0]
mlen[0] = 1
getmlen(0, -1, 0)

for i in range(n):
    print(mlen[i])


Measured memory_bytes: 556864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N,M;
    std::cin >> N >> M;

    long x[100000];
    long y[100000];
    long balls[100000];
    long p[100000]={};
    p[0]=1;

    for(long i=0; i<N; i++){
        balls[i]=1;
    }
    for(long i=0; i<M; i++){
        std::cin >> x[i];
        std::cin >> y[i];
    }

    for(long i=0; i<M; i++){
        if(balls[x[i]-1]>0){
            balls[x[i]-1]-=1;
            balls[y[i]-1]+=1;
            if(p[x[i]-1]==1){
                p[y[i]-1]=1;
                if(balls[x[i]-1]==0){
                    p[x[i]-1]=0;
                }
            }
        }
        
    }

    long count=0;
    for(long i=0; i<N; i++){
        count+=p[i];
    }
    std::cout << count << std::endl;
    return 0;
}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 59;

int main()
{
  int64 N, A[200000];
  cin >> N;
  int64 all = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    all += A[i];
  }

  int64 ret = INF;
  int64 sum = 0LL;
  for(int i = 0; i < N - 1; i++) {
    sum += A[i];
    all -= A[i];
    ret = min(ret, llabs(all - sum));
  }
  cout << ret << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define clear(x, y) memset(x, y, sizeof(x))

const int N(1e5 + 10);
int sum[N], n, Q, l, r; char s[N];

int main()
{
	scanf("%d%d%s", &n, &Q, s + 1);
	for(RG int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + (s[i] == 'C' && s[i - 1] == 'A');
	while(Q--) scanf("%d%d", &l, &r), printf("%d\n", sum[r] - sum[l - 1] - (s[l] == 'C' && s[l - 1] == 'A'));
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	string s;
	cin >> s;
	ll n = s.size();
	vector<ll> v(26);
	rep(i, n) ++v[s[i]-'a'];
	ll ans = n * (n-1)/ 2LL;
	rep(i, 26) if(v[i] > 0) {
		ans -= v[i] * (v[i]-1) / 2LL;
	}
	cout << ans+1 << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    rep(i,s.size()){
        s[i]+=n;
        if (s[i]>'Z') s[i]+='A'-'Z'-1;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int b[] = new int[q];
		int c[] = new int[q];
		for(int i=0;i<q;i++) {
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		long sum = 0;
		for(int i=0;i<n;i++) {
			sum+=arr[i];
			if(map.containsKey(arr[i]))
				map.put(arr[i], map.get(arr[i])+1);
			else
				map.put(arr[i], 1);
		}
		for(int i=0;i<q;i++) {
			if(map.containsKey(b[i])) {
				int a = map.get(b[i]);
				long flag = (long)a * (long)b[i];
				sum = sum-flag;
				map.put(b[i], 0);
				if(map.containsKey(c[i])) {
					map.put(c[i], map.get(c[i])+a);
				}
				else
					map.put(c[i], a);
				flag = (long)a * (long)c[i];
				sum=sum+flag;
				System.out.println(sum);
			}
			else {
				System.out.println(sum);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 66864
A,B,C,D=map(int,input().split())
while A>=0 and C>=0:
    C=C-B
    if C<=0:
        a=1
        break
    A=A-D
    if A<=0:
        a=0
        break
if a==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        FastScan scan = new FastScan(System.in);
        int H = scan.scanInt();
        int W = scan.scanInt();
        int D = scan.scanInt();
        HashMap<Integer, Point> map = new HashMap<>();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int A = scan.scanInt();
                map.put(A, new Point(i, j));
            }
        }
        int[] s = new int[H*W+1];
        for (int i = 1; i <= H * W - D; i++) {
            Point p1 = map.get(i);
            Point p2 = map.get(i+D);
            s[i+D] = s[i]
                    + Math.abs(p1.i-p2.i)
                    + Math.abs(p1.j-p2.j);
        }
        int Q = scan.scanInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.scanInt();
            int R = scan.scanInt();
            System.out.println(s[R]-s[L]);
        }
    }
    class Point {
        int i;
        int j;
        Point(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }
    class FastScan {
        BufferedReader br;
        StringTokenizer st;
        FastScan(InputStream is) {
            InputStreamReader isr = new InputStreamReader(is);
            this.br = new BufferedReader(isr);
        }
        String next() throws IOException {
            while (this.st == null || !this.st.hasMoreTokens()) {
                this.st = new StringTokenizer(br.readLine().trim());
            }
            return st.nextToken();
        }
        long scanLong() throws IOException {
            return Long.parseLong(this.next());
        }
        int scanInt() throws IOException {
            return Integer.parseInt(this.next());
        }
        double scanDouble() throws IOException {
            return Double.parseDouble(this.next());
        }
        char scanCharacter() throws IOException {
            return this.next().charAt(0);
        }
        String nextLine() throws IOException {
            return br.readLine().trim();
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int M,N;
string S,T;

ll dp[2003][2003][2];

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

    cin >> M >> N >> S >> T;

    for (int i = 0;i <= M;i++){
        for (int j = 0;j <= N;j++){
            dp[i][j][0] = -1;
            dp[i][j][1] = -1;
        }
    }

    dp[0][0][0] = 0;
    ll ans = 0;

    for (int i = 0;i <= M;i++){
        for (int j = 0;j <= N;j++){
            dp[i][j][0] = max(dp[i][j][0],0LL);
            //cout << i << " " << j << " " << dp[i][j][0] << " " << dp[i][j][1] << endl;
            ans = max(ans,dp[i][j][1]);
            if(dp[i][j][0] >= 0){
                if(i < M && S[i] == 'I') dp[i+1][j][1] = max(dp[i+1][j][1],dp[i][j][0]+1);
                if(j < N && T[j] == 'I') dp[i][j+1][1] = max(dp[i][j+1][1],dp[i][j][0]+1);
            }
            if(dp[i][j][1] >= 0){
                if(i < M && S[i] == 'O') dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][1]+1);
                if(j < N && T[j] == 'O') dp[i][j+1][0] = max(dp[i][j+1][0],dp[i][j][1]+1);
            }
        }
    }

    cout << ans << endl;
    
    return 0;

}


Measured memory_bytes: 65880
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

lli ans;

void dfs(int n,int k,int s){
	if (s < 0) return;
	if (k == 0 and s == 0){
		ans++;
		return;
	}
	if (n == 0) return;
	if (k == 0) return;
	//not select
	dfs(n-1,k,s);
	//select
	dfs(n-1,k-1,s-n);

	return;
	

}

int main() {
	while(1){
		ans = 0;
		int n,k,s; cin >> n >> k >> s;
		if (n + k + s == 0) break;
		dfs(n,k,s);
		cout << ans << endl;
	}
	return 0;
}

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

int main(void) {
    int N;
    int i;
    
    cin >> N;
    
    vector<int> A(N);
    
    for (i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    
    for (i = 0; i < N - 1; i++) {
        if (A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int llu;

ll dp[101][100001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,cap;
    cin>>n>>cap;
    vector<ll> v(n),w(n);
    for(ll i=0;i<n;i++){
    	cin>>w[i]>>v[i];
	}
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=cap;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
		}
	}
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=cap;j++){
			if(w[i-1]<=j){
				dp[i][j]= max((v[i-1]+dp[i-1][j-w[i-1]] ), dp[i-1][j]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][cap];
    return 0;
}


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

struct point{
  int x;
  int y;
};


int N, maxx = -200, maxy = -200, minx = 200, miny = 200, n, d;
struct point map[200];

int main()
{
  map[0].x = 0; map[0].y = 0; 
  while(1){
    cin >> N;
    if(N == 0){
      break;
    }else{
      for(int i = 1; i < N; i++){
	cin >> n >> d;
	if(d == 0){
	  map[i].x = map[n].x - 1;
	  map[i].y = map[n].y;
	}else if(d == 1){
	  map[i].y = map[n].y - 1;
	  map[i].x = map[n].x;
	}else if(d == 2){
	  map[i].x = map[n].x + 1;
	  map[i].y = map[n].y;
	}else if(d == 3){
	  map[i].y = map[n].y + 1;
	  map[i].x = map[n].x;
	}
      }
      for(int i = 0; i < N; i++){
	maxx = maxx <= map[i].x ? map[i].x : maxx;
	miny = miny >= map[i].y ? map[i].y : miny;
	maxy = maxy <= map[i].y ? map[i].y : maxy;
	minx = minx >= map[i].x ? map[i].x : minx;
      }
      cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
      maxx = -200; maxy = -200; minx = 200; miny = 200;
    }
  }
}

Measured memory_bytes: 1164
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))


Measured memory_bytes: 20024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <tuple>

using namespace std;

int main(void) {
    int N, C;
    cin >> N >> C;
    vector< tuple<int,int,int> > program(N);
    for(int i=0; i<N; i++) {
        cin >> get<0>(program[i]) >> get<1>(program[i]) >> get<2>(program[i]);
    }

    sort(program.begin(), program.end(), [](auto &lhs, auto &rhs) {return (get<2>(lhs) == get<2>(rhs)) ? get<1>(lhs) < get<1>(rhs) : get<2>(lhs) < get<2>(rhs);});
    for(int i=1; i<N; i++) {
        if(get<2>(program[i]) == get<2>(program[i-1]) && get<1>(program[i-1]) == get<0>(program[i])) {
            get<0>(program[i]) = get<0>(program[i-1]);
            get<1>(program[i-1]) = get<0>(program[i-1]) - 1;
        }
    }

    vector<int> time(100010);
    for(auto e: program) {
        ++time[get<0>(e) - 1];
        --time[get<1>(e)];
    }
    partial_sum(time.begin(), time.end(), time.begin());

    cout << (*max_element(time.begin(), time.end())) << endl;
    return 0;
}


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

using namespace std;
using LL = long long int;

#define int long long

const int MAX_N = 2005;
const int INF = 1000000005;

int N, K, Q;
int A[MAX_N];

bool used[MAX_N];

bool check(int l, int r)
{
    memset(used, 0, sizeof(used));
    for(int i = 0; i < N; i++) {
        if(l <= A[i]) {
            used[i] = true;
        }
    }

    int cnt = 0;
    for(int i = 0; i < N; ) {
        if(!used[i]) {
            i++;
            continue;
        }
        int j = i;
        int k = 0;
        for(; j < N; j++) {
            if(!used[j]) {
                break;
            } else if(A[j] < r) {
                k++;
            }
        }
        if(j-i >= K) {
            cnt += min(k, j-i-K+1);
        }
        i = j;
    }

    // cerr << "Cnt: " << cnt << endl;

    return cnt >= Q;
}

signed main()
{
    cin >> N >> K >> Q;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    // check(2,4);
    // return 0;

    int ans = INF;
    for(int i = 0; i < N; i++) {
        int l = 0, r = INF;
        while(r-l > 1) {
            int mid = (l+r)/2;
            if(check(A[i], A[i]+mid)) {
                r = mid;
            } else {
                l = mid;
            }
        }
        ans = min(ans, r-1);
        // cerr << A[i] << " " << A[i]+r-1 << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
al = "abcdefghijklmnopqrstuvwxyz"
d = {}
dn = {}
for a in al:
    d[a] = []
    dn[a] = 0
s = input()
for i in range(len(s)):
    d[s[i]].append(i)
    dn[s[i]] += 1

t = input()
import bisect
ans = 0
n = -1
for a in t:
    l = d[a]
    if l:
        res = bisect.bisect(l, n)
        if res == dn[a]:
            ans += 1
            n = l[0]
        else:
            n = l[res]
    else:
        ans = 0
        n = -2
        break
print(ans * len(s) + n + 1)

Measured memory_bytes: 7668
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v*t + a >= w*t + b and a < b:
    print("YES")
elif -v*t + a <= -w*t + b and a > b:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;


 
int main(){
    long n,k;
    cin  >> n >> k;
    vector<long> vec;
    long ans=0;
    if(n<k) cout << 0 << endl;
    else{
    for (long i=0;i<n;i++) {
        long s;
        cin >>s;
        vec.push_back(s);
        ans+=s;
    }
    sort(vec.begin(),vec.end(),greater<long>());
    for(long i=0;i<k;i++){
        ans-=vec[i];
    }
    cout << ans << endl;
    }
}



Measured memory_bytes: 2420
n = int(input())
t = 0
c = [0] * (n-1)
s = [0] * (n-1)
f = [0] * (n-1)
for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

for i in range(n-1):
    t = 0
    for j in range(i,n-1):
        if t < s[j]:
            t = s[j]
        elif t % f[j] != 0:
            t = t + f[j] - (t % f[j])
        t += c[j]
            
    print(t)
print(0)

Measured memory_bytes: 3064
from typing import List


def binary_search(S: List[int], key: int) -> int:
    left: int = 0
    right: int = len(S)

    while left < right:
        mid: int = int((left + right) / 2)
        if S[mid] == key:
            return 1
        elif key < S[mid]:
            right = mid
        else:
            left = mid + 1
    return 0


def main():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count = 0

    for num in T:
        count += binary_search(S, num)

    print(count)


if __name__ == "__main__":
    main()



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

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

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



int main(void){
  int N,K;
  cin>>N>>K;
  ll answer = K*pow(K-1,N-1);
  printf("%lld\n",answer);
  
}


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

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    ll K;

    cin >> N >> K ;
    int count = 0;
    while( N != 0 ){
        count++;
        N = N/K;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPeaks solver = new CPeaks();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPeaks {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int h[] = new int[n + 1];
            boolean[] good = new boolean[n + 1];
            for (int i = 1; i <= n; i++) {
                good[i] = true;
                h[i] = in.nextInt();
            }
            while (m-- > 0) {
                int u = in.nextInt();
                int v = in.nextInt();
                if (h[u] >= h[v]) {
                    good[v] = false;
                }
                if (h[u] <= h[v]) {
                    good[u] = false;
                }
            }
            int cnt = 0;
            for (int i = 1; i <= n; i++) {
                cnt += good[i] == true ? 1 : 0;
            }
            out.println(cnt);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 54208
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    set<int> m;
    int s=0;
    REP(i,n){
        ++s;
        m.insert(a[i]);
    }
    s-=m.size();
    int ans=m.size();
    if(s%2)--ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int a,b,k;std::cin >> a>>b>>k;
    int n=0;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0&&b%i==0)n++;
        if(n==k){std::cout << i << std::endl;return 0;}
    }
}

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

//template<class T, size_t N> 
//size_t countof(const T (&array)[N]) { return N; }

int main() {
  int N,K;
  K=0;
  cin  >> N >> K;
  N = N+3;
  string s;
  cin >> s;
  int flag=0;
  int Sima[N];
  for(int i=0; i< N; i++){
    Sima[i]=0;
  }
  int jSima=0;
  for (auto x: s) {
    int skip=0;
    if (x == '0' && flag==0) Sima[jSima] +=1; 
    if (x == '1' && flag==0) {
      jSima++;
      Sima[jSima] +=1;
      flag=1;
      skip=1;
    }
    if (x == '1' && flag==1 && skip==0) Sima[jSima] +=1;
    if (x == '0' && flag==1 && skip==0) {
      jSima++;
      Sima[jSima] +=1;
      flag=0;
    }    
  }
  int Smax=Sima[1];
  


  for(int k=0; k < jSima+1; k++){
    int tmp_max=0;
    if(k==0){
      int loop = min(jSima+1, k+(2*K));
      for(int l=k; l < loop; l++){
	tmp_max += Sima[l];
      }
    }
    if(k%2==1){
      int loop = min(jSima+1, k+(2*K)+1);
      for(int l=k; l < loop; l++){
	tmp_max += Sima[l];
      }
    }
    //    cout << tmp_max <<" " << k<< endl;
    Smax = max(Smax, tmp_max);
  }


  cout << Smax << endl;
  



  //  int n = sizeof(s)/sizeof(*s);

  //  cout  <<  sizeof(s)/sizeof(*s) << endl;


}


Measured memory_bytes: 896
function main(s) {
	var s = s.split("\n")[0].split(" ").map(x => Number(x));
	var a = 0;
	for (var i = 1; i <= s[0]; i++) {
		var t = i.toString();
		var x = 0;
		for (var j = 0; j < t.length; j++) {
			x += Number(t[j]);
		}
		if ((x >= s[1]) && (x <= s[2])) {a += i};
	}
	console.log(a);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 8012