akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int x=sc.nextInt();
    	int y=sc.nextInt();

    	Set<Integer> setA=new TreeSet<Integer>();
    	setA.add(4);
    	setA.add(6);
    	setA.add(9);
    	setA.add(11);

    	if(setA.contains(x) && setA.contains(y)) {
    		System.out.println("Yes");
    	}else if(x==2 || y==2) {
    		System.out.println("No");
    	}else if(!setA.contains(x) && !setA.contains(y)) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}


    }
}


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n,a,b;
    cin >> n >> a >> b;
    if(abs(a-b) % 2 == 0){
        cout << "Alice" <<endl;
    }else cout << "Borys" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int ans = (int)Math.ceil(N / 1.08);
        int check = (int)(ans * 1.08);
        if(check != N) {
            System.out.println(":(");
            return;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#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 L;
    cin >> L;

    double V = pow(L / 3.0, 3.0);
    cout << fixed << setprecision(8) << V << endl;
}


Measured memory_bytes: 4160
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int a,b;
cin>>a>>b;

if(a<0 || a>9 || b<0 || b>9){
    cout<<"-1";
}
else{
    cout<<a*b<<endl;
}
 return 0;
}
/*


*/

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int dividend,divisor,counter=0;
//    while(1)
//    {
        counter=0;
        cin>>dividend;

        for(divisor=1; divisor<=dividend; divisor++)
        {
            if(dividend%divisor==0)
            {
                counter=counter+(dividend/divisor)-1;
            }
            else
            {
                counter=counter+(dividend/divisor);
            }
        }
        cout<<counter<<endl;
//    }
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
    string s;
    int a, b, c, d;
    vector<char> sgn(3);//符号を格納する
    vector<int> memo(4);//そこまでの計算結果を格納
    vector<int> num(4);
    bool e = false;//出力済んだらtrue
    void dfs(int i){
        if(i == 3){
            if(sgn.at(2) == '+'){
                if(memo.at(2) + d == 7 && e == false){
                    cout << a << sgn.at(0) << b << sgn.at(1) << c << sgn.at(2) << d << "=7" << endl;
                    e = true;
                }
            }
            else{
                if(memo.at(2) - d == 7 && e == false){
                    cout << a << sgn.at(0) << b << sgn.at(1) << c << sgn.at(2) << d << "=7" << endl;
                    e = true;
                }
            }
        }
        else for(int j = 0; j < 2; j++){
            if(j == 0){//sgn'+'のとき
            memo.at(i + 1) = memo.at(i) + num.at(i + 1);
            sgn.at(i) = '+';
            dfs(i + 1);
            }
            else{
            memo.at(i + 1) = memo.at(i) - num.at(i + 1);
            sgn.at(i) = '-';
            dfs(i + 1);
            }
        }
    }
    int main(){
        cin >> s;
        a = s.at(0) - '0';
        b = s.at(1) - '0';
        c = s.at(2) - '0';
        d = s.at(3) - '0';
        num.at(0) = a;
        num.at(1) = b;
        num.at(2) = c;
        num.at(3) = d;
        memo.at(0) = a;
        dfs(0);
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, dist[200010], a, b, c;
vector<pi> e[200010], em;
bool vis[200010];
unordered_set<int> inr[200010], m;

int main()
{
	while(~scanf("%d %d",&N,&M))
	{
		memset(vis, false, sizeof(vis));
		memset(dist, 63, sizeof(dist));
		Forn(i, 200005)
			e[i]=em, inr[i]=m;
		while(M--)
		{
			a=in(), b=in(), c=in();
			e[a].eb(mp(b, c));
			e[b].eb(mp(a, c));
		}
		priority_queue<pi> q;
		dist[1]=0;
		vis[1]=true;
		q.push(mp(0, 1));
		while(!q.empty())
		{
			int st=q.top().s, cost=-q.top().f;
			q.pop();
			vis[st]=true;
			if(cost>dist[st])
				continue;
			foreach(it, e[st])
			{
				int ed=it->f, c=it->s, d=dist[st]+(!inr[st].count(c));
				if(vis[ed]||dist[ed]<d)
					continue;
				if(dist[ed]>d)
				{
					dist[ed]=d;
					q.push(mp(-d, ed));
					inr[ed].clear();
				}
				inr[ed].insert(c);
			}
		}
		if(dist[N]>INF)
			puts("-1");
		else
			printf("%d\n", dist[N]);
	}
	return 0;
}


Measured memory_bytes: 33268
class Dice:
    def __init__(self, labels):
        self.labels = labels

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def change(self, convert):
        result = []
        for i in range(6):
            result.append(self.labels[convert[i] - 1])

        self.labels = result


dice = Dice(list(map(int, input().split())))
for direction in input():
    if direction == 'N':
        dice.north()
    if direction == 'S':
        dice.south()
    if direction == 'E':
        dice.east()
    if direction == 'W':
        dice.west()

print(dice.labels[0])

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

typedef long long ll;

int main() {
    int N, a;
    cin >> N;
    vector<int> b(9, 0);
    rep(i, N) {
        cin >> a;
        b[min(8, a / 400)]++;
    }
    int ans = 0;
    rep(i, 8) {
        ans += min(1, b[i]);
    }
    cout << max(1, ans) << " " << ans + b[8] << "\n";
}

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

using namespace std;

int main()
{
   int a,b;
   
   int output=1;
   cin>>a>>b;int sum1=a;
   if (b==1){cout<<0<<endl;return 0;}
   while(sum1<b){
       sum1-=1;
       output++;
       sum1+=a;
   }
   cout<<output<<endl;
}


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

const int maxn = 1e5+5;
int N, A[maxn], K;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    vector<int> facs;
    for (int i = 1; i*i <= sum; i++) {
        if (sum % i == 0) {
            facs.push_back(i);
            facs.push_back(sum/i);
        }
    }
    sort(facs.begin(),facs.end(),greater<int>());
    for (int f: facs) {
        multiset<int> mods;
        int sub = 0, add = 0;
        for (int i = 0; i < N; i++) {
            mods.insert(A[i] % f);
            add += (f - (A[i] % f));
        }
        for (int i: mods) {
            sub += i;
            add -= (f - i);
            if (sub == add && sub <= K) {
                cout << f << '\n';
                return 0;
            }
        }
    }
}



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

typedef long long ll;

class SegmentTree {
private:
    int n;
    vector<bitset<26> > node;

public:
	SegmentTree(vector<bitset<26> > v) {
        int size = v.size();
		n = 1; while(n < size) n *= 2;
		node.resize(2 * n - 1);

		for(int i = 0; i < size; i++) node[i + n - 1] = v[i];
		for(int i = n - 2; i >= 0; i--) node[i] = node[2 * i + 1] | node[2 * i + 2];
	}

	void update(int x, bitset<26> val) {
		x += n - 1;

		node[x] = val;
		while(x > 0){
			x = (x - 1) / 2;
			node[x] = node[2 * x + 1] | node[2 * x + 2];
		}
	}

	bitset<26> get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if(r < 0) r = n - 1;
		if(r < a || b < l) return bitset<26>(0);
		if(a <= l && r <= b) {
            //cerr << k << " " << node[k] << endl;
            return node[k];
        }

		bitset<26> vl = get(a, b, 2 * k + 1, l, (l + r - 1) / 2);
		bitset<26> vr = get(a, b, 2 * k + 2, (l + r + 1) / 2, r);
		return vl | vr;
	}
};

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

    int N, Q;
    string S;

    cin >> N >> S >> Q;

    vector<bitset<26> > b(N);

    for(int i = 0; i < N; i++) {
        char c = S[i] - 'a';
        b[i] = 1 << c;
    }

    SegmentTree st(b);

    vector<ll> A(Q);
    vector<ll> B(Q);
    vector<ll> C(Q);

    for(int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i];
        B[i]--;
        if(A[i] == 1) {
            char c;
            cin >> c;
            c -= 'a';
            C[i] = 1 << c;
        } else {
            cin >> C[i];
            C[i]--;
        }
    }

    for(int i = 0; i < Q; i++) {
        if(A[i] == 1) {
            st.update(B[i], bitset<26>(C[i]));
        } else {
            cout << __builtin_popcountll(st.get(B[i], C[i]).to_ullong()) << endl;
        }
    }
}


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

int main(){
  int n,x;
  int a[100];

  cin>>n>>x;
  for (int i = 0; i < n; i++) {
    cin>>a[i];
  }
  sort(a, a + n);
  int ans=0;
  for (int i = 0; i < n-1; i++) {
    if (x>=a[i]){
      x -= a[i];
      ans++;
    }
  }
  if (x==a[n-1]) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	
	private static Scanner sc=new Scanner(System.in);
	
	private static int dp[][];
	
	public static int maxHappiness(int arr[][],int day,int act){
		if(day>=arr.length)
			return 0;
		
		if(dp[day][act]!=0)
			return dp[day][act];
		
		int curHappiness=Integer.MIN_VALUE;
		
		for(int i=0;i<3;i++){
			if(i==act)
				continue;
			curHappiness=Math.max(curHappiness,maxHappiness(arr,day+1,i)+arr[day][i]);
		}
		dp[day][act]=curHappiness;
		return curHappiness;
		
	}
	
	
	public static void main(String []args){
		
		int n=sc.nextInt();
		int arr[][]=new int[n][3];
		dp=new int[n][3];
		for(int i=0;i<n;i++){
			arr[i][0]=sc.nextInt();
			arr[i][1]=sc.nextInt();
			arr[i][2]=sc.nextInt();			
		}
		
	
		
		int a=maxHappiness(arr,1,0)+arr[0][0];
		int b=maxHappiness(arr,1,1)+arr[0][1];
		int c=maxHappiness(arr,1,2)+arr[0][2];
		
		System.out.println(Math.max(a,Math.max(b,c)));
		
	}
}

Measured memory_bytes: 71152
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
const int WMAX = 100, HMAX = 100;
int w, h;
int island[WMAX][HMAX];

void dfs(int x, int y) {
  if (x < 0 or w <= x) return;
  if (y < 0 or h <= y) return;
//  cout << "(" << x << " " << y << ")" << endl;
  if (!island[x][y]) return;
  island[x][y] = false;
  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1},
      dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

  REP(dir, 8) {
    dfs(x + dx[dir], y + dy[dir]);
  }
}

int solve() {
  int ans = 0;
  REP(y, h) {
    REP(x, w) {
      if (island[x][y]) {
        ans++;
        dfs(x, y);
      }
    }
  }
  return ans;
}

int main() {
  while (cin >> w >> h and w) {
    REP(y, h) {
      REP(x, w) {
        int c;
        cin >> c;
        island[x][y] = c;
      }
    }

    cout << solve() << endl;
  }
}

Measured memory_bytes: 1404
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
    input! {
        a: usize, b: usize, n: usize,
    }
    let mut ans: usize = 0;
    let al = if b -1 > n {
        n
    } else {
        b - 1
    };
    let qq = a / b;
    let rr = a % b;
    let qql = al / b;
    let rrl = al % b;
    let left = rr * rrl / b + rr * qql + qq * al;
    let right = (al / b) * a;
    ans = max(ans, left - right);


    println!("{}", ans);
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
double ps[3100];
double dp[3100][7000];

double rec(int i, int c){
    if(i == N){
        return c > 0 ? 1 : 0;
    }

    if(dp[i][c + 3500] >= 0){
        return dp[i][c + 3500];
    }

    double res = ps[i] * rec(i + 1, c + 1) + (1. - ps[i]) * rec(i + 1, c - 1);
    return dp[i][c + 3500] = res;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> ps[i];
    }

    std::fill(&dp[0][0], &dp[0][0]+3100*7000, -1);

    double res = rec(0, 0);
    printf("%.10f\n", res);
}


Measured memory_bytes: 169984
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 8
#define MAX_M 28

bool is_path(int N, int M, int *a, int *b, int *order) {
    bool is_path = true;
    for (int i = 1; i < N; i++) {
        bool exist_path = false;
        for (int j = 0; j < M; j++) {
            if (a[j] == order[i-1] && b[j] == order[i]) {
                exist_path = true;
            }
            if (a[j] == order[i] && b[j] == order[i-1]) {
                exist_path = true;
            }
        }
        if (!exist_path) {
            is_path = false;
        }
    }
    return is_path;
}

int main() {
    int N, M, a[MAX_M], b[MAX_M];
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
    }
    int order[MAX_N];
    for (int i = 0; i < N; i++) {
        order[i] = i+1;
    }
    int num_of_path = 0;
    do {
        if (is_path(N, M, a, b, order)) {
            num_of_path++;
        }
    } while (next_permutation(order+1, order+N));
    cout << num_of_path << endl;
    return 0;
}

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

int H, N[3000];

void print()
{
	for (int i = 1; i <= H; i++)
	{
		cout << "node " << i << ": " << "key = " << N[i] << ", ";
		if (i / 2 >= 1)
			cout << "parent key = " << N[i / 2] << ", ";
		if (i * 2 <= H)
			cout << "left key = " << N[i * 2] << ", ";
		if (i * 2 + 1 <= H)
			cout << "right key = " << N[i * 2 + 1] << ", ";

		cout << endl;
	}
}

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

	cin >> H;

	for (int i = 1; i <= H; i++)
		cin >> N[i];

	print();

	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 #include <numeric>
 #include <stdio.h>
 #include <algorithm>

 using namespace std;

 int main(){
    int N;
    int D[240];
    int i;
    int cnt = 0;
    bool ans = false;
    
    cin >> N;
    for (i=0; i<2*N-1; i=i+2)
        cin >> D[i] >> D[i+1];

    for (i=0; i<2*N-1; i=i+2){
        if(D[i]==D[i+1])
            cnt++;
        else
            cnt=0;
        if(cnt==3){
            ans = true;
            break;
            }
    }

    if(ans==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
 }
 



Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int N = int.Parse(str);
        int[] a = new int[N];
        string[] stra = Console.ReadLine().Split(' ');
        bool[] flag = new bool[8];
        int min, max, count;
        count = min = max = 0;

        for(int i = 0; i < N; i++){
            a[i] = int.Parse(stra[i]);
        }

        for(int i = 0; i < N; i++){
            if(a[i] <= 399){
                if(flag[0] == false){
                    flag[0] = true;
                    count++;
                }
            }else if(a[i] <= 799){
                if(flag[1] == false){
                    flag[1] = true;
                    count++;
                }
            }else if(a[i] <= 1199){
                if(flag[2] == false){
                    flag[2] = true;
                    count++;
                }
            }else if(a[i] <= 1599){
                if(flag[3] == false){
                    flag[3] = true;
                    count++;
                }
            }else if(a[i] <= 1999){
                if(flag[4] == false){
                    flag[4] = true;
                    count++;
                }
            }else if(a[i] <= 2399){
                if(flag[5] == false){
                    flag[5] = true;
                    count++;
                }
            }else if(a[i] <= 2799){
                if(flag[6] == false){
                    flag[6] = true;
                    count++;
                }
            }else if(a[i] <= 3199){
                if(flag[7] == false){
                    flag[7] = true;
                    count++;
                }
            }else{
                max++;
            }
        }

        min = count;
        if(min == 0){
            min++;
        }else{
            max = count + max;
        }
        Console.WriteLine(min + " " + (max));
    }
}



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

int main(){
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i') {
    cout << "vowel" << endl;
  }
  else if (c == 'u' || c == 'e') {
    cout << "vowel" << endl;
  }
  else if (c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" <<endl;
  }
}
      


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

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    int g = 0;
    for (int i = 0; i < N; i++)
    {
        g = gcd(abs(X - x[i]), g);
    }
    cout << g << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,n;
	while(cin>>n){
		a=n/1000;
		b=(n/100)%10;
		c=(n/10)%10;
		d=n%10;
		if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
		else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
		else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
		else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
		else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
		else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
		else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
		else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    ll n;
    cin >> n;
    string s[301];
    REP(i, n){
        cin >> s[i];
    }
    ll ok[300][300] = {};
    REP(i, n){
        REP(j, n){
            if(ok[i][j] == 0){
                bool okk = true;
                for(int k = i; k < n + i; k++){
                    for(int l = j + k; l < n + j; l++){
                        if(s[k % n][l % n] != s[(l - j + i) % n][(k + j - i) % n]){
                            okk = false;
                            break;
                        }
                    }
                    if(!okk){
                        break;
                    }
                }
                if(okk){
                    REP(k, n){
                        ok[(i + k) % n][(j + k) % n] = 1;
                    }
                }
                else{
                    REP(k, n){
                        ok[(i + k) % n][(j + k) % n] = -1;
                    }
                }
            }
        }
    }
    
    ll ans = 0;
    REP(i, n){
        REP(j, n){
            if(ok[i][j] == 1)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 1000005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    char c;
    cin>>c;
    int x=c;
    x++;
    char an=char(x);
    pr(an);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

X.sort()
res = M
ans = 0
for a, b in X:
    if res <= 0:
        break

    tmp = min(b, res)
    res -= tmp
    ans += tmp * a

print(ans)


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

const int N = 1e2+1;
int dp[N][100000+1];

void solve(){
    int n, w;
    cin >> n >> w;
    int W[n+1], V[n+1];
    for(int i = 1; i <= n; i++){
        cin >> W[i] >> V[i];
    }
    for(int v = 1; v <= 1e5; v++)dp[0][v] = inf;
    for(int i = 1; i <= n; i++){
        for(int v = 1; v <= 1e5; v++){
            dp[i][v] = dp[i-1][v];
            if(V[i] <= v)
                dp[i][v] = min(dp[i][v], dp[i-1][v-V[i]]+W[i]);
        }
    }
    for(int v = 1e5; v >= 0; v--){
        if(dp[n][v] <= w){
            cout << v << endl;
            return;
        }
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    //#endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

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

S = {X : 1}

path = [X]

cnt = 1
ans = X
a = X
for i in range(2, N + 1):
    a = a * a % M
    if a in S:
        cnt = i - S[a]
        break
    S[a] = i

    ans += a
    path.append(a)

pre_len = S[a] - 1

Q, R = divmod(N - pre_len - 1, len(path) - pre_len)

pre = sum(path[:pre_len])
cycle = sum(path) - pre

ans = a
for _ in range(R):
    a = a * a % M
    ans += a

print(pre + Q * cycle + ans)

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

int a, b, c, d;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> c >> d;

    const int lower = max(a,c);
    const int upper = min(b,d);

    cout << max(0,upper-lower) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,j,H,W,num;
	
	scanf("%d %d",&H,&W);
	while(H!=0 && W!=0){
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
			num=i+j;
			if(num%2==0) printf("#");
			else printf(".");
			}
		printf("\n");
		}
		printf("\n");
		scanf("%d %d",&H,&W);
	}
}

Measured memory_bytes: 572
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0;
	while (true) {
		string s; cin >> s;
		if (s == "0")return 0;
		for (int h = 0; h < s.size(); h++) {
			n += (s[h] - '0');
		}
		cout << n << endl; n = 0;
	}
	cin >> n;
}


Measured memory_bytes: 3208
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
const int MAXN = 510;

int n, m, r, c, a[MAXN][MAXN];

int main() {
	scanf( "%d%d%d%d", &n, &m, &r, &c );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			a[i][j] = 1000;
	int num = (r * c - 1) * 1000 + 1;
	for( int x = r; x <= n; x += r )
		for( int y = c; y <= m; y += c )
			a[x][y] = -num;
	int sum = 0;
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			sum += a[i][j];
	if( sum <= 0 ) {
		puts("No");
		return 0;
	}
	puts("Yes");
	for( int i = 1; i <= n; ++i ) {
		for( int j = 1; j <= m; ++j )
			printf( "%d ", a[i][j] );
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2560
x, y = map(int, input().split())

if 0 <= x and 0 <= y:
    if x <= y:
        res = abs(x - y)
    elif y == 0:
        res = abs(x - y) + 1
    else:
        res = abs(x - y) + 2
elif x < 0 and y <= 0:
    if x <= y:
        res = abs(x - y)
    else:
        res = abs(x - y) + 2
else:
    res = abs(abs(x) - abs(y)) + 1

print(res)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = input()
    a = []
    for e in s:
        if e == 'B':
            if a: a.pop()
        else:
            a.append(e)
    print(''.join(a))
        


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 9268
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=2e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}

class alphs{
public:
	array<llint,26> kaz;
	alphs(){for(int i=0;i<26;i++){kaz[i]=0;}}
	alphs& operator +=(alphs other){
		for(int i=0;i<26;i++){this->kaz[i]+=other.kaz[i];}
		return (*this);
	}
	alphs& operator -=(alphs other){
		for(int i=0;i<26;i++){this->kaz[i]-=other.kaz[i];}
		return (*this);
	}
};
vector<llint> retu;
vector<alphs> mowa;
string str;
void retus(void){
	llint k=retu.back();
	alphs a=mowa.back();
	while(-1){
		k+=retu[retu.size()-2];retu.pub(k);
		a+=mowa[mowa.size()-2];mowa.pub(a);
		if(retu.back()>big){return;}
	}
}
alphs solve(llint x,llint fu){
	alphs ans;
	if(fu==0||fu==1){
		for(llint i=0;i<x;i++){ans.kaz[str[i]-'a']++;}
		return ans;
	}
	if(x<retu[fu-1]){return solve(x,fu-1);}
	ans=mowa[fu-1];
	ans+=solve(x-retu[fu-1],fu-2);
	return ans;
}

int main(void){
	llint l,r,n,i,j;//p r p の最初のp
	cin>>str;n=str.size();
	cin>>l>>r;
	alphs it;n/=2;
	for(i=0;i<n;i++){it.kaz[str[i]-'a']++;}
	mowa.pub(it);
	retu.pub(n);
	for(j=0;j<n;j++){str.pob();}
	llint ueha=0;
	llint siha=0;
	const llint ueka=101;
	llint uegen=1;
	llint iti=n;
	for(i=1;i<n;i++){//上と下が良い数
		ueha+=(str[i-1]-'a')*uegen;ueha%=mod;
		uegen*=ueka;uegen%=mod;
		siha*=ueka;
		siha+=(str[n-i]-'a');
		siha%=mod;
		if(ueha==siha){iti=i;}
	}
	for(j=0;j<n-iti;j++){
		str.pub(str[j]);
		it.kaz[str[j]-'a']++;
	}
	mowa.pub(it);
	retu.pub(str.size());
	retus();
	auto ans=solve(r,retu.size());
	ans-=solve(l-1,retu.size());
	for(i=0;i<26;i++){cout<<ans.kaz[i]<<" ";}
	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}

int main()
{
	string s;
	int cnt = 0, ans = 0;
	int search = 0;
	cin >> s;
	if (s[0] == 'A') {
		ans++;
		for (int i = 2; i <= s.length() - 2; i++) {
			if (s[i] == 'C') {
				cnt++;
			}
		}
		if (cnt == 1) {
			ans++;
			rep(i, s.length()) {
				if (s[i] >= 'A' && s[i] <= 'Z') {
					search++;
				}
			}
			if (search == 2) {
				ans++;
			}
		}
	}
	if (ans == 3) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

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>;
using G = vector<vector<int>>;
    
int main(){
    ll n;
    cin >> n;
    vector<char> ans;
    ll i = 26;

    vector<ll> hantei = {1,27,703,18279,475255,12356631,321272407,8353082583,217180147159,5646683826135,146813779479511,3817158266467287};
    
    rep(i, hantei.size()-1){
        if (hantei[i]<=n && n<hantei[i+1]){
            n-= hantei[i];
            while(n>0){
                ans.push_back(n%26);
                n /= 26;
            }
            while(i+1>ans.size()){
                ans.push_back(0);
            }
        }
    }
    rep(i,ans.size()){
        char c = ans[ans.size()-1-i];
        c += 97;
        cout << c;
    }
    cout << endl;
    return 0;
}

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

#define ll int long long
#define dll double long long
#define forei(i,n,x) for(int i=n;i<=x;i++)
#define fored(i,n,x) for(int i=n;i>=x;i--)
#define forni(i,n,x) for(int i=n;i<x;i++)
#define fornd(i,n,x) for(int i=n;i>x;i--)
#define SQ(a) (a)*(a)
#define MOD 1000000007
#define sortvi(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pv(v) for(auto it: v) cout<<it
#define endl '\n'   //Take care in case of interactive problems
#define  MAX2 200005
#define  MAX1 100005
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INPA(arr,n) forni(i,1,n)cin>>arr[i]


typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
    /* write your code here */
    
    ll n;cin>>n;
    ll temp;
    string s={};
    char c;
    while(n>26)
    {
        temp = n%26;
        if(temp==0)
        {
            s.append("z");
            n--;
        }
        else
        {
         c = 'a' + temp-1;
            s.append(1,c);
        }
        
        n = n/26;
    }
    
        temp = n%26;
  //      cout<<temp<<endl;
        if(temp==0)
        {
            s.append("z");
        }
        else
        {
            c = 'a' + temp-1;
            s.append(1,c);
        }
        
    
     reverse(s.begin(),s.end());
    cout<<s<<endl;
    
    return 0;
}






Measured memory_bytes: 3596
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int xyturn = 1;
		int rtzw = 0;
		int[] ian = new int[n];
		for(int i=0;i<n;i++){
			ian[i] = sc.nextInt();
		}
		if(n==1){
			rtzw = ian[0] - w;
		}
		else{
			int ans1 = ian[n-2] - ian[n-1];
			if(ans1<0){
				ans1 *= -1;
			}
			int ans2 = ian[n-1] - w;
			if(ans2<0){
				ans2 *= -1;
			}
			rtzw= ans1>ans2 ? ans1 : ans2; 
		}
		if(rtzw<0){
			rtzw *= -1;
		}
		System.out.println(rtzw);
    }
}


Measured memory_bytes: 25188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

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

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll ans = (a*(ll)((ll)b*100))/100;
    cout << ans << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 1;
  int ans = 0;

  while(sum<B) {
      ans++;
      sum = A+(A-1)*(ans-1);
  }
  cout << ans << endl;
}


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

using namespace std;

inline void read() {}
template <class S>
inline void read(S &arg) {
  cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    read(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void read(S &arg, T &... rest) {
  read(arg);
  read(rest...);
}

inline void write() {}
template <class S>
inline void write(S arg) {
  cout << arg;
}
template <class S>
inline void writeA(S Lptr, S Rptr) {
  if (Lptr != Rptr) {
    write(*Lptr);
    Lptr++;
  }
  while (Lptr != Rptr) {
    write(' ');
    write(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void write(S arg, T... rest) {
  write(arg);
  write(' ');
  write(rest...);
}

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

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

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 1e9 + 7;
constexpr int N = 1e6 + 10;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}

ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n, m;
int A[N], B[N];
function<bool(int, int)> cmp = greater<int>();

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

  read(n, m);
  readA(A, A + n);
  readA(B, B + m);

  sort(A, A + n, cmp);
  sort(B, B + m, cmp);

  rep(i, 1, n) if (A[i] == A[i - 1]) return write(0), 0;
  rep(i, 1, m) if (B[i] == B[i - 1]) return write(0), 0;

  int lptr = 0, rptr = 0;

  ll res = 1;
  for (int i = n * m; i; i--) {
    bool a = lptr < n && A[lptr] == i;
    bool b = rptr < m && B[rptr] == i;
    if (a) lptr++;
    if (b) rptr++;
    if (a && b) continue;
    if (a)
      res = (res * rptr) % MOD;
    else if (b)
      res = (res * lptr) % MOD;
    else
      res = (res * (lptr * rptr - (n * m - i))) % MOD;
  }
  write(res);

  return 0;
}


Measured memory_bytes: 2304
n, x = map(int, input().split())
happy_lists = sorted([int(i) for i in input().split()])
happy_children = 0

for _ in range(n):
    if x >= happy_lists[_]:
        if _ == len(happy_lists)-1:
            if x == happy_lists[_]:
                happy_children += 1
        else:
            happy_children += 1
            x -= happy_lists[_]

print(happy_children)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int X, Y;
    cin >> X >> Y;
    long int A[Y];
    int ans = 1;
    long int tmp = X;
    for (int i = X; i <= Y; i++)
    {
        if (tmp * 2 <= Y) 
        {
            ans++;
            tmp *= 2;
        }
        
        else break;
    }
    cout << ans << endl;
    return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<ll> l(n), r(n);
	for(int i=0; i<n; i++) cin >> l[i] >> r[i];

	ll lmax=0, rmin=1e10;
	for(int i=0; i<n; i++){
		lmax = max(lmax, l[i]);
		rmin = min(rmin, r[i]);
	}
	dbg(lmax, rmin);

	vector<pair<ll, ll>> v(n);
	for(int i=0; i<n; i++){
		v[i] = {max(0ll, 1+r[i]-lmax), -max(0ll, 1+rmin-l[i])};
	}

	sort(v.begin(), v.end());
	for(int i=0; i<n; i++) dbg(v[i].first, -v[i].second);

	ll ans = 0;

	for(int i=0; i<n; i++){
		ans = max(ans, max(0ll, rmin-lmax+1)+max(0ll, r[i]-l[i]+1));
	}

	ll lmin = 2e9;
	for(int i=0; i<n-1; i++){
		lmin = min(lmin, -v[i].second);
		ans = max(ans, v[i+1].first + lmin);
	}

	cout << ans << endl;
	return 0;
}


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

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


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

int main(){
  int n;
  cin >> n;
  double v[n];
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v, v+n);

  double crr = v[0];
  for ( int i = 1; i < n; i++){
    crr = ( crr + v[i] ) / 2;
  }

  cout << setprecision(12) << crr << endl;

  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  int ans = 0;
  string x;
  cin >> x;
  bool found = false;
  for (int i = 0; i < n; i++) {
    if (s[i] == x) {
      found = true;
      continue;
    }
    if (found) {
      ans += t[i];
    }
  }
  cout << ans << '\n';
  return 0;
}


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

vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < s.size(); i++) if (S == s.at(i)) cout << 7 - i << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int lim=min(k,43);
    for(int i = 0; i < lim; i++) {
        vector<int> na(n,0);
        for(int j = 0; j < n; j++) {
            int l=max(0,j-a[j]);
            int r=min(n-1,j+a[j]);
            na[l]++;
            if(r+1<n) na[r+1]--;
        }
        for(int j = 1; j < n; j++) {
            na[j]+=na[j-1];
        }
        swap(a,na);
    }

    for(int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << "\n";

    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S, T; cin >> S >> T;
    int ans = 0;
    rep(i, S.length()){
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3776
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

m = ri()
ls = rils(m)
res = -1
s = 0
for d, c in ls:
    res += c
    s += d * c
res += (s - 1) // 9
print(res)

Measured memory_bytes: 45364
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string odd,even, res="";
    int n,i;
    cin>>odd>>even;
    int l=odd.length();
    int ll=even.length();
    i=0;
    int j=0;
    while(i<l)
    {
       res=res+odd[i];
       if(j<ll) res=res+even[j];
       i++;
       j++;

    }
    cout<<res<<endl;
    return 0;
}


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

int main(){
  string s; cin >> s;
  int n=0, m, a;
  
  m = s.length();
  
  for(int i = 0; i < m/2; i++){
  	if(s[i] != s[m-i-1]) n++;
  }
  
  cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#define ALL(a)  (a).begin(),(a).end()

//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i, n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
	int x,y;
	cin>>x>>y;
	cout<<(x==y?"Yes":"No");
	return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  // cout<<fixed<<setprecision(10);

  ll V,E,r; cin>>V>>E>>r;

  vint s(E),t(E),d(E);
  rep(i,E){
    cin>>s[i]>>t[i]>>d[i];
  }

  vint dist(V, LLONG_MAX);
  dist[r] = 0;

  rep(i, V-1){
    rep(j, E){
      if(dist[s[j]] == LLONG_MAX) continue;
      chmin(dist[t[j]], dist[s[j]] + d[j]);
    }
  }

  rep(j, E){
    if(dist[s[j]] == LLONG_MAX) continue;
    if(dist[s[j]] + d[j] < dist[t[j]]){
      puts("NEGATIVE CYCLE");
      return 0;
    }
  }

  rep(i,V){
    if(dist[i] == LLONG_MAX) puts("INF");
    else cout<<dist[i]<<endl;
  }





}







Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 n, k;
  cin >> n >> k;
  i64 ans = 0;
  rep(i,0,n) {
    i64 h;
    cin >> h;
    if(h >= k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256