akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

ll ans = 0;

void dfs(ll x, bool c3, bool c5, bool c7, ll N){
  if(c3&&c5&&c7){
  	ans++;
  }
  if(10*x+3 <= N){
	dfs(10*x+3, 1, c5, c7, N);
  }
  if(10*x+5 <= N){
    dfs(10*x+5, c3, 1, c7, N);
  }
  if(10*x+7 <= N){
    dfs(10*x+7, c3, c5, 1, N);
  }
}

void Main()
{
  ll N;
  cin >> N;
  dfs(0, 0, 0, 0, N);	  
  cout << ans << endl;
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll a,b,c;
  cin >> a >> b >> c;
  if(a==b&&a!=c) cout << "Yes" << endl;
  else if(a==c&&a!=b) cout << "Yes" << endl;
  else if(b==c&&a!=b) cout << "Yes" << endl;
  else  cout << "No" << endl;
  
}

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

using namespace std;

const auto PI = 3.14159265358979312;
const auto DEG_TO_RAD = PI/180;

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

	auto x = b*cos(C*DEG_TO_RAD);
	auto h = sqrt(b*b - x*x);
	auto a1 = h*x/2;
	auto y = a - x;
	auto c = sqrt(y*y + h*h);
	auto a2 = h*y/2;

	auto S = a1 + a2;
	auto L = a + b + c;
	cout << fixed << setprecision(17);
	cout << S << ' ' << L << ' ' << h << endl;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define N 1005
using namespace std;
int hav[N],n,ans=0,mat;
int a[N][N];
bool flag;
vector<int> ad,pos;
int main(){
	int i,j,x,y,c,d;
	cin>>n;
	mat=n*(n-1)/2;
	for(i=0;i<n;i++)
	{
		ad.push_back(i);
		for(j=0;j+1<n;j++)
		{
			cin>>x;
			a[i][j]=x-1;
		}
	}
	memset(hav,0,sizeof(hav));
	while(1)
	{
		ans++;
		bool book[N]={};
		flag=true;
		pos.clear();
		for(j=0;j<ad.size();j++)
		{
			i=ad[j];
			if(book[i]||hav[i]>=n-1)
			{
				continue;
			}
			y=a[i][hav[i]];
			if(book[y]||hav[y]>=n-1)
			{
				continue;
			}
			d=a[y][hav[y]];
			if(d==i)
			{
				flag=false;
				hav[i]++;
				hav[y]++;
				mat--;
				book[i]=true;
				book[y]=true;
				pos.push_back(i);
				pos.push_back(y);
			}
		}
		if(mat<=0)
		{
			cout<<ans<<endl;
			return 0;
		}
		if(flag)
		{
			cout<<-1<<endl;
			return 0;
		}
		ad=pos;
	}
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

// A - Serval vs Monster
// https://atcoder.jp/contests/abc153/tasks/abc153_a
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = Integer.parseInt(scanner.next());
        int A = Integer.parseInt(scanner.next());
        scanner.close();

        System.out.println((int) Math.ceil(H / (double) A));
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<int> b(n - 1);
    for(int i = 0; i < n - 1; i++) cin >> b[i];

    int ans = b[0];
    for(int i = 1; i < n - 1; i++){
        if(b[i - 1] < b[i]) ans += b[i - 1];
        else ans += b[i];
    }
    ans += b[n - 2];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795L
#ifndef DEBUG
#define debug(args...)
#else
#include "debug.h"
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
vector<int> adj[100000];
bool v[100000]={false};
int bp[100000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  freopen("inp.txt", "r", stdin);
#endif
  int n, m;
  cin>>n>>m;
  for (int i=0;i<m;i++){
    int a, b;
    cin>>a>>b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  v[0]=true;
  int cnt=1;
  while (q.size()) {
    int c=q.front(); q.pop();
    for (int nb:adj[c]) {
      if (v[nb]) continue;
      v[nb]=true;
      bp[nb]=c;
      q.push(nb);
      cnt++;
    }
  }
  if (cnt!=n) return cout<<"No\n",0;
  cout<<"Yes\n";
  for (int i=1;i<n;i++) cout<<bp[i]+1<<'\n';
  return 0;
}


Measured memory_bytes: 10636
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,t,u; cin >> s >> t >> u;
    int diff = 'a' - 'A';
    cout << (char)(s[0]-diff) << (char)(t[0] - diff) << (char)(u[0] - diff) << endl;
    return 0;
}

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

int main()
{
	int n, m = 0;
	int w[100];

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> w[i];
		m += w[i];
	}

	int d = m, s = 0;

	for (int i = 0; i < n; i++) {
		s += w[i];
		d = min(d, abs(m - s * 2));
	}

	cout << d << endl;

	return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] == 'E') {
            ans++;
        }
    }

    int t = ans;
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'W') {
            t++;
        }
        if (S[i] == 'E') {
            t--;
        }
        ans = min(ans, t);
    }

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

Measured memory_bytes: 900
import itertools as it

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = 0
b = 0
n = it.permutations(range(1, N + 1), N)
for i, e in enumerate(n):
    if P == e:
        a = i
    if Q == e:
        b = i

print(abs(a - b))


Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
using namespace std;
int n, m;
int x, y, z;
int c;
vector<int> g[100000];
int s[100000];
void dfs(int a, int b) {
	s[a] = 1;
	for (int i = 0; i < g[a].size(); i++) {
		if (g[a][i] != b && s[g[a][i]] == 0)dfs(g[a][i], a);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &x, &y, &z);
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == 0) {
			c++;
			dfs(i, i);
		}
	}
	printf("%d\n", c);
}

Measured memory_bytes: 10752
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	cout << count(str.begin(), str.end(), '1') << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
int res = 0;
int n,m,q;
vector<int> A;
vector<int> a,b,c,d;
void dfs(int pos,int val){
  if(pos == n){
    int total = 0;
    REP(i,q){
      if(A[b[i]]-A[a[i]]==c[i]){
        total+=d[i];
      }
    }
    
    chmax(res,total);
  }else{
    for(int i=val;i<=m;i++){
      A[pos] = val;
      dfs(pos+1,i);
    }
  }
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin >> n >> m >> q;
  A.resize(n);
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  REP(i,q){
	cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  dfs(0,1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>

int gcd(int x, int y){
    int r;
    while((r = x % y) != 0){
        x = y;
        y = r;
    }
    return y;
}

long long lcm(int x, int y){
    return ((long long)x * y / gcd(x, y));
}
long long a,b,lcmCD;
int c,d;

long long numCount(long long x){
	return x-((x/c)+(x/d)-(x/lcmCD));
}
int main(){
	scanf("%lld%lld%d%d", &a,&b,&c,&d);
	lcmCD=lcm(c,d);
	printf("%lld\n",numCount(b)-numCount(a-1));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n;
  cin >> n;
  vector<P> d;

  rep (i, n) {
    int a; cin >> a;
    d.push_back({a, i});
  }

  sort(d.begin(), d.end());

  for (auto v : d) {
    cout << v.second + 1 << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4260
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int c = scanner.nextInt();
			if ((n | c) == 0)
				break;
			int[] a = new int[n];
			int[] b = new int[c];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < 16; j++)
					a[i] |= (scanner.nextInt() << j);
			for (int i = 0; i < c; i++)
				for (int j = 0; j < 16; j++)
					b[i] |= (scanner.nextInt() << j);
			int[][] dp = new int[2][1 << 16];
			Set<Integer> set = new HashSet<Integer>();
			set.add(0);
			Arrays.fill(dp[0], -1);
			dp[0][0] = 0;
			int X = 1;
			for (int i = 0; i < n; i++, X = 1 - X) {
				Arrays.fill(dp[X], -1);
				Set<Integer> tmp = new HashSet<Integer>();
				for (int S : set) {
					int light = S | a[i];
					for (int j = 0; j < c; j++) {
						int pushed = light & b[j];
						int point = Integer.bitCount(pushed);
						int nx = light & ~b[j];
						if (dp[X][nx] < dp[1 - X][S] + point) {
							dp[X][nx] = dp[1 - X][S] + point;
						}
						tmp.add(nx);
					}
				}
				set.clear();
				set.addAll(tmp);
			}
			int max = 0;
			for (int i = 0; i < 1 << 16; i++)
				max = Math.max(max, dp[1 - X][i]);
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 303716
#include <iostream>
#include <vector>
#include <stdio.h>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

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

  if(a-k>=0){
    cout << a-k << " " << b << endl;
    return 0;
  }
  else if(a+b-k>=0){
    cout << 0 << " " << a+b-k << endl;
    return 0;
  }
  else{
    cout << 0 << " " << 0 << endl;
    return 0;
  }  
  
}


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

stores = []
for i in range(N):
    stores.append(list(map(int,input().split())))

stores = sorted(stores)
drinks = 0
price = 0
for s in stores:
    drinks += s[1]
    price += s[0] * s[1] 
    if drinks == M:
        break
    elif drinks > M:
        price -= (drinks - M) * s[0]
        break
        
print(price)

Measured memory_bytes: 28656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int l = n/100;
    int r = n%100;
    
    if(1<=l and l<=12){
        if(1<=r and r<=12)cout << "AMBIGUOUS";
        else cout << "MMYY";
    }
    else{
        if(1<=r and r<=12)cout << "YYMM";
        else cout << "NA";
    }
    
	return 0;
}

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

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

	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p.at(i);
	}

	int count = 0;
	vector<int> idx;
	for (int i = 1; i < n; i++)
	{
		if (p.at(i) < p.at(i - 1))
		{
			count++;
			idx.push_back(i);
		}
	}

	if (count == 2)
	{
		int tmp = p.at(idx.at(0) - 1);
		p.at(idx.at(0) - 1) = p.at(idx.at(1));
		p.at(idx.at(1)) = tmp;
	}

	count = 0;
	for (int i = 1; i < n; i++)
	{
		if (p.at(i) < p.at(i - 1))
		{
			count++;
		}
	}

	if (count == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
from collections import defaultdict
def power_func(a, n, p=2019):
    bi = str(format(n, "b"))  # 2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

s=input()
d=[]
for i in range(len(s)):
    d.append(int(s[i])*power_func(10,len(s)-i-1,2019)%2019)
d1=[d[0]]
for g in range(1,len(s)):
    d1.append((d1[-1]+d[g])%2019)

di = defaultdict(int)
ans=0
for i in range(len(s)):
    di[d1[i]]+=1
    if d1[i]==0:
        ans+=1
    ans+=di[d1[i]]-1
print(ans)

Measured memory_bytes: 24112
#include <iostream>

using namespace std;

int x, r, r2;

int main()
{
  cin >> x;
  r += x / 500;
  r *= 1000;
  x %= 500;
  r2 += x / 5;
  r2 *= 5;
  r += r2;
  cout << r;
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n, k;cin >> n >> k;
    LL ans = 0LL;
    inc(i, 1, n+1){
        ans += n/i*max(0LL, i-k) + max(0LL, n%i-k+1);
    }
    if(k == 0) ans -= n;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
# Assumed solution

from collections import deque


def main():
    k = int(input())

    queue = deque()
    for i in range(1, 10):
        queue.append(i)

    l = 0
    for _ in range(k):
        l = queue.popleft()
        r = l % 10
        if r != 0:
            queue.append(l * 10 + r - 1)
        queue.append(l * 10 + r)
        if r != 9:
            queue.append(l * 10 + r + 1)
    print(l)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40560
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100000)

def main():
    N = int(input())
    sides = [[] for _ in range(N-1)]
    
    for i in range(N-1):
        a,b = map(int, input().split())
        sides[a-1].append((b-1,i))

    ans = [[None] for _ in range(N-1)]

    def dfs(focus,parent_color):
        if focus == N-1:
            return
        color = 1
        for child,index in sides[focus]:
            if parent_color == color:
                color += 1 #もし親の色と被っていた場合はその色を飛ばす
            ans[index] = color
            # if child < N-1:
            #     dfs(child,color)
            dfs(child,color)
            color += 1 #同じ親から続く次の辺の色を変更する

    dfs(0,0)

    print(max(ans)) 
    for color in ans:
        print(color)


if __name__ == "__main__":
    main()


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

int m;
int nmin;
int nmax;
int ps[1000000];

int main() {
  while (1) {
    scanf("%d%d%d", &m, &nmin, &nmax);
    if ((m|nmin|nmax) == 0) return 0;

    for (int i=0; i<m; i++) {
      scanf("%d", &ps[i]);
    }

    int ans;
    int md = -1;
    for (int i=nmax; i>=nmin; i--) {
      int d = -(ps[i] - ps[i-1]);
      if (d > md) {
        md = d;
        ans = i;
      }
    }

    printf("%d\n", ans);
  }
}

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

int ret, n;

void f(int idx, int sum, int c){
	if(sum == n){ret++; return;}
	if(c == 4) return;
	for(int i = idx; i*i+sum <= n; i++){
		f(i, i*i+sum, c+1);
	}
}

int main(){
	while(cin >> n, n){
		ret = 0;
		for(int i=1; i*i <= n; i++){
			f(i, i*i, 1);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
// #define int ll
vector<ll> ft(1, 1LL);
/*======================================================================*/
const int faxsize = 50;
vector<pair<int, int> >fax[faxsize];

void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(a > 0 and c > 0){
        if(i%2 == 0)c -= b;
        else a -= d;
        i++;
    }
    if(i%2)cout << "Yes";
    else cout << "No";
}
signed main() {
    rep(i, 2, faxsize+1)if(fax[i].size() == 0)repc(j, i, faxsize+1, i){int k = j, c = 0;while(k%i == 0)k/= i, c++;fax[j].push_back({i, c});}
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3640
use proconio::input;
use std::collections::HashSet;

fn main() {
    input!{
        n: i32,
        m: i32,
        h_array: [i32; n],
    };

    let mut set = HashSet::new();
    for i in 0..n {
        set.insert(i);
    }

    for _ in 0..m {
        input!{
            a: i32,
            b: i32,
        }

        if h_array[a as usize - 1] <= h_array[b as usize - 1] {
            set.remove(&(a - 1));
        }

        if h_array[a as usize - 1] >= h_array[b as usize - 1] {
            set.remove(&(b - 1));
        }
    }

    println!("{}", set.len());
}


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


int main(){
	int N; cin >> N;
	vector<int> d(N); for (int i = 0; i < N; i++) cin >> d[i];

	sort(d.begin(), d.end());
	int ans = d[N / 2] - d[N / 2 - 1];

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


Measured memory_bytes: 640
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int n, m, e, j;
	while(cin >> n, n) {
		rep(i,n) {
			cin >> m >> e >> j;
			int t = m+e+j;
			if(m==100||e==100||j==100||m+e>=180||t>=240) cout << "A" << endl;
			else if(t>=210||t>=150&&(m>=80||e>=80)) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
int N,M;
int s[MAX_N];

int check(int X){
  int res=0;
  int lv=1;
  while( lv + X <= s[N-1] ){
    
    int f=lower_bound(s,s+N,lv)-s;
    
    if( s[f] >= lv + X)f--;
    if(f>0 && abs(s[f]-lv) > abs(s[f-1]-lv) )f--;
    
    if(f<0)return 1e9;

    res++;
    lv+=max(1, X-abs(s[f]-lv));
  }
  return res+1;
}

int solve(){
  int left=s[0];
  int right=1e9;
  int mid;
  while(right-left>1){
    mid=(left+right)/2;
    if(check(mid) >= M){
      left=mid;
    }else{
      right=mid;
    }
  }

  
  if(check(left)>=M)return left;
  else return -1;
}

int main(){
  while(cin>>N>>M){
    if(N==0&&M==0)break;
    for(int i=0;i<N;i++)cin>>s[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3448
n = int(input())

points = []

for i in range(n) :
    point = list(map(int, input().split(" ")))
    points.append(point)

z = []
w = []

for i in range(len(points)) :
    z.append(points[i][0] + points[i][1])

for i in range(len(points)) :
    w.append(points[i][0] - points[i][1])

max_z = max(z) - min(z)
max_w = max(w) - min(w)

if max_z > max_w :
    print(max_z)
else :
    print(max_w)


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  
  int num;
  for (int i=0 ; i<K ; i++){
    if (A >= B){
      num = i+1;
      B *= 2;
    }
    else{
      num = i;
      break;
    }
  }
  for (int i=0 ; i<K-num ; i++)
    C *= 2;
  
  if (A < B && B < C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,x;cin>>n>>m>>x;
    vector<int> cost(n);
    vector<vector<int> > v(n,vector<int> (m));
    for(int i=0;i<n;i++){
        cin>>cost[i];
        for(int j=0;j<m;j++)cin>>v[i][j];
    }
    int ans=1e9;
    for(int i=0;i<(1<<n);i++){
        vector<int> temp(m,0);
        int cur=0;
        for(int j=0;j<n;j++){
            if((1<<j)&i){
                cur+=cost[j];
                for(int k=0;k<m;k++)temp[k]+=v[j][k];
            }
        }
        bool ok=1;
        for(int j=0;j<m;j++)if(temp[j]<x)ok=0;
        if(ok)ans=min(ans,cur);

    }
    if(ans==1e9){cout<<-1;return 0;}
    cout<<ans;
    
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
constexpr ll mod=998244353 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    ll n,m;
    cin>>n>>m;
    mod_build(3000000);
    ll ok=comb(n-1+3*m,3*m),ng=comb(n-1+m-1,m-1);
    REP(i,m+1,n+1){
        int s = 3*m-i, t = m-i;
        if(s%2==0)ok += mod-comb(n,i)*comb(n+s/2-1,n-1)%mod;
        if(t%2==0){
            ng+=mod-comb(n-1,i-1)*comb(n+t/2-1,n-1)%mod;
            ng+=mod-comb(n-1,i)*comb(n+t/2-2,n-1)%mod;
        }
    }
    ok%=mod;
    ng%=mod;
    ng=ng*n%mod;
    cout<<(ok-ng+mod)%mod<<endl;
    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


ll solve(int N,int C,vvi& D, vvi& c) {
    // [mod][colors] = cnt
    vvi st(3, vi(C, 0));
    rep(i,N)rep(j,N){
        int mod = (i+j)%3;
        int color = c[i][j]-1;
        ++st[mod][color];
    }
    ll best = 0x7fffffffffffffffLL;
    rep(i,C) rep(j,C) rep(k,C){ //27000
        if (i==j || j==k || k==i) continue;
        ll score = 0;
        rep(from,C){
            score += st[0][from] * D[from][i];
            score += st[1][from] * D[from][j];
            score += st[2][from] * D[from][k];
        }
        // printf("(%d %d %d) score=%lld\n", i,j,k, score);
        best = min(best, score);
    }
    return best;
}

int main() {
    int N,C; cin >>N>>C;
    vvi D(C,vi(C));
    rep(i,C) {
        rep(j,C) cin >> D[i][j];
    }
    vvi c(N,vi(N));
    rep(i,N){
        rep(j,N) cin >> c[i][j];
    }
    cout << solve(N,C,D,c) << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	for (int z=0;z<s.size();z++){
		ll k = s[z]+n;
		if (s[z]+n > 90) k -= 26;
		s[z] = char(k);
	}
	cout << s << endl;
}
 

Measured memory_bytes: 256
fun main (args: Array<String>) {
  val (a, b, c) = (1..3).map { readLine()!! }.map(String::toMutableList)
  var card = a.removeAt(0)
  while (true) {
    when (card) {
      'a' -> {
        if (a.isEmpty()) {
          println('A')
          return
        }
        card = a.removeAt(0)
      }
      'b' -> {
        if (b.isEmpty()) {
          println('B')
          return
        }
        card = b.removeAt(0)
      }
      'c' -> {
        if (c.isEmpty()) {
          println('C')
          return
        }
        card = c.removeAt(0)
      }
    }
  }
}

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

using namespace std;

int main()
{
  long long H, W;
  cin >> H >> W;
  long long ans = 0;
  if(H == 1 || W == 1){
    ans = 1;
  }else if(H % 2 == 0 && W % 2 == 0){
    ans += (W / 2) * H;
  }else if(H % 2 == 0 && W % 2 == 1){
    ans += (H / 2) * (W / 2);
    ans += (H / 2) * (W / 2 + 1);
  }else if(H % 2 == 1 && W % 2 == 0){
    ans += (W / 2) * (H / 2);
    ans += (W / 2) * (H / 2 + 1);
  }else if(H % 2 == 1 && W % 2 == 1){
    ans += (W / 2 + 1) * (H / 2 + 1);
    ans += (H / 2) * (W / 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    size_t N;
    std::cin >> N;

    std::vector<uint32_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        uint32_t t;
        std::cin >> t;
        A.push_back(t);
    }

    size_t l, r;
    l = r = 0;
    uint32_t sum = 0;
    size_t count = 0;

    while (l < N) {
        while (r < N) {
            // cerr << l+1 << " " << r+1;
            if ((sum ^ A[r]) != (sum | A[r])) {
                // むり
                //cerr << endl;
                break;
            }
            else {
                // cerr << " ++" << endl;
                sum ^= A[r];
                r++;
            }
        }
        count += r - l;
        sum ^= A[l];
        l++;
    }

    std::cout << count << std::endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int c[n];

	int r_cnt = 0;
	int w_cnt = 0;

	rep (i, n) {
		char C;
		cin >> C;
		if (C == 'R') {
			c[i] = 1;
			r_cnt++;
		} else {
			c[i] = 0;
			w_cnt++;
		}
	}

	if ((w_cnt == 0) || (r_cnt == 0)) {
		cout << 0 << endl;
		return 0;
	}

    int d[n];
    memcpy(d, c, sizeof(c));
    sort(d, d+n, greater<>());
    int cnt = 0;
    rep (i, n) {
        if(c[i] != d[i]) cnt++;
    }

//    int a = w_cnt - r_cnt;
//    if (a < 0) a *= -1;
//    if (w_cnt > r_cnt) {
//        cnt -= r_cnt;
//    } else {
//        cnt -= w_cnt;
//    }

//    int g=0;
//    if (cnt/2) g++; 

	cout << cnt/2 << endl;

	return 0;
}


Measured memory_bytes: 5188
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<int> v( N );
	rep( i, N ) cin >> v[i];

	sort( ALL( v ), []( int a, int b ) { return ( a > b ); } );

	int alice = 0, bob = 0;
	rep( i, N )
	{
		if ( i % 2 ) bob += v[i];
		else alice += v[i];
	}

	cout << ( alice - bob ) << endl;

	return ( 0 );
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    SCIN(s,t);
    sort(all(s));
    sort(all(t),greater<char>());
    printf(s<t?"Yes":"No");
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){

	int height,width,max,count,limit,tmp_count;

	int** table = new int*[10];
	int** tmp = new int*[10];

	for(int i=0; i < 10; i++){
		table[i] = new int[10000];
		tmp[i] = new int[10000];
	}

	while(true){
		scanf("%d %d",&height,&width);
		if(height == 0 && width == 0)break;

		for(int i = 0; i < height; i++){
			for(int k=0; k < width; k++){
				scanf("%d",&table[i][k]);
			}
		}

		limit = pow(2,height);

		max = 0;

		for(int i = 0; i < limit; i++){

			for(int k = 0; k < height; k++){
				if((i & (1 << k))){
					for(int p = 0; p < width; p++){
						tmp[k][p] = 1 - table[k][p];
					}
				}else{
					for(int p = 0; p < width; p++){
						tmp[k][p] = table[k][p];
					}
				}
			}
			count = 0;

			for(int k = 0; k < width; k++){
				tmp_count = 0;
				for(int p = 0; p < height; p++){
					if(tmp[p][k] == 0)tmp_count++;
				}
				if(tmp_count > height-tmp_count){
					count += tmp_count;
				}else{
					count += height-tmp_count;
				}
			}
			max = (max >= count)?max:count;
		}

		printf("%d\n",max);

	}


    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int cnt[550][550];
int main() {
	int n,k;
  cin>>n>>k;
  if(n%k==0){
    cout<<0;
  }else{
    cout<<1;
  }
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n,a,b,i;
    int suma=0,sumb=0;

    while(scanf("%d",&n)&&n!=0){
suma=0;
sumb=0;
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        a>b?(suma+=a+b):a<b?(sumb+=a+b):(suma+=a,sumb+=b);
    }
    printf("%d %d\n",suma,sumb);
}
    return 0;
}

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

int n;
int a[100000];
int A[100000];

//set<int>s;
/*
void dfs(int d){
	if(d==n){
		for(int i=0;i<n;i++){
			cout<<A[i]<<' ';
		}
		cout<<endl;
		exit(0);
	}
	else{
		int x=(*s.begin());
		s.erase(x);
		int st = x;
		while(1){
			A[d] = x;
			if(!d || (d && a[A[d-1]-1]!=A[d])){
				dfs(d+1);
			}
			if((int)s.size()==0){
				s.insert(A[d]);
				return;
			}
			x = (*s.begin());
			s.erase(x);
			s.insert(A[d]);

			if(x==st)break;
		}
	}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(i+1);
	}
	dfs(0);
	cout<<-1<<endl;
}
*/

int main(){
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i]>>a[i];
	}
	string t;
	cin>>t;
	int sum=0 , flag=0;
	for(int i=0;i<n;i++){
		if(flag)sum+=a[i];
		if(t==s[i])flag=1;
	}
	cout<<sum<<endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

int memo[100001];

void solve(long long N, long long K, long long Q, std::vector<long long> A){
    REP(i, Q) {
        memo[A[i]-1]++;
    }

    REP(i, N) {
        cout << (K - Q + memo[i] > 0 ? YES : NO) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int n;
    int ans;
    int i;
    int num;
    scanf("%d",&n);
    for(ans=1;;ans++)
    {
        num=0;
        for(i=1;i<=ans;i++)
        {
            if(ans%i==0) num++;
            if(num>n) break;
        }
        if(num==n) break;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int n;
  cin >> n;
  int t[n];
  int sum=0;
  rep(i,0,n){
    cin >> t[i];
    sum += t[i];
  }
  int m;
  cin >> m;
  rep(i,0,m){
    int p,x;
    cin >> p >> x;
    p--;
    int ans = sum;
    ans = ans - t[p] + x;
    P(ans);
  }
  

  ret 0;
}

Measured memory_bytes: 256
s=input()
ans=50
for i in "qwertyuiopasdfghjklzxcvbnm":
    t=0
    a=0
    for c in s:
        if(i==c):
            a=max(a,t)
            t=0
        else:
            t+=1
    a=max(a,t)
    ans=min(ans,a)
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <set>

int main(int argc, char *argv[]) {
  int n, m;
  std::cin >> n;
  std::set<int> a, b;
  int x;
  for (int i = 0; i < n; ++i) {
    std::cin >> x;
    a.insert(x);
  }
  std::cin >> m;
  for (int i = 0; i < m; ++i) {
    std::cin >> x;
    b.insert(x);
  }

  std::set<int> res;
  std::set_difference(a.begin(), a.end(), b.begin(), b.end(),
                 std::inserter(res, res.end()));
  for (auto &v : res)
    std::cout << v << std::endl;
}



Measured memory_bytes: 31208
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val record = List.fill(4)(List.fill(3)(Array.fill(10)(0)))

    val n = scanner.nextInt
    for(_ <- 1 to n) {
      val b, f, r, v = scanner.nextInt
      record(b - 1)(f - 1)(r - 1) = record(b - 1)(f - 1)(r - 1) + v
    }

    var first = true
    for(b <- record) {
      if(!first) {
        println("#" * 20)
      }
      first = false

      for(f <- b) {
        println(" " + f.mkString(" "))
      }
    }
  }
}


Measured memory_bytes: 47336
# coding: utf-8
import heapq
n, m = map(int, input().split())
jobs = [[] for i in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    jobs[m-a].append(b)
ans = 0
l = []
for i in range(m-1, -1, -1):
    for j in jobs[i]:
        heapq.heappush(l, -j)
    if len(l):
        ans += -heapq.heappop(l)
print(ans)

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

int main() {
  int N,M;
  vector<string> blue, red;
  
  cin >> N;
  for(int i=1;i<=N;i++){
    string s;
    cin >> s;
    blue.push_back(s);
  }
  
  cin >> M;
  for(int j=1;j<=M;j++){
    string s;
    cin >> s;
    red.push_back(s);
  }
  
  vector<string> words = blue;
  sort(words.begin(), words.end());
  words.erase(unique(words.begin(), words.end()), words.end());

  int ans = 0;
  
  for(int k=0;k<words.size();k++){
    int ans_temp = 0;
    for(int l=0;l<N;l++){
      if(blue.at(l)==words.at(k)){
        ans_temp++;
      }
    }
    for(int m=0;m<M;m++){
      if(red.at(m)==words.at(k)){
        ans_temp--;
      }
    }
    if(ans<ans_temp){
      ans = ans_temp;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

bool red_sort(const pair<int, int>&f, const pair<int, int>&s)
{
	return f.second > s.second;
}

bool blue_sort(const pair<int, int>&f, const pair<int, int>&s)
{
	return f.first < s.first;
}

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

	int n;
	cin >> n;
	vector<pair<int, int>> red, blue;
	for(int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		red.push_back(pair<int, int>(a, b));
	}
	for(int i = 0; i < n; i++)
	{
		int c, d;
		cin >> c >> d;
		blue.push_back(pair<int, int>(c, d));
	}
	int ret = 0;
	sort(red.begin(), red.end(), red_sort);
	sort(blue.begin(), blue.end(), blue_sort);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < (int)red.size(); j++)
		{
			if(blue[i].first > red[j].first&&blue[i].second > red[j].second)
			{
				red.erase(red.begin() + j);
				ret++;
				break;
			}
		}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
gets
a = gets.chomp.split.map(&:to_i)
n = 0

for i in 0..a.size-1
  for j in (a.size-1).downto(i+1)
    if a[j-1] > a[j]
    a[j-1],a[j] = a[j],a[j-1]
    n += 1
    end
  end
end

puts a*" "
puts n

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

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


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

const int MAX_N = 100;

int N;
int arr[MAX_N+1];
vector<int> ans;

int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; i++){
		scanf("%d", &arr[i]);
	}
	while(N>0){
		bool tf = false;
		for(int i=N; i>=1; i--){
			if(i==arr[i]){
				tf = true;
				ans.pb(i);
				for(int j=i; j<N; j++){
					arr[j] = arr[j+1];
				}
				break;
			}
		}
		if(!tf){
			printf("-1");
			return 0;
		}
		arr[N] = 0;
		N--;
	}
	while(!ans.empty()){
		printf("%d\n", ans.back());
		ans.pop_back();
	}
	return 0;
}


Measured memory_bytes: 256