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

string str;
void so(int& i,string& r,int k,char c){
    while(str[i]!=c&&i!=str.length()){
        if(str[i]=='X'){
            r+=char(k+'0');
        }
        else
            r+=str[i];
        i++;
    }i++;
}
string add(string a,string b){
    string r;
    int p=0;
    if(a.length()>b.length())swap(a, b);
    for(int i=0;i<b.length();i++){
        if(i>=a.length()){
            r=char(b[b.length()-1-i]+p)+r;
            p=0;
        }
        else{
            int g=b[b.length()-1-i]+a[a.length()-1-i]-2*'0'+p;
            r=char('0'+g%10)+r;
            p=g/10;
        }
    }
    if(p)r=char('0'+p)+r;
    return r;
}
int main(){
    while(cin>>str){
        int s=0,k=0;
        for(;k<10;k++){
            string a,b,c;
            int i=0;
            so(i,a,k,'+');//cout<<"a: "<<a<<endl;
            so(i,b,k,'=');////cout<<b<<endl;
            so(i,c,k,'.');//cout<<c<<endl;
            
            if(add(a,b)==c){cout<<k<<endl;s=1;break;}
        }
        if(!s)cout<<"NA"<<endl;
    }
//    string a,b;
//    while(cin>>a>>b)cout<<add(a,b)<<endl;
}

Measured memory_bytes: 1196
#include <iostream>

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

    const auto sum = N*L + N*(N - 1)/2;

    const auto taste = [=]() {
        if (L >= 0) return sum - L;
        else if (N + L - 1 >= 0) return sum;
        else return sum - (N + L - 1);
    }();

    std::cout << taste << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, k;
	cin >> N >> k;

	vector<Int> x(N);
	Int flag = 1;
	for (Int i = 0; i < N; i++) {
		cin >> x[i];
		if (x[i] == 0) k--;
	}
	
	Int ans = INF;
	Int temp = 0;
	if (k) {
		for (Int i = 0; i < N; i++) {
			temp = abs(0 - x[i]) + abs(x[k + i - 1] - x[i]);
			ans = min(ans, temp);
			if (k + i - 1 == N - 1)break;
		}

		for (Int i = 0; i < N; i++) {
			temp = abs(0 - x[k+i-1]) + abs(x[k + i - 1] - x[i]);
			ans = min(ans, temp);
			if (k + i - 1 == N - 1)break;
		}
	}
	else {
		ans = 0;
	}
	

	cout << ans << endl;


}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var c = new int[n - 1];
        var s = new int[n - 1];
        var f = new int[n - 1];

        for (int i = 0; i < n - 1; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            c[i] = vals[0];
            s[i] = vals[1];
            f[i] = vals[2];
        }

        for (int i = 0; i < n; i++)
        {
            int cur = 0;
            for (int j = i; j < n - 1; j++)
            {
                var t = Math.Max(cur, s[j]);
                t += f[j] - 1;
                var next = (t / f[j]) * f[j] + c[j];
                cur = next;
            }
            Console.WriteLine(cur);
        }
    }
}

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

int EditDistance(string s1,string s2){
	int r=s1.size();
	int c=s2.size();
	int DP[r+1][c+1];

	for(int i=0;i<r+1;i++){
		DP[i][0]=i;
	}
	for (int j=0;j<c+1;j++){
		DP[0][j]=j;
	}

	for (int i=1;i<r+1;i++){
		for (int j=1;j<c+1;j++){
			if(s1[i-1]==s2[j-1]){
				DP[i][j]=min( min(DP[i-1][j] +1, DP[i][j-1]+1) , DP[i-1][j-1]);
			}else{
				DP[i][j]=min( min(DP[i-1][j] +1, DP[i][j-1]+1) , DP[i-1][j-1]+1);
			}
		}
	}
	return DP[r][c];
}

int main(){
	string s1,s2;
	cin >> s1 >> s2;

	cout << EditDistance(s1,s2) << endl;
}

Measured memory_bytes: 5104
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string t;
  cin>>t;
  for(long long int i=0; i<t.size(); i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  cout<<t<<endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> p;
long long n;
int main(){
	cin >> n;
	long long res = 0;
//	for (int i = 1; i < n; i++) res += 1LL*i % (i + 1);
	res = (1 + n - 1)*(n-1)/2 ;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>

typedef long long LL;
typedef unsigned long long ull;

const int N=40;
const int seed=2333;

int n,a[N],col[N];
char str[N];
ull po[N];
LL ans;
std::map<ull,int> ma;

void check()
{
    ull x=0,y=0;
    int p=1,q=n;
    for (int i=1;i<=n;i++)
        if (!col[i]) x+=(ull)a[i]*po[p],p++;
        else y+=(ull)a[i]*po[q],q--;
    ma[x-y]++;
}

void calc()
{
    ull x=0,y=0;
    int p=n,q=1;
    for (int i=n*2;i>n;i--)
        if (col[i]) y+=(ull)a[i]*po[q],q++;
        else x+=(ull)a[i]*po[p],p--;
    ans+=ma[y-x];
}

void dfs1(int x)
{
    if (x>n) {check();return;}
    col[x]=0;dfs1(x+1);
    col[x]=1;dfs1(x+1);
}

void dfs2(int x)
{
    if (x>n*2) {calc();return;}
    col[x]=0;dfs2(x+1);
    col[x]=1;dfs2(x+1);
}

int main()
{
    scanf("%d",&n);
    scanf("%s",str+1);
    for (int i=1;i<=n*2;i++) a[i]=str[i]-'a'+1;
    po[0]=1;
    for (int i=1;i<=n;i++) po[i]=(ull)po[i-1]*seed;
    dfs1(1);
    dfs2(n+1);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int n ,arr[105];
int main()
{
    n=D();
    for(int i=0;i<n;++i){
        arr[i]=D();
    }
    sort(arr,arr+n);
    int sum1=0,sum2=0;
    bool f1=true,f2=false;
    for(int i=n-1;i>=0;--i)
    {
        if(f1==true){
            f2=true;
            f1=false;
            sum1+=arr[i];
        }else if(f2==true){
              f1=true;
            f2=false;
            sum2+=arr[i];
        }
    }
    cout<<sum1-sum2<<endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  string s,t;
  cin >> s >> t;
  map<char,vector<ll>> c;
  for(ll i=0;i<s.size();i++) {
    c[s[i]].push_back(i);
  }
  ll pre=-1;
  ll ans=0;
  for(ll i=0;i<t.size();i++) {
    if(c[t[i]].size()==0) {
      cout << -1 << endl;
      return 0;
    }
    ll l=-1,r=c[t[i]].size();
    ll temp=(l+r)/2;
    while(l+1<r) {
      if(c[t[i]][temp]>pre) {
        r=temp;
      }
      else {
        l=temp;
      }
      temp=(l+r)/2;
    }
    if(r==c[t[i]].size()) {
      pre=c[t[i]][0];
      ans+=s.size();
    }
    else {
      pre=c[t[i]][r];
    }
  }
  ans+=pre+1;
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }

// a >= b であること
ll gcd(ll a, ll b) {
  ll next = a % b;
  if(next == 0) return b;
  return gcd(b, next);  
}

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



int main() {
  ll N, Y;
  cin >> N >> Y;
  
  //10000について全探索
  for(int i=0; i<=N; ++i) {
    ll remY = Y - 10000LL * i;
    int remN = N - i;
    if(remY < 0 || (5000 * remN - remY) % 4000 != 0) continue;
    
    ll kouho5 = (5000 * remN - remY) / 4000;
    ll kouho1 = remN - kouho5;
    if(kouho5 < 0 || kouho1 < 0) continue;
    
    cout << i << " " << kouho1 << " " << kouho5 << endl;
    return 0;
  }
  
  cout << "-1 -1 -1" << endl;
  
  return 0;
}



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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

map<int,int>map1;

void prime(int n){
    int r = sqrt(n);
    for(int i=2;i<r+1;i++){
        while(n%i==0){
            n /= i;
            map1[i]++;
        }
    }
    if(n>1)map1[n]++;
}


int main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i=1;i<n+1;i++)prime(i);
    for(const auto& x:map1){
        int num = x.second;
        ans *= num+1;ans%=MOD;
    }
    COUT(ans);
    return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int count = 0;
	vector<int> v(N), c(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++)
	{
		if (v[i] > c[i])
		{
			count += v[i] - c[i];
		}
	}
	printf("%d", count);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1000000000000
#define fr first
#define sc second
using vl =vector<ll>;
using vvl =vector<vl>;
const ll md = 1000000007;
vl fac(2,1), ifac(2,1);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(ll n, ll r, ll mod = md) {
    if(n < r) return 0;
    return ml(fac[n], ml(ifac[r], ifac[n-r], mod), mod);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int n;
   	cin >> n;
   	vector<pair<ll,ll>> a(n);
   	for(int i = 0; i < n; ++i) {
   		cin >> a[i].fr >> a[i].sc;
   	}
   	sort(a.begin(), a.end());
   	vl diff(n), diff2(n);
   	diff[0] = a[0].sc - a[0].fr;
   	diff2[0] = a[0].fr + a[0].sc;
   	for(int i = 1; i < n; ++i) {
   		diff[i] = max(diff[i-1], a[i].sc - a[i].fr);
   		diff2[i] = min(diff2[i-1], a[i].fr + a[i].sc);
   	}
   	ll hi = 0;
   	for(int i = 1; i < n; ++i) {
   		hi = max(hi, a[i].fr + a[i].sc - diff2[i-1]);
   	}
   	for(int i = 1; i < n; ++i) {
   		hi =  max(hi, a[i].fr - a[i].sc + diff[i-1]);
   	}
   	cout << hi << "\n";
    return 0;
}

Measured memory_bytes: 9516
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <queue>
#include <limits.h>
using namespace std;

typedef long long ll;

const int N = 1e5;
int n, m, dp[N];
vector<vector<int> > g;

int calc(int v) {
	int &res = dp[v];
	if (res != -1)
		return res;
	res = 0;
	for (int u : g[v])
		res = max(res, calc(u) + 1);
	return res;
}

int main(int argc, char **argv) {
	scanf("%d%d", &n, &m);
	g.resize(n);
	for (int i = 0; i < m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		--u, --v;
		g[u].push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	int res = 0;
	for (int i = 0; i < n; ++i)
		res = max(res, calc(i));
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
using namespace std;
 
int main(){
  int n,ans=0;
  cin>>n;
  while(n--){
    int a;
    cin>>a;
    int i=2;
    while(i*i<=a&&a%i) i++;
    if(a%i||a==2) ans++; 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>                
using namespace std;
int N, i, sumt, sumab;
bool answer;/* trueの時No*/  
typedef struct str_s{
	int t;
	int x;
	int y;
}STR; 
STR str[100005];

int main(void){
 int N;
 cin >> N;
 for(i = 1; i <= N; i++){
	 cin >> str[i].t >> str[i].x >> str[i].y;
	 sumt = str[i].t-str[i-1].t;
	 sumab = abs(str[i].x-str[i-1].x)+abs(str[i].y-str[i-1].y);
	 if(sumt < sumab || sumt%2 != sumab%2 ) answer = true;
 }
 if(answer) puts("No");
 else puts("Yes");
}


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

using namespace std;
using ll = long long;

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

// ll h(int A, int x) { return A / x; }

// ll g(int A, int B, int x) {
//   int d = h(B, x) - h(A - 1, x);
//   if (d % 2 == 0) return 0;
//   return x;
// }

ll g(ll x, int i) {
  ll d = pow(2, i + 1);
  ll a = x % d;
  ll b = x / d;
  return b * (d / 2) + max(0LL, a - (d / 2 - 1));
}

ll h(ll x, ll y, int i) {
  ll c = g(y, i) - g(x, i);
  if (c & 1) return pow(2, i);
  return 0;
}

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

  ll ans = 0;
  rep(i, 45) { ans += h(a - 1, b, i); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4008
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int A, sum;
	for (int i = 0; i < 3; i++)
	{
		cin >> A;
		if(A!=5 && A!=7)
		{
			cout << "NO" << endl;
			return 0;
		}
		else
		{
			sum += A;
		}
	}
	if(sum==17)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

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

int main(void){
	int n, i;
	scanf("%d", &n);
	int v[50];
	for(i=0; i<n; i++){
		scanf("%d", v+i);
	}
	qsort(v, n, sizeof(int), comp);
	double ans = v[0];
	for(i=1; i<n; i++){
		ans = (ans+v[i])/2;
	}
	printf("%lf\n", ans);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
const ll mod = 1000000000 + 7;


char s[maxn];
int n, k, a[110];
ll dp[200][10];
ll dfs(int pos, bool lead, bool limit, int state) {
    if (pos == -1 && state == 0) return 1;
    if (pos == -1 && state != 0) return 0;
    if (!limit && !lead && dp[pos][state] != -1) return dp[pos][state];
    int up = limit ? a[pos] : 9;
    if (state == 0) up = 0;
    ll ans = 0;
    int st = state;
    for (int i = 0; i <= up; i++) {
        if (i != 0) st = max(0, state - 1);
        ans += dfs(pos - 1, lead && i == 0, limit && i == a[pos], st);
    }
    if (!limit && !lead) dp[pos][state] = ans;
    return ans;
}
ll solve() {
    memset(dp, -1, sizeof(dp));
    int pos = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[pos++] = s[i] - '0';
    }
    return dfs(n - 1, true, true, k);
}
int main() {
    cin >> s >> k;
    n = strlen(s);
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<string> s;
    string t;
    s.pb("11");
    s.pb("101");
    s.pb("0100");
    if(n==1){
    	cout << "1" <<endl;
    	cout << "0" <<endl;
    	return 0;
    }
    if(n==2||n==3){
    	cout << "2" <<endl;
    	cout <<"0" <<endl;
     	cout << "11" <<endl;
     	return 0;
    }
    t="0";
    for(int i=0;i<=n-5;i++){
    	t+="0";
    	s.pb("1"+t+"10");
    }
    cout << s.size() <<endl;
    for(auto i:s){
    	cout << i<<endl;
    }

    return 0;
}



Measured memory_bytes: 3336
//
//  main.cpp
//  binary_search_tree_1
//
//  Created by ???????????? on 2017/10/11.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <cstdlib>

//#define NIL Nodes a.parent = -1
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *nil;
Node *root;


void init(int key){
    nil = (Node *) malloc(sizeof(Node));
    nil->parent = nil->left = nil->right = nil;
    nil->key = -1;
    
    root = (Node *) malloc(sizeof(Node));
    root->key = key;
    root->left = root->right = nil;
}

Node* init_node(int key){
    Node *node = (Node *) malloc(sizeof(Node));
    node->parent = node->left = node->right = nil;
    node->key = key;
    return node;
}

void insert(Node* z){
    Node *y = nil;
    Node *x = root;
    while(x != nil){
        y = x;
        if(z->key  < x->key) x = x->left;
        else x = x->right;
    }
    
    z->parent = y;
    
    if(y==nil) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;
    
}

void find(Node* x,int key){
    while(x != nil && key != x->key ){
        if(key < x->key) x = x->left;
        else x = x-> right;
    }
    if (x==nil) cout << "no" << endl;
    else cout << "yes" << endl;
}

void in_parse(Node* u){
    if (u->key == -1) return;
    in_parse(u->left);
    cout <<" "<<u->key;
    in_parse(u->right);
}

void pre_order(Node* u){
    if (u->key == -1) return;
    cout <<" "<<u->key;
    pre_order(u->left);
    pre_order(u->right);
}


int main(int argc, const char * argv[]) {
    int n, i, key, find_num;
    int ini = 0;
    char command[10];
    scanf("%d", &n);
    //    Node nodes[n];
    for(i = 0; i < n; i++){
        scanf("%s", command);
        if(command[0] == 'p'){
            in_parse(root);
            cout <<endl;
            pre_order(root);
            cout<<endl;
            ini ++;
        }
        else if(command[0] == 'f') {
            scanf("%d",&find_num);
            find(root, find_num);
        }
        else{
            scanf("%d", &key);
            if(i==ini) init(key);
            else {
                Node* z = init_node(key);
                insert(z);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 21848
def d(x,y):
    return ((x[0]-y[0])**2+(x[1]-y[1])**2)**(1/2)
n= int(input())
x=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
    for j in range(n):
        ans+=d(x[i],x[j])
print(ans/n)


Measured memory_bytes: 3060
import * as fs from "fs";

export class Reader {
  lines: string[];
  currentLine: number;

  constructor() {
    this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
    this.currentLine = 0;
  }

  readLine(): string {
    return this.lines[this.currentLine++];
  }

  readInt(): number {
    return Number(this.readLine());
  }

  readInts(): number[] {
    return this.readLine().split(" ").map(Number);
  }
}

interface Program {
  start: number;
  end: number;
}

function solve(): number {
  let reader = new Reader();
  let [N, C] = reader.readInts();
  let channelPrograms: Program[][] = new Array(30).fill(null).map(() => []);
  for(let i=0; i<N; i++) {
	let [s, t, c] = reader.readInts();
	channelPrograms[c-1].push({start: s, end: t});
  }
  for(let i=0; i<30; i++) {
	channelPrograms[i].sort((a, b) => a.start-b.start);
	let groupedPrograms: Program[] = [];
	for(let j=0; j<channelPrograms[i].length; j++) {
	  let l = groupedPrograms.length;
	  if (l == 0) {
		groupedPrograms.push(channelPrograms[i][j]);
	  } else {
		if (groupedPrograms[l-1].end == channelPrograms[i][j].start) {
		  groupedPrograms[l-1].end = channelPrograms[i][j].end;
		} else {
		  groupedPrograms.push(channelPrograms[i][j]);
		}
	  }
	}
	channelPrograms[i] = groupedPrograms;
  }
  
  // should start first if times are same
  let START = 0,
	  END = 1;
  let events: [number, number][] = [];
  for(let i=0; i<channelPrograms.length; i++) {
	for(let j=0; j<channelPrograms[i].length; j++) {
	  events.push([channelPrograms[i][j].start, START]);
	  events.push([channelPrograms[i][j].end, END]);
	}
  }
  events.sort(function(a, b) {
	if (a[0] == b[0]) {
	  return a[1]-b[1];
	}
	return a[0]-b[0];
  });
  let maximumStreams = 0;
  let activeStream = 0;
  for(let i=0; i<events.length; i++) {
	if (events[i][1] == START)
	  activeStream += 1;
	else
	  activeStream -= 1;
	maximumStreams = Math.max(maximumStreams, activeStream);
  }
  return maximumStreams;
}


console.log(solve());


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

typedef long long ll;

const int MAX = 2000000;
const ll MOD = 1000000007LL;
ll fac[MAX], finv[MAX], inv[MAX];
 
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数
ll combination(int n, int k) {
    init();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll x, y; cin >> x >> y;

    ll res = 0;
    ll n = (-x + 2 * y) / 3;
    ll m = (2 * x - y) / 3;
    if ((x + y) % 3 == 0 && n >= 0 && m >= 0) {
        res = combination(n + m, n);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<pii> d(n);

  for (int i = 0; i < n; i++) {
    cin >> d[i].first >> d[i].second;
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (d[i].first == d[i].second)
      count++;
    else
      count = 0;
    if (count >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll total = 0;
    for (int i = 0; i <n; i++){
        cin >> a[i];
        total += a[i];
    } 
    sort(all(a));
    bool flag = true;
    for (int i = 0; i < m; i++){
        if (a[n-i-1] < (double) total/(4*m)){ 
            flag = false;
            break;
        }
    }
    if (flag) cout << "Yes\n";
    else cout << "No\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int n, a[100];
  scanf("%d", &n);
  int min = 0, max = 0, p = 0, m = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) m++;
    if (a[i] > 0) p++;
    if (a[min] > a[i]) min = i;
    if (a[max] < a[i]) max = i;
  }

  if (a[min] >= 0) {
    printf("%d\n", n - 1);
    for (int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
    return 0;
  }

  else if (a[max] <= 0) {
    printf("%d\n", n - 1);
    for (int i = n - 1; i >= 1; i--) printf("%d %d\n", i + 1, i);
    return 0;
  }

  else {
    if (a[max] >= -a[min]) {
      printf("%d\n", m + n - 1);
      for (int i = 0; i < n; i++) {
	if (a[i] < 0) {
	  printf("%d %d\n", max + 1, i + 1);
	}
      }
      for (int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
      return 0;
    } else {
      printf("%d\n", p + n - 1);
      for (int i = 0; i < n; i++) {
	if (a[i] > 0) {
	  printf("%d %d\n", min + 1, i + 1);
	}
      }
      for (int i = n - 1; i >= 1; i--) printf("%d %d\n", i + 1, i);
      return 0;
    }
  }
}


Measured memory_bytes: 128
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var num = int.Parse(input);

            for (int i = 1; i <= num; i++)
            {
                var x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" {0}", i);
                    continue;
                }
                while (0!=x)
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" {0}", i);
                        break;
                    }
                    x /= 10;
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 19952
import java.util.*;

public class Main {


    static class Pair {
            int x=0;
            int y=0;
            Pair(int x , int y){
                this.x = x;
                this.y = y;
            }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return x == pair.x &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }
    }

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

        if(N==1){
            System.out.println(1);
            return ;
        }

        int[][]  nums = new int[N][2];
        Set<Pair> s = new HashSet<>();
        for (int i = 0; i < N; i++) {
            nums[i][0]=sc.nextInt();
            nums[i][1]=sc.nextInt();
            s.add(new Pair(nums[i][0],nums[i][1]));
        }

        HashMap<Pair,Integer> m = new HashMap<>();
        int max = 0;
        Pair maxPair = new Pair(0,0);
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length; j++) {
                if(i!=j){
                    int p = nums[j][0] - nums[i][0];
                    int q = nums[j][1] - nums[i][1];
                    Pair nw = new Pair(p,q);
                    if(!m.containsKey(nw)){
                        m.put(nw,1);
                    }else{
                        m.put(nw,m.get(nw)+1);
                    }

                    if(m.get(nw) > max ){
                        max =m.get(nw);
                        maxPair = nw;
                    }

                }
            }
        }

        int count =0;
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length; j++) {
                int p = nums[j][0] - nums[i][0];
                int q = nums[j][1] - nums[i][1];
                if(maxPair.x == p && maxPair.y == q){
                    count++;
                }
            }
        }

        System.out.println(N-count);
    }

}


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

class DisjointSet {
	public:
	
	vector<int> rank, p;

	DisjointSet(){}
	DisjointSet(int size){
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0; i<size; i++) makeSet(i);
	}

	void makeSet(int x){
		p[x]=x;
		rank[x]=0;
	}

	bool same(int x, int y){
		return findSet(x)==findSet(y);
	}

	void unite(int x, int y){	// 合併
		link( findSet(x), findSet(y) );
	}

	void link(int x, int y){	// x,yを含む集合を合併
		if( rank[x]>rank[y]){
			p[y]=x;
		}else{
			p[x]=y;
			if(rank[x]==rank[y]) rank[y]++;
		}
	}

	int findSet(int x){		// 根っこを返す
		if(x != p[x]){
			p[x]=findSet(p[x]);
		}
		return p[x];
	}
};



int main(){
	int n,q;	cin>>n>>q;
	DisjointSet ds = DisjointSet(n);

	int t,a,b;
	for(int i=0;i<q;i++){
		cin>>t>>a>>b;
		if(t==0) ds.unite(a,b);
		else if(t==1){
			if(ds.same(a,b)) cout<<1<<endl;
			else cout<<0<<endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double EPS = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int n;
double v[3010];
double dp[2][3010];
double f(int i, int tail){
    if(i == n){
        return 1;
    }
    double &ans = dp[i][tail];
    if(ans < 0){
        ans = 0;
        int head = n - tail;
        if(head > tail + 1)
            ans += f(i + 1, tail + 1) * (1.0 - v[i]);
    
        ans += f(i + 1, tail) * v[i];
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = n; i >= 0; i--){
        for(int tail = 0; tail < n; tail++){
            double &ans = dp[i & 1][tail];    
            if(i == n){
                ans = 1;
                continue;
            }
            ans = 0;
            ans += dp[(i + 1) & 1][tail] * v[i];
            int head = n - tail;
            if(head > tail + 1)
                ans += dp[1 & (i + 1)][tail + 1] * (1.0 - v[i]);
        }
    }
    
    cout << fixed << setprecision(9) << dp[0 & 1][0] << '\n';
    EjecuteTime;
    return 0;
}       

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

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

  int sum = 0;
  for(int i = 0; i < n.length(); i++){
    sum += n[i] - '0';
  }

  sum % 9 == 0 ? cout << "Yes" << endl : cout << "No" << endl; 
return 0;
}

Measured memory_bytes: 3740
n=int(input())
a=list(map(int,input().split()))
ans=0
count=1
x=10000
for i in range(1,n):
    if a[i-1]==a[i]:
        count+=1
    else:
        ans+=count//2
        count=1
    if i==n-1:
        ans+=count//2
print(ans)


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

int main() {
  //ios_base::sync_with_stdio(false);
  //cin.tie(nullptr);
  int n;
  cin >> n;
  int v[n], c[n];
  for (int i = 0; i < n;++i)
    cin >> v[i];
  for (int i = 0; i < n;++i)
    cin >> c[i];
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int diff = v[i] - c[i];
    if(diff>0)
      sum += diff;
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3632
//a から b までの整数の中に、c の約数がいくつあるかを求めるプログラム
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int n,m;//範囲の整数
	int i;//初期化しない
	int x;//求める約数の整数
	int k;//約数の個数
	int rem;//余り
	k = 0;
	scanf("%d %d %d", &n, &m,&x);
	
	for (i = n; i <= m; i++) {
		rem=x %i;
		if (rem == 0) 
			k += 1;
		
		
	}
	printf("%d\n", k);

		return 0;
}



Measured memory_bytes: 2144
import collections
s = input()
t = input()
dd = collections.defaultdict(str)
dd2 = collections.defaultdict(str)
for i in range(len(s)):
    if dd[t[i]] == '':
        dd[t[i]] = s[i]
    if dd[t[i]] != '' and dd[t[i]] != s[i]:
        print('No')
        exit()
for i in range(len(s)):
    if dd2[s[i]] == '':
        dd2[s[i]] = t[i]
    if dd2[s[i]] != '' and dd2[s[i]] != t[i]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 4144
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

int main()
{
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  partial_sum(ALL(A), A.begin());
  ll ans = LLINF;
  ll sum = A[N-1];
  REP(i, N-1) {
    ll l = A[i], r = sum - A[i];
    ans = min(ans, abs(r - l));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
# coding:utf-8
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    total = 0

    for i in list(reversed(range(1,n+1))):
        #一歩先を倒す処理
        if a[i] > b[i-1]:
            total += b[i-1]
            a[i] = a[i] - b[i-1]
            b[i-1] = 0
        else:
            total += a[i]
            b[i-1] = b[i-1] - a[i]
            a[i] = 0

        #自分の街を助ける処理
        if a[i-1] > b[i-1]:
            total += b[i-1]
            a[i-1] = a[i-1] - b[i-1]
            b[i-1] = 0
        else:
            total += a[i-1]
            b[i-1] = b[i-1] -a[i-1]
            a[i-1] = 0

    print(total)


if __name__ == '__main__' :
    main()

Measured memory_bytes: 19004
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

vector<vector<long long int>> v_t;
vector<vector<long long int>> v_p;

long long int dfs(int depth,long long int kaitenlist[],int N){
    if(depth==10){
        int check=0;
        for(int i=0;i<10;i++){
            check += kaitenlist[i];
        }
        if(check==0) return -1e10;

        long long int res=0;
        for(int i=0;i<N;i++){
            check=0;
            for(int j=0;j<10;j++){
                check += kaitenlist[j]*v_t.at(i)[j];
            }
            res += v_p.at(i)[check];
        }
        return res;
    }
    kaitenlist[depth]=1;
    long long int ret1 = dfs(depth+1,kaitenlist,N); 
    kaitenlist[depth]=0;
    long long int ret2 = dfs(depth+1,kaitenlist,N); 

    return max(ret1,ret2);
}

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

    for(int i=0;i<n;i++){
        vector<long long int> v;
        for(int j=0;j<10;j++){
            int tmp;cin >> tmp;
            v.push_back(tmp);
        }
        v_t.push_back(v);
    }

    for(int i=0;i<n;i++){
        vector<long long int> v;
        for(int j=0;j<=10;j++){
            int tmp;cin >> tmp;
            v.push_back(tmp);
        }
        v_p.push_back(v);
    }

    long long int list[10]={};
    p(dfs(0,list,n))
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

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

	if (a + b >= 24)
		cout << a + b - 24;
	else
		cout << a + b;

	return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
N = int(input())
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist) > 1:
    atk = heappop(Alist)
    Alist = [A % atk for A in Alist if (A % atk != 0)]
    heapify(Alist)
    heappush(Alist, atk)
print(Alist[0])


Measured memory_bytes: 14184
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
#define all(a) (a).begin(),(a).end()
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

#ifdef CHEN_PC
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif

const int N = 200010;
const int mod = 1000000007; // 10^9+7
int n;
int a[N];
int b[N];
int type[N];
int cnt[4];

ll solve() {
    ll suma = 0;
    ll sumb = 0;
    forn (i, n) {
        suma += a[i];
        sumb += b[i];
    }
    ll ans = min(suma, sumb);

    vector<pair<int, pii>> arr;
    forn (i, n) {
        arr.emplace_back(MP(a[i], MP(i, 1)));
        arr.emplace_back(MP(b[i], MP(i, 2)));
    }
    sort(all(arr));
    clr(type, 0);
    clr(cnt, 0);
    ll val = 0;
    forn (i, n) {
        auto v = arr[i];
        val += v.first;
        type[v.second.first] |= v.second.second;
    }
    forn (i, n) {
        cnt[ type[i] ]++;
    }
    if (cnt[0] != 0) {
        return val;
    }
    forn (i, n) {
        auto v = arr[n + i];
        for (int j = n - 1; j >= 0; --j) {
            if (arr[j].second.first != v.second.first) {
                ans = min(ans, val + v.first - arr[j].first);
                break;
            }
        }
    }
    return ans;
}

int main(int argc, char *argv[]) {
#ifdef CHEN_PC
    freopen("C.in", "r", stdin);
#endif

    while (scanf("%d", &n) != EOF) {
        forn (i, n) {
            scanf("%d%d", a + i, b + i);
        }
        ll ret = solve();
        printf("%lld\n", ret);
    }
    return 0;
}



Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<pair<string, int>> v(n);
  rep(i,n){
    string s;
    int t;
    cin >> s >> t;
    v[i] = make_pair(s, t);
  }
  string x;
  cin >> x;
  int ok = false;
  int ans = 0;
  rep(i,n){
    if(ok) ans += v[i].second;
    else if(x == v[i].first) ok = true;
  }
  cout << ans << endl;
}






Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      Scanner sc = new Scanner(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
      int N = Integer.parseInt(sc.next());
      int preT = 0;
      int preX = 0;
      int preY = 0;
      
      boolean judge = true;
      for(int i = 0; i < N; i++){
      	int postT = Integer.parseInt(sc.next());
        int postX = Integer.parseInt(sc.next());
        int postY = Integer.parseInt(sc.next());
        
        int dt = postT - preT;
        int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
        if(dt < dist || (dt - dist) % 2 != 0){
        	judge = false;
          	break;
        }
        preX = postX;
        preY = postY;
        preT = postT;
      }
      
      if(judge){
      	 out.println("Yes");
      }else {
     	 out.println("No");
      }
      out.close();
    }
}

Measured memory_bytes: 62812
N=gets.strip.to_i

AB=(0..N-1).map{|i| gets.strip.split.map(&:to_i)}

AB.sort_by!{|i| i[1]}
now=0

AB.each do |i|
    now+=i[0]
    if now>i[1] then
        puts "No"
        exit
    end

end
puts 'Yes'


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    vector<int> v(9);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        v[min(8, a / 400)]++;
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) if (v[i]) ans++;
    cout << max(ans, 1) << " " << ans + v[8] << endl;
    return 0;
}


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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int start = H1 * 60 + M1;
  int end = H2 * 60 + M2 - K;
  int ans = end - start;
  cout << ans << endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            if (n % 2 == 0)
            {
                WriteLine(n / 2);
            }
            else WriteLine((n / 2) + 1);
        }
    }
}


Measured memory_bytes: 13140
import sys
rect = 0
loze = 0
for line in sys.stdin:
    s = line.split(',')
    a,b,c = int(s[0]),int(s[1]),int(s[2])
    if a**2 + b**2 == c**2:
        rect += 1
    if a == b and a+b > c:
        loze += 1
print(rect)
print(loze)

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
ll a[maxn] , res[maxn] , _max , now;
map<ll , ll> mp , ind;
set<ll> st;
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
        if(ind.find(a[i]) == ind.end())
            ind[a[i]] = i;
        ind[a[i]] = min(ind[a[i]] , (ll)i);
        st.insert(a[i]);
    }
    _max = *st.rbegin();
    now = _max;
    ll nowind = ind[_max] , t = mp[_max];
    st.erase(_max);
    while(!st.empty())
    {
        ll x = *st.rbegin();
        st.erase(x);
        res[nowind] += (now - x) * (t);
        t += mp[x];
        now = x;
        nowind = min(nowind , ind[x]);
    }

    res[nowind] += now * t;
    for(int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

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

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    COMinit();
    ll n,m,k;cin >> n >> m >> k;
    mint ans = 0;
    mint mult = (mint)COM(n*m-2,k-2); 
    for(ll d = 0;d <= n-1;d++){
        ans += (mint)d*(mint)(n - d)*(mint)m*(mint)m*mult;
    }
    for(ll d = 0;d <= m-1;d++){
        ans += (mint)d*(mint)(m - d)*(mint)n*(mint)n*mult;
    }
    cout << ans.x << '\n';
    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;
 
long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}
 
ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  while (q-- >0) {
    int a;
    cin >> a;
    if (a < 600) {
      cout << 8 << "\n"; 
    } else if (a < 800) {
      cout << 7 << "\n"; 
      
    } else if (a < 1000) {
      
      cout << 6 << "\n"; 
    } else if (a < 1200) {
      
      cout << 5 << "\n"; 
    } else if (a < 1400) {
      
      cout << 4 << "\n"; 
    } else if (a < 1600) {
      
      cout << 3 << "\n"; 
    } else if (a < 1800) {
      
      cout << 2 << "\n"; 
    } else {
      
      cout << 1 << "\n"; 
    }
  }
 
  return 0;
}


Measured memory_bytes: 3652