akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n;
	string s,t;
	cin >> n >> s >> t;
	
	if(s == t){
		cout << 0 << endl;
		return 0;
	}
	
	static int a[1000010] = {};
	
	vector<int> vec;
	int loc = n;
	for(int i = n-1 ; i >= 0 ; i --){
		loc = min( loc , i );
		while(loc >= 0 && s[loc] != t[i])loc --;
		if(loc == -1){
			puts("-1");
			return 0;
		}
		a[i] = loc;
		vec.push_back(loc);
	}
	reverse(vec.begin(),vec.end());
	vector<int> vec_;
	for(int i = 0 ; i < vec.size() ; i ++){
		if(i == 0 || vec[i-1] != vec[i]){
			vec_.push_back(vec[i]);
		}
	}
	vec = vec_;
	for(int i = 0 ; i < n ; i ++){
		a[i] = (upper_bound(vec.begin(),vec.end(),a[i])-vec.begin())-1;
	}
	vec.push_back(n);
	
	/*for(int i = 0 ; i < vec.size() ; i ++){
		cout << vec[i] << endl;
	}
	for(int i = 0 ; i < n ; i ++){
		cout << a[i] << " ";
	}cout << endl;*/
	
	int l = 0 , r = 2000000;
	while(l < r){
		int m = (l+r)/2;
		bool t = true;
		for(int i = 0 ; i < n && t ; i ++){
			t &= (a[i]+m+1 >= vec.size()) || (i <= vec[a[i]+m+1]-(m+1));
		}
		//if(a[2]+m+1 < vec.size())cout << "hoge" << vec[a[2]+m+1]-(m+1) << endl;
		//if(a[2]+m+1 >= vec.size() || 2 <= vec[a[2]+m+1]-(m+1))cout << "m=" << m << endl;
		if(t)r = m;
		else l = m+1;
	}
	cout << l+1 << endl;
}



Measured memory_bytes: 18428
#!/usr/bin/env python3
import sys


def solve(N: int):
    result = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 != 0:
            result += 1

    print(result)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n,m;
  while(scanf("%d %d", &n, &m), n|m){
    vector<int> h(n), w(m);
    rep(i,n) scanf("%d", &h[i]);
    rep(i,m) scanf("%d", &w[i]);

    vector<int> l(n*(n+1)/2);
    int cnt=0;
    rep(i,n){
      int t = 0;
      repl(j,i,n){
        t += h[j];
        l[cnt++] = t;
      }
    }
    sort(all(l));

    int res=0;
    rep(i,m){
      int t=0;
      repl(j,i,m){
        t += w[j];
        res += upper_bound(all(l), t) - lower_bound(all(l), t);
      }
    }
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 9228
#include <iostream>
#define N 300000
using namespace std;

int main(){
  int n;
  bool isP[N];

  for(int i=0;i<N;i++ )
    isP[i] = true;

  isP[0]=false;
  isP[1]=false;
  for( int i=2;i<N;i++ ){
    if( !isP[i] )
      continue;
    for( int j=2*i;j<N;j+=i )
      isP[j] = false;
  }

  while(cin>>n &&n){
    int num=0;
    for(int j=n+1,len=2*n;j<=len;j++ )
      if( isP[j] )
	num++;
    cout << num << endl;
  }

  return 0;
}

Measured memory_bytes: 1452
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13 || N == 17)puts("No");
	else puts("Yes");

	return(0);
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n,a,b;
string s;
void input(){
    cin>>n>>a>>b>>s;
}
void src(){
    int ok=0;
    int fok=0;
    rep(i,n){
        if(s[i]=='a' and ok<a+b){
            ok++;
            cout<<"Yes"<<"\n";
        }else if(s[i]=='b' and ok<a+b and fok<b){
            ok++;fok++;
            cout<<"Yes"<<"\n";            
        }else{
            cout<<"No"<<"\n";
        }
    }
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 848
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    d = [0] * (max(A) + 1)
    for a in A:
        if a == 0:
            ans *= 3 - d[a]
            ans %= MOD
            d[a] += 1
        else:
            ans *= d[a-1] - d[a]
            d[a] += 1
            ans %= MOD

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 52696
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

ll a[100010];
int invlr[100010];
int invrl[100010];

int main(void){
  int n;
  cin >> n;
  ll sum = 0;
  bool find0 = false;
  for(int i = 0;i < n;++i){
    cin >> a[i];
    if(a[i] == 0)
      find0 = true;
    sum += (ll)abs(a[i]);
  }
  if(find0){
    cout << sum << endl;
    return 0;
  }
  int inv = 1;
  invlr[0] = 1;
  for(int i = 1;i < n;++i){
    if(a[i-1] * invlr[i-1] < 0){
      inv = -1;
    }else{
      inv = 1;
    }
    invlr[i] = inv;
  }
  inv = 1;
  invrl[n-1] = 1;
  for(int i = n-2;i >= 0;--i){
    if(a[i+1] * invrl[i+1] < 0){
      inv = -1;
    }else{
      inv = 1;
    }
    invrl[i] = inv;
  }
  
  ll res = 0;
  for(int i = 0;i < n;++i){
    ll calc = sum - (ll)abs(a[i]) + a[i] * invlr[i] * invrl[i];
    res = max(res, calc);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
        int S,h,m,s;
        cin >> S;
        h = S / 3600;
        S -= h*3600;
        m = S / 60;
        S -= m*60;
        s = S;
        cout << h << ":" << m << ":" << s << endl;
        return 0;
}

Measured memory_bytes: 3076
#include <cstdio>
using namespace std;

int k,r,l;
double p,e,t;

double rec(int depth,double l,double r) {
//    printf("%d %lf %lf\n", depth, l, r);
    double mid = (l+r)/2,ret = 0;
    if(depth == k) {
        if(mid >= t-e && mid <= t+e) return 1;
        return 0;
    }

    if(r+e < t || l-e > t) return 0;
    if(r < t+e && l > t-e) return 1;

    if(mid > t) {
        ret += (1-p)*rec(depth+1,l,mid);
        ret += p*rec(depth+1,mid,r);
    }else{
        ret += p*rec(depth+1,l,mid);
        ret += (1-p)*rec(depth+1,mid,r);
    }
    return ret;
}

int main() {
    scanf("%d %d %d %lf %lf %lf", &k, &l, &r, &p, &e, &t);
    printf("%.12f\n", rec(0,l,r));
}

Measured memory_bytes: 0
using System;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int N = int.Parse(arr[0]), K = int.Parse(arr[1]);
        int cnt = 1;
        while (Math.Pow(K, cnt) <= N) cnt++;
        Console.WriteLine(cnt);
    }
}

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


int main() {

    int h, w;
    cin >> h >> w;
    char board[60][60];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char s; cin >> s;
            // cout << s << endl;
            board[i][j] = s;
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (board[i][j] == '#') {
                // cout << board[i][j] << endl;
                if (board[i][j-1]!='#'&&board[i+1][j]!='#'&&board[i][j+1]!='#'&&board[i-1][j]!='#') {
                    cout << "No" << endl;
                    return 0;
                } 
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {

    int N;

    cin >> N;

    if (N % 2 == 0) {
        cout << N << endl;
    }
    else {
        int N2;
        N2 = N * 2;
        cout << N2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

template<int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }
    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e) {
        long long a = 1, p = x;
        while (e > 0) {
            if (e % 2 == 0) { p = (p * p) % mod; e /= 2; }
            else { a = (a * p) % mod; e--; }
        }
        return ModInt(a);
    }

    friend ostream& operator<<(ostream& os, const ModInt<mod>& p) {
        return os << p.x;
    }
    friend istream& operator>>(istream& is, ModInt<mod>& a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
using modint = ModInt<mod>;

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

    ll n, k;
    cin >> n >> k;
    VI a(n);
    multiset<int> s;
    FOR(i, 0, n) {
        cin >> a[i];
        s.insert(a[i]);
    }
    auto itr = s.begin();
    map<int, modint> map;
    int MIN = *itr;
    modint L = k * (k - 1) / 2;
    FOR(i, 0, s.size()) {
        if (i == 0 || (*itr != MIN && map[*itr] == 0)) {
            map[*itr] = L * i;
        }
        itr++;
    }

    vector<modint> b(n);
    FOR(i, 0, n) {
        int cnt = 0;
        FOR(j, i + 1, n)if (a[i] > a[j])cnt++;
        b[i] = cnt * k;
    }

    modint ans = 0;
    FOR(i, 0, n) {
        ans += b[i];
        ans += map[a[i]];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int a, b, c;

        a = cin.nextInt();
        b = cin.nextInt();
        c = cin.nextInt();

        if (b - a == c - b) {
            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<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string a,b; cin>>a>>b;
    if(a.size()>b.size()) cout<<"GREATER"<<endl;
    else if(a.size()<b.size()) cout<<"LESS"<<endl;
    else{
        rep(i,a.size()){
            if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }
            if(a[i]<b[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
    }
    return 0;
}

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

int main(){
    string ans;
    for(int i = 0; i < 3; i++)
    {
        string s;
        cin >> s;
        ans += (char)(s[0]+('A'-'a'));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	string a, b;
	cin >> a;
	cin >> b;
	string ans = "";
	for (int i = 0; i < b.size(); i++) {
		ans += a.at(i);
		ans += b.at(i);
	}
	if (a.size() > b.size()) {
		ans += a.at(a.size() - 1);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
//#include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;

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 int INF = 2e9;
const LL MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;
  VLL v(N), w(N);
  REP(int, i, N) cin >> w[i] >> v[i];
  VLL dp(W+1, 0);
  REP(int, i, N) REPR2(int, j, w[i], W+1) chmax(dp[j], dp[j-w[i]] + v[i]);
  cout << dp[W] << endl;

  return 0;
}

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

int main(){
	int a, d;
	char b;
	bool c[4][14];
	for(int i=0 ;i<4; i++){
		for(int j=0 ;j<14; j++){
			c[i][j]=0;
		}
	}
	cin >> a;
	for(int k=0 ;k<a; k++){
		cin >> b >> d;
		if(b=='S'){
			c[0][d]=1;
		}else if(b=='H'){
			c[1][d]=1;
		}else if(b=='C'){
			c[2][d]=1;
		}else if(b=='D'){
			c[3][d]=1;
		}
	}
	for(int m=0 ;m<4; m++){
		for(int n=1 ;n<14; n++){
			if(c[m][n]==1){
				continue;
			}
			if(c[m][n]==0){
				if(m==0){
					cout <<"S" << " " << n << endl; 
				}else if(m==1){
					cout << "H" << " " << n << endl;
				}else if(m==2){
					cout << "C" << " " << n << endl;
				}else if(m==3){
					cout << "D" << " " << n << endl;
				}
			}	
		}
	}
	return 0;
}

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

int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	int i,j;
	char s[h][w+1];
	for(i=0;i<h;i++){
		scanf("%s",&(s[i][0]));
	}
	
	for(i=0;i<h;i++){
		printf("%s\n",&(s[i][0]));
		printf("%s\n",&(s[i][0]));
	}
	
	return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]

ans =[]

for i in range(h):
    for j in range(w-1):
        if a[i][j]%2 ==1:
            ans.append([i+1, j+1, i+1, j+2])
            a[i][j+1]+=1
    if i != h-1 and a[i][w-1]%2==1:
        ans.append((i+1, w, i+2, w))
        a[i+1][w-1]+=1

print(len(ans))
for i in range(len(ans)):
    print(' '.join(map(str, ans[i])))

Measured memory_bytes: 29844
N,M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
A.sort()
flag = True
for i in range(M):
  a = A[N-1-i]
  if a * 4 * M >= S:
    continue
  else:
    flag = False
    break
print("Yes" if flag else "No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define LL long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int n,f[100050];
int main()
{
    IO;
    cin>>n;
    int x;
    for(int i=0;i<n;i++)
        cin>>x,f[x]++;
    int mx=0,tmp;
    x=0;
    for(int i=0;i<100005;i++)
    {
        tmp=f[i];
        if(i!=0)tmp+=f[i-1];
        tmp+=f[i+1];
        if(tmp>mx)mx=tmp,x=i;
    }
    cout<<mx;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<vector<int> >arr(n,vector<int> (3));
	for(int i=0;i<n;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		arr[i]={x,y,z};
	}
	int prev_idx=-1;
	vector<vector<int> >dp(n,vector<int>(3,0));
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
		
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		
		int count=0;
		int max = 0;
		int min = Integer.MAX_VALUE;
		int tmpp = Integer.MAX_VALUE;
		
		ArrayList<Integer> ast1 = new ArrayList<Integer>();
		ArrayList<String> ast = new ArrayList<String>();
		
		
		String[] sprite;
		
		
		double tmp1,tmp2;
		int[] kazutmp = new int[9];
		int[] kazu = new int[4];
		int[] kazu2 = new int[9];
		boolean flag;
		
		
		int tmper;
		
		boolean flagr = false;
		
		String kaibun;
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			if(tmp.equals("")){
				break;
			}
			
			kaibun = getName(tmp);
			if(tmp.equals(kaibun)){
				count++;
				
			}
			
		}
		System.out.println(count);
		
	}public static String getName(String name) {
	    StringBuffer sb = new StringBuffer(name);
	    name = sb.reverse().toString();
	    return name;
	}
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int x;
    cin >> x;
    cout << 1 - x ;
}

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



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

int main(){

    int N;
    cin >> N;

    int v[N],c[N],a[N];
    for (int i = 0; i < N; i++){
        cin >> v[i];
    }
    for (int i = 0; i < N; i++){
        cin >> c[i];
    }
    for (int i = 0; i < N; i++){
        a[i] = v[i] - c[i];
    }

    int ans = 0;

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

    return 0;
}

Measured memory_bytes: 256
N = int(input())
l = [0] * N


x = 1
y = 1
z = 1

ans = 6
first_judge = 1
ans_out = 0
#print("ans 6")

if N <= 5:
    for i in range(N):
        print(l[i])
else:
    while ans <= N:
        # print("x,y,z=",x,y,z)
        ans = (x + y + z)**2 - (x*y+ y*z + z*x)
        # print("ans",ans)
        if first_judge == 1 and ans > N:
            if ans_out >= 2:
                # print("break!")
                break
            else:
                x += 1
                y = x
                z = x
                ans_out += 1
                first_judge = 1
                ans = 0
                # print("x_++ x,y,z=",x,y,z)
                # print("first_judge=1")
                # print("ans_out=",ans_out)
        elif ans <= N:
            ans_out = 0
            if x==y==z:
                # print("x=y=z!")
                # print("first_judge=0")
                l[ans-1] += 1
                first_judge = 0
            elif x==y or y==z or z==x:
                # print("list in")
                # print("first_judge=0")
                l[ans-1] += 3
                first_judge = 0
            else:
                l[ans-1] += 6
                first_judge = 0
            z += 1
        else:
            y += 1
            z = y
            first_judge = 1
            ans_out += 1
            ans = 0
            # print("kousin x,y,z=",x,y,z)
            # print("first_judge=1")
            # print("ans_out=",ans_out)
            
        # print("\n")
        
    for i in range(N):
        print(l[i])

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

int main(){
  int c=0,n,q,i,r,l;
  cin>>n>>q;
  string s;
  cin>>s;
  bool f;
  int ac[n];
  for(i=0;i<n;i++){
      if(s[i]=='C'&&f){
          c++;
          f=0;
      }
      else if(s[i]=='A') f=1;
      else f=0;
      ac[i]=c;
  }

  for(i=0;i<q;i++){
    cin>>l>>r;
    cout<<ac[r-1]-ac[l-1]<<endl;
  }
  return 0;
}


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

const int mod = 1000000007;

int main(){
  char L_in[100002];
  scanf("%s", L_in);
  
  int n = strlen(L_in);
  int L[n];
  for(int i = 0; i < n; i++) L[i] = L_in[i] - '0';
  
  long long dp[n + 1][2];
  for(int i = 1; i <= n; i++){
    dp[i][0] = 0;
    dp[i][1] = 0;
  }
  dp[0][0] = 0;
  dp[0][1] = 1;
  
  for(int i = 0; i < n; i++){
    if(L[i]){
      dp[i + 1][1] += dp[i][1] * 2;
      dp[i + 1][0] += dp[i][1] + dp[i][0] * 3;
    }else{
      dp[i + 1][1] += dp[i][1];
      dp[i + 1][0] += dp[i][0] * 3;
    }
    dp[i + 1][1] %= mod;
    dp[i + 1][0] %= mod;
  }
  
  printf("%d\n", (dp[n][1] + dp[n][0]) % mod);
  
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(){
	int a, b, ans;
	char c;

	while(1){
	cin >> a >> c >> b;

	if(c == '+'){
		ans = a + b;
	}
	if(c == '-'){
		ans = a - b;
	}
	if(c == '*'){
		ans = a * b;
	}
	if(c == '/'){
		ans = a / b;
	}
	if(c == '?'){
		break;
	}

	cout << ans << endl;
}
}

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D;

  if (A >= B){
    F = B;
  }else{
    F = A;
  }

  if (C >= D){
    E = D;
  }else{
    E = C;
  }
  cout << E + F;


}


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

map<string, int> ans = {
    {"SSS", 0}, {"SSR", 1}, {"SRS", 1}, {"SRR", 2}, {"RSS", 1}, {"RSR", 1}, {"RRS", 2}, {"RRR", 3}
};

int main(){
    string s;
    cin >> s;
    cout << ans[s] << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i= -k+1 ; i<k ; i++){
            
            System.out.print(i+x +" ");
        }
        
        
    }
}


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

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<double>vec(n);
	for(int i=0;i<n;i++) cin>>vec[i];
	vector<vector<double> >dp(n+1,vector<double>(n+1,0.0));
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++) dp[i][0]=dp[i-1][0]*(1.0-vec[i-1]);
	for(int i=1;i<=n;i++) for(int j=1;j<=i;j++)
	{
		dp[i][j]=dp[i-1][j-1]*vec[i-1];
		if(i!=j)dp[i][j]+=dp[i-1][j]*(1-vec[i-1]);
	}
	double ans=0.0;
	for(int j=n/2+1;j<=n;j++) ans+=dp[n][j];
	cout<<fixed<<setprecision(9)<<ans;
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

const int N = 2e3+100;
vector<int> ans(N);
vector<int> adj[N] = {};

void bfs(int root)
{
  queue<int> q;
  q.push(root);
  q.push(-1);
  vector<int> vis(N);
  vis[root] = 1;
  int dist = 0;
  while(!q.empty())
  {
    int u = q.front();
    q.pop();
    if(u == -1)
    {
      if(!q.empty()) 
      {
        q.push(-1);
        dist++;
        continue;
      }
      break;
    }

    if(u > root) ans[dist]++;

    for(auto v : adj[u])
    {
      if(!vis[v])
      {
        vis[v] = 1;
        q.push(v);
      }
    }
  }
}

int main()
{
  __;
  int n,X,Y;
  cin >> n >> X >> Y;
  X--; Y--;
  for(int i=0;i<n-1;i++)
  {
    adj[i].pu(i+1);
    adj[i+1].pu(i);
  }
  adj[X].pu(Y);
  adj[Y].pu(X);

  for(int i=0;i<n;i++)
  {
    bfs(i);
  }

  for(int i=1;i<n;i++) cout << ans[i] << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    int m;
    cin >> m;
    ll sum = 0;
    for(int i=1; i<=m; i++){
        int x;
        cin >> x;
        sum += x;
    }
    if(sum > n) cout << -1;
    else cout << n-sum;
    return 0;
}


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

int main()
{
	std::string s;
	std::cin >> s;
	for (unsigned int i{}; i + 1 < s.size(); i++)
	{
		if (s[i] == s[i + 1])
		{
			printf("%d %d\n", i + 1, i + 2);
			return 0;
		}
	}
	for (unsigned int i{}; i + 2 < s.size(); i++)
	{
		if (s[i] == s[i + 2])
		{
			printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	}
	printf("-1 -1\n");

	return 0;
}

Measured memory_bytes: 512
N=int(input())
A=[]
B=[]
ans=0
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(N):
    ans+=(B[(-1)*(i+1)]-(A[(-1)*(i+1)]+ans))%B[(-1)*(i+1)]
print(ans)


Measured memory_bytes: 16820
# imos法
n, m = map(int, input().split())
l = []
r = []
imos = [0]*(n+1)
for i in range(m):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)

for i in range(m):
    imos[l[i]-1] += 1
    imos[r[i]] -= 1

cum_sum = [imos[0]]
for i in range(1, len(imos)):
    cum_sum.append(cum_sum[i - 1] + imos[i])

ans = 0
for count in cum_sum:
    if count == m: ans += 1
print(ans)


Measured memory_bytes: 21764
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,n) for(ll i=0;i<n;i++)

using namespace std;

ll f(ll n){
    if(n==1) return 1;
    return f(n/2)*2+1;
} 

int main(){
    ll h;
    cin >> h;
    cout << f(h) << endl;

    return 0;
}

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

using namespace std;

int n, w, values[101], weights[101];
long long memo[101][100000] = {};

long long dp(int item, int size)
{
    if (item == n)
        return 0;
    if (size - weights[item] < 0)
        return dp(item + 1, size);
    if (memo[item][size] > 0)
        return memo[item][size] - 1;
    long long best;
    best = max(values[item] + dp(item + 1, size - weights[item]), dp(item + 1, size));
    memo[item][size] = best + 1;
    return best;
}

int main(void)
{
    scanf("%d %d", &n, &w);
    memset(memo, 0, sizeof(memo));
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &weights[i]);
        scanf("%d", &values[i]);
    }
    long long res;
    res = dp(0, w);
    printf("%lld\n", res);
}

Measured memory_bytes: 82720
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;
int a[211111],b[211111];
signed main(){
	
	cin>>n>>k;
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,n){
		if(a[i]*a[i]+b[i]*b[i]<=k*k)ans++;
	}
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << a * b << " " << (a + b) * 2 << endl;
}



Measured memory_bytes: 3188
N = int(input())

checked = [False]*(N+1)
edges = [[] for i in range(N+1)]
ans = [0]*(N+1)
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    edges[u].append((v,w))
    edges[v].append((u,w))

stack = [(1,0)]
while stack:
    p = stack.pop()
    checked[p[0]] = True
    for np in edges[p[0]]:
        if not checked[np[0]]:
            stack.append((np[0],p[1]+np[1]))
            if (p[1]+np[1])%2:
                ans[np[0]] = 1

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 43340
#include <stdio.h>
int c(char *p,int d){return ((26+*p-*(p+1))%26==d);}
int a(char *p){return((*p<'a')||(*p>'z'));}

char *decode (char *inbuf, int s) {
  int p = 0;
  while (inbuf[p]){
    if(!a(&inbuf[p])) {
      int t = inbuf[p] + s;

      if (t > 'z')      inbuf[p] = (char)(t - 26);
      else if (t < 'a') inbuf[p] = (char)(t + 26);
      else              inbuf[p] = (char)t;
    }
    p++;
  }
  return (inbuf);
}

int main(s){
  char inbuf[82];
  while(fgets(inbuf,80,stdin)){
    //    int s;
    char *p=inbuf;
    while(*p){
      s = 0;
      if(c(p,12)){
	if(c(p+1,3)&&a(p+3)) {
	  s = 't' - *p;
	  p+=3;
	}
	/* that */
	else if(c(p+1,7)&&c(p+2,7)&&a(p+4)){
	  s = 't' - *p;
	  p+=4;
	}
	/* this */
	else if(c(p+1,25)&&c(p+2,16)&&a(p+4)){
	  s = 't' - *p;
	  p+=4;
	}
      }
      if (s) break;
      p++;
    }
    printf("%s",decode(inbuf, s));
  }
  return 0;
}

Measured memory_bytes: 524
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }
    else {
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    vector<int> si(n);
    rep(i,n){
        cin>>s[i];
        cin>>si[i];
    }
    string o;
    cin>>o;
    int ans = 0;
    bool f=false;
    rep(i,n){
        if(f){
            ans+=si[i];
        }else if(s[i]==o){
            f=true;

        }
    }
    cout<<ans<<endl;

    
return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,x;
    cin >> n >> x;
    for(i=x-n+1;i<=x;i++)
    {
        cout << i << ' ';
    }
    for(i=x+1;i<x+n;i++)
    {
        cout << i << ' ';
    }
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
r = 0
c = 0
for i in range(H):
    for j in range(1,W):
        if A[i][j]==A[i][j-1]=="#":
            r += 1
for j in range(W):
    for i in range(1,H):
        if A[i][j]==A[i-1][j]=="#":
            c += 1
if r==W-1 and c==H-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 38356
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#include<utility>
#include<vector>
#define llong long long
#define pll pair<llong,llong>
#define mkpr make_pair
using namespace std;

const int N = 6720;
const int P = 1e9+7;
vector<pll> fac;
llong a[N+3];
llong f[N+3],ff[N+3];
int coe[N+3];
llong n,m; int cnt;
llong ans;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}

void factorize()
{
	llong x = n;
	for(int i=2; i<=100000; i++)
	{
		if(x%i==0)
		{
			fac.push_back(mkpr(i,0));
			while(x%i==0)
			{
				fac[fac.size()-1].second++;
				x/=i;
			}
		}
	}
	if(x>1) {fac.push_back(mkpr(x,1));}
}

void dfs0(llong x,int id,int pos)
{
	if(pos==fac.size()) {a[id] = x; return;}
	for(int i=0; i<=fac[pos].second; i++)
	{
		dfs0(x,id+coe[pos]*i,pos+1);
		x*=fac[pos].first;
	}
}

void dfs(int id0,int id,int pos,int coef)
{
	if(pos==fac.size()) {ff[id0] = (ff[id0]+coef*f[id]%P+P)%P; return;}
	int cur = (id0%coe[pos+1])/coe[pos];
	for(int i=0; i<=1 && i<=cur; i++)
	{
		dfs(id0,id-coe[pos]*i,pos+1,i==1?-coef:coef);
	}
}

int main()
{
	scanf("%lld%lld",&n,&m);
	factorize();
	coe[0] = 1; for(int i=1; i<=fac.size(); i++) coe[i] = coe[i-1]*(fac[i-1].second+1); cnt = coe[fac.size()];
	dfs0(1,0,0);
	for(int i=0; i<cnt; i++) f[i] = quickpow(m,(a[i]+1)/2);
//	printf("a: "); for(int i=0; i<cnt; i++) printf("%lld ",a[i]); puts("");
	for(int i=0; i<cnt; i++)
	{
		dfs(i,i,0,1);
	}
//	printf("ff: "); for(int i=0; i<cnt; i++) printf("%lld ",ff[i]); puts("");
	ans = 0ll;
	for(int i=0; i<cnt; i++)
	{
		if(a[i]&1)
		{
			ans = (ans+ff[i]*(a[i]%P))%P;
		}
		else
		{
			ans = (ans+ff[i]*(a[i]/2%P))%P;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc003_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;

  int s = 0, e = 0, w = 0, n = 0;
  rep(i, S.size()) {
    if (S[i] == 'S') s++;
    if (S[i] == 'E') e++;
    if (S[i] == 'W') w++;
    if (S[i] == 'N') n++;
  }

  if ((s == 0 && n != 0) || (s != 0 && n == 0) || (w == 0 && e != 0) ||
      (w != 0 && e == 0)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>v(k,0);
	for(int i=1;i<=n;++i)++v.at(i%k);
	int64_t ans=0;
	for(int a=1;a<=n;++a){
		int b=(k-a%k)%k,c=(k-b%k)%k;
		if((c+a)%k)continue;
		ans+=1L*v.at(b)*v.at(c);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3900
#include <stdio.h>

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

int main(void){
    // Your code here!
    int N, L[2000];
    long count = 0;
    scanf("%d", &N);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &L[i]);
    }
    QSort(L,0,N-1);
    
    /*for(int i = 0; i < N; i++)
    {
        printf("%d, ", L[i]);
    }
    printf("\n");*/
    
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; j < N; j++)
        {
            for(int k = j+1; k < N && L[i]+L[j] > L[k]; k++)
            {
                count++;
            }
        }
    }
    
    printf("%ld\n", count);
}


Measured memory_bytes: 128
let id x = x
let n = Scanf.scanf "%d\n" id
let ar = Array.make (n+2) 0
let sum_init i =
  let rec sum i' tmp =
    if i' = (n + 1) then tmp + abs ar.(0) + abs ar.(n)
    else
      let v = Scanf.scanf "%d " id in
      let () = ar.(i') <- v in
      sum (i' + 1) (tmp + abs (v - ar.(i' - 1)))
  in
  sum 1 0

let cost = sum_init n

let skip i =
  let off = abs (ar.(i) - ar.(i-1)) + abs (ar.(i + 1) - ar.(i))
  and add = abs (ar.(i + 1) - ar.(i - 1)) in
  cost - off + add

let () = for i = 1 to n do skip i |> Printf.printf "%d\n" done

Measured memory_bytes: 6272
// C - Snuke Festival

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[100000], B[100000], C[100000];
int b_to_c[100000];
ll b_to_n[100000];
ll cum_b_to_n[100000];

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

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

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

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

	sort(B, B+N);
	sort(C, C+N);

	for (int i=0; i<N; i++) {
		b_to_c[i] = upper_bound(C, C+N, B[i]) - C; // B[i]より大きい値が最初に現れるCのインデックス
	}

	// Bを選んだときの組み合わせの数を計算
	for (int i=0; i<N; i++) {
		b_to_n[i] = N - b_to_c[i];
	}

	// Bを選んだときの、B以上の大きさの組み合わせの数を累積和で計算
	cum_b_to_n[N-1] = b_to_n[N-1];
	for (int i=N-1; i>0; i--) {
		cum_b_to_n[i-1] = cum_b_to_n[i] + b_to_n[i-1];
	}

	ll ans = 0;
	for (int i=0; i<N; i++) {
		int j = upper_bound(B, B+N, A[i]) - B; // A[i]より大きい値が最初に現れるBのインデックス
		if (j != N) {
			ans += cum_b_to_n[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;

	int tmp = b;
	int div = 0;
	while(tmp) {
		div += 1;
		tmp /= 10;
	}

	a = a * pow(10, div);
	a = a + b;

	int x = (int)sqrt(a);
	if(a == pow(x, 2)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 512