akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
/*istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}*/
const ll INF=1e9+7;

ll n;

vector<ll> que;

ll u[3]={7,5,3};

void dfs(ll t,ll bit){
    if(bit==7) que.push_back(t);
    string s=to_string(t);
    if(s.length()==10) return;
    rep(i,3){
        dfs(t*10+u[i],bit | (1<<i));
    }
    return;
}

int main()
{
    
    cin >> n;
    dfs(0,0);
    sort(que.begin(),que.end());
    ll ans=0;
    ll i=0;
    while(true){
        if(que[i]<=n){
            ans++;
            i++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 1400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <limits>
#include <iomanip>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AMaximizeTheFormula {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,b,c;in>>a>>b>>c;
	    out<<max({a,b,c})*9+a+b+c<<endl;

	}
};


int main() {
	AMaximizeTheFormula solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int cnt=0;
	string s;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s.substr(i,1)=="1"){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const ll oo = 1e18L+7;

int abso(ll a) {
    if(a < 0) return -a;
    return a;
}

vector<ll> h, dp;
int n;

int main() {
    
    scanf("%d",&n);
    h.resize(n+1);
    
    for(int i = 1; i <= n; ++i) {
        scanf("%lld",&h[i]);
    }
    
    dp.assign(n+1, oo);
    dp[1] = 0;
    
    for(int i = 1; i <= n; ++i) {
        for(int j = i+1; j <= i+2 && j <= n; ++j) {
            dp[j] = min(dp[j], dp[i]+abso(h[i]-h[j]));
        }
    }

    printf("%lld\n", dp[n]);
    
    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll n;
ll a[ARRS];
ll s[ARRS];
ll p=0;
vector<ll> v[ARRS];
set<ll> st;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	for(int i=1; i<=n; i++)
		s[i]=s[i-1]+a[i];
	st.insert(-MAX);
	st.insert(MAX);
	st.insert(2*s[1]);
	for(int i=2; i<=n-2; i++){
		ll k=s[i];
		auto it=st.lower_bound(k);
		ll t=*it;
		--it;
		if(abs(t-k)>abs(k-(*it)))
			t=*it;
		v[i].pb(t/2);
		v[i].pb(k-t/2);
		st.insert(2*k);
	}
	reverse(a+1,a+n+1);
	for(int i=1; i<=n; i++)
		s[i]=s[i-1]+a[i];

	st.clear();
	st.insert(-MAX);
	st.insert(MAX);
	st.insert(2*s[1]);
	for(int i=2; i<=n-2; i++){
		ll k=s[i];
		auto it=st.lower_bound(k);
		ll t=*it;
		--it;
		if(abs(t-k)>abs(k-(*it)))
			t=*it;
		v[n-i].pb(t/2);
		v[n-i].pb(k-t/2);
		st.insert(2*k);
	}
	ll pas=MAX;
	for(int i=2; i<=n-2; i++){
		//cout<<i<<endl;
		//for(auto x:v[i]){
			//cout<<x<<" ";
		//}
		//cout<<endl;
		sort(v[i].begin(),v[i].end());
		pas=min(pas,v[i][3]-v[i][0]);
	}
	cout<<pas;
}


Measured memory_bytes: 55936
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, k;

char s[100010];
int LRs, RLs;

int main()
{
	scanf("%d%d\n", &n, &k);
	scanf("%s", s);
	
	int total = 0;
	int curSection = 0;
	char lastCh = s[0];
	for (int i = 1 ; i < n ; i++)
	{
		if ((s[i - 1] == 'L') && (s[i] == 'R'))
			LRs++;
		else if ((s[i - 1] == 'R') && (s[i] == 'L'))
			RLs++;
			
		if (lastCh == s[i])
		{
			curSection++;
			total++;
		}
		else
		{
//			total = total + curSection;
			curSection = 0;
		}
		
		lastCh = s[i];
	}
	
	int aSec, bSec;
	if (LRs > RLs)
	{
		aSec = LRs;
		bSec = RLs;
	}
	else
	{
		aSec = RLs;
		bSec = LRs;
	}
	
	if (k <= bSec)
	{
		total = total + k * 2;
		bSec = bSec - k;
		aSec = aSec - k;
		k = 0;
	}
	else
	{
		total = total + bSec * 2;
		k = k - bSec;
		aSec = aSec - bSec;
		bSec = 0;
		
		if (aSec > 0)
			total++;
	}
	
	printf("%d\n", total);
	
		
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a = 0, b = 0;
  char s[10];
  cin >> s;
  s[0] == 'A' ? a++ : b++;
  s[1] == 'A' ? a++ : b++;
  s[2] == 'A' ? a++ : b++;
  if ( a > 0 && b > 0 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(void){
  cin >> s;
  lli a=0, b=0;
  lli n = s.size();
  for(lli i = 0; i < n; i++){
    if(s[i] == 'B'){
      a+=n-1-i;
      b++;
    }
  }
  cout << a-b*(b-1)/2 << endl;
  return 0;
}


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

def solve(A: int, B: int, H: int, M: int):
    minRad = M/60*2*math.pi
    hourRad = (60*H+M)/(60*12)*2*math.pi
    minCoord = (B*math.cos(minRad),B*math.sin(minRad))
    hourCoord = (A*math.cos(hourRad),A*math.sin(hourRad))
    print(math.sqrt((minCoord[0]-hourCoord[0])**2+(minCoord[1]-hourCoord[1])**2))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62528
#include<stdio.h>
int main(){
  int l,r,n,n2,i,S[1000000],T,mid,count;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&T);
    l=0;
    r=n;
    while(l<r){
      mid=(l+r)/2;
      if(S[mid]==T){
	count++;
      break;
      }else if(S[mid]<T){
	l=mid+1;
      }else if(S[mid]>T){
	r=mid;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int a = Integer.parseInt(line1[0]);
        int b = Integer.parseInt(line1[1]);
        String line2 = sc.nextLine();
        char[] line3 = line2.toCharArray();
        
        char c = line2.charAt(b - 1);
        c += 32;
        line3[b - 1] = c;
        for(char c1 : line3) {
            System.out.print(c1);
        }
    }
}

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

int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    int c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] !=t[i]){
            c++;
        }
    } 
    cout << c << endl;
}


Measured memory_bytes: 3912
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int A[100][100];
int d[100],p[100],color[100],mincost;
void prim(int);
int goukei(int);
int main() {
	int i,j,n,a;
	scanf("%d",&n);
	for (i = 0; i < n;i++) {
		for (j = 0; j < n;j++) {
			scanf("%d", &a);
			if (a == -1) {
				A[i][j] = 2001;
			}
			else {
				A[i][j] = a;
			}
		}
	}
	prim(n);
	printf("%d\n",goukei(n));
	return 0;

}
void prim(int n) {
	int i,v,u;
	for (i = 0; i < n;i++) {
		color[i] = WHITE;
		d[i] = 2001;
	}
	d[0] = 0;
	p[0] = -1;

	while (1) {
		mincost = 2001;
		for (i = 0; i < n;i++) {
			if (color[i] != BLACK && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == 2001) {
			//printf("%d\n",u);
			break;
		}
		color[u] = BLACK;

		for (v = 0; v < n;v++) {
			if (color[v] != BLACK && A[u][v] < 2001) {
				if (A[u][v] < d[v]) {
					d[v] = A[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
}
int goukei(int n) {
	int i,sum= 0;
	for (i = 0; i < n;i++) {
		sum += d[i];
	}
	return sum;
}


Measured memory_bytes: 2032
class SegmentTree:
    def __init__(self, array, seg_func, ide_ele):
        n = len(array)
        self.size = 2**(n - 1).bit_length()
        self.seg_func = seg_func
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele] * (2 * self.size - 1)

        for i in range(n):
            self.seg[i + self.size - 1] = array[i]
        for i in range(self.size - 2, -1, -1):
            self.seg[i] = self.seg_func(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, index, sbn):
        index += self.size - 1
        self.seg[index] += sbn
        while index:
            index = (index - 1) // 2
            self.seg[index] = self.seg_func(self.seg[index * 2 + 1], self.seg[index * 2 + 2])

    def query(self, lower_ep, upper_ep):
        if upper_ep <= lower_ep:
            return self.ide_ele
        lower_ep += self.size - 1
        upper_ep += self.size - 2
        res = self.ide_ele
        while (upper_ep - lower_ep) > 1:
            if lower_ep & 1 == 0:
                res = self.seg_func(res, self.seg[lower_ep])
            if upper_ep & 1 == 1:
                res = self.seg_func(res, self.seg[upper_ep])
                upper_ep -= 1

            lower_ep //= 2
            upper_ep = (upper_ep - 1) // 2
        if lower_ep == upper_ep:
            res = self.seg_func(res, self.seg[lower_ep])
        else:
            res = self.seg_func(self.seg_func(res, self.seg[lower_ep]), self.seg[upper_ep])
        return res


def add(a, b):
    return a + b


n, q = map(int, input().split())
seg = SegmentTree([0] * n, add, 0)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        seg.update(x - 1, y)
    else:
        print(seg.query(x - 1, y))



Measured memory_bytes: 10736
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int ans = 0;
        int outlet = 1;
        while(outlet < b)
        {
            outlet--;
            outlet += a;
            ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
import math


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


X = int(input())


def factors(A):
    a = []
    for i in range(1, A + 1):
        if A % i == 0:
            a.append(i)
    return a


f = (factors(X))

if(len(f) != 2):
    while (len(f) != 2):
        X += 1
        f = factors(X)
    print(X)
else:
    print(X)



Measured memory_bytes: 3064
#include<algorithm>
#include<cstdio>
#define mxn 1000010
using namespace std;
const int mod=1e9+7;
int n,sl,fh,s[mxn],siz[mxn],g[mxn],f[5010][5010];
int t,h[mxn];
struct Tre
{
	int to,nxt;
}e[mxn<<1];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void add(int u,int v)
{
	e[++t]=(Tre){v,h[u]};h[u]=t;
	e[++t]=(Tre){u,h[v]};h[v]=t;
}
void dfs(int u,int fa)
{
	int v;siz[u]=1;f[u][1]=1;
	for(int i=h[u];i;i=e[i].nxt)
		if((v=e[i].to)!=fa)
		{
			dfs(v,u);
			for(int i=1;i<=siz[u]+siz[v];++i) g[i]=0;
			for(int j=1;j<=siz[u];++j)
				for(int k=0;k<=siz[v];++k)
					g[j+k]=(g[j+k]+1ll*f[u][j]*f[v][k])%mod;
			siz[u]+=siz[v];
			for(int i=1;i<=siz[u];++i) f[u][i]=g[i];
		}
	for(int i=2;i<=siz[u];i+=2) f[u][0]=(f[u][0]+1ll*s[i]*f[u][i])%mod;
	f[u][0]=mod-f[u][0];
}
int main()
{
	n=rd();int x,y;s[0]=1;
	for(int i=1;i<n;++i) x=rd(),y=rd(),add(x,y);
	for(int i=2;i<=n;i+=2) s[i]=1ll*(i-1)*s[i-2]%mod;
	dfs(1,0);
	printf("%d\n",mod-f[1][0]);
	return 0;
}

Measured memory_bytes: 107136
import sys
import math

def solve(n, k):
    ans = 0.
    rate = 1./n
    for i in xrange(n):
        if i + 1 >= k:
            ans += rate
        else:
            ans += rate * 0.5 ** math.ceil(math.log(k/(i+1), 2))

    return ans

if __name__ == '__main__':

    n, k = sys.stdin.readline().strip().split(" ")
    print solve(int(n), float(k))

Measured memory_bytes: 2568
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,r;
    cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }
    else{
        cout << r+100*(10-n) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s;
  int ans=0;
  rep(i,n){
    cin>>s;
    if(s=="E869120") ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<algorithm>
#define NC 5

using namespace std;

int C[ NC ];

bool isStraight(){
    for ( int i = 2; i < 5; i++ ){
	if ( C[i-1] != C[i] - 1 ) return false;
    }
    if ( C[4] == 13 ) return ( C[0] == 1 ) ? true : false;
    return ( C[0] == C[1] - 1 ) ? true : false;
}

bool isFourC(){
    for ( int i = 2; i < 4; i++ ) if ( C[i-1] != C[i] ) return false;
    return ( C[0] == C[1] || C[3] == C[4] );
}

bool isFullHouse(){
    if ( C[0] == C[1] && C[2] == C[3] && C[3] == C[4] ||
	 C[0] == C[1] && C[1] == C[2] && C[3] == C[4] ) return true;
    else return false;
}

bool isThreeC(){
    if ( C[0] == C[1] && C[1] == C[2] ||
	 C[1] == C[2] && C[2] == C[3] ||
	 C[2] == C[3] && C[3] == C[4] ) return true;
    else return false;
}

bool isPair(int pair){
    int sum = 0;
    for ( int i = 1; i < 5; i++ ) if ( C[i-1] == C[i] ) sum++;
    return sum == pair; // one pair ツつゥ two pair 
}

string judge(){
    sort( C, C + NC );

    if ( isStraight() ) return "straight";
    else if ( isFourC() ) return "four card";
    else if ( isFullHouse() ) return "full house";
    else if ( isThreeC() ) return "three card";
    else if ( isPair(2) ) return "two pair";
    else if ( isPair(1) ) return "one pair";
    else return "null";
}

bool read(){
    char comma;
    if ( !(cin >> C[0]) ) return false;
    for ( int i = 1; i < NC; i++ ){
	cin >> comma >> C[i];
    }
    return true;
}

int main(){
    while ( read() ){
	cout << judge() << endl;
    }
    return 0;
}

Measured memory_bytes: 0
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,q,a,sum,num[maxn],b,c;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	while(n--){
		cin>>a;
		num[a]++;
		sum+=a;
	}
	cin>>q;
	while(q--){
		cin>>b>>c;
		sum+=c*num[b];
		sum-=b*num[b];
		num[c]+=num[b];
		num[b]=0;
		cout<<sum<<endl;
	}	
}


Measured memory_bytes: 4428
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<int, int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int H, W, M; cin >> H >> W >> M;
    vector<int> y(H, 0), x(W, 0);

    set<P> st;

    for(int i = 0; i < M; i++)
    {
        int h, w; cin >> h >> w;
        h--, w--;
        y[h]++;
        x[w]++;
        st.insert(P(h, w));
    }

    priority_queue<P> py, px;
    for(int i = 0; i < H; i++) py.push(P(y[i], i));
    for(int i = 0; i < W; i++) px.push(P(x[i], i));

    int ans = 0;

    P target_h = py.top();

    for(int i = 0; i < W; i++)
    {
        int cnt = target_h.first + x[i];
        if(st.count(P(target_h.second, i))) cnt--;
        ans = max(ans, cnt);
    }

    P target_w = px.top();

    for(int i = 0; i < H; i++)
    {
        int cnt = target_w.first + y[i];
        if(st.count(P(i, target_w.second))) cnt--;
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 28020
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <string>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ull N;
    cin >> N;
    vector<ull> count(5U, 0);
    for (auto &&i: irange(0U, (uint)N)) {
        string s;
        cin >> s;
        char c;
        c = s.at(0);
        if (c == 'M') {
            count.at(0)++;
        }else if (c == 'A'){
            count.at(1)++;
        }else if (c=='R'){
            count.at(2)++;
        }else if (c=='C'){
            count.at(3)++;
        }else if(c=='H'){
            count.at(4)++;
        }
    }
    ull c0 = count.at(0);
    ull c1 = count.at(1);
    ull c2 = count.at(2);
    ull c3 = count.at(3);
    ull c4 = count.at(4);
    cout << c0 * c1 * c2 + c0 * c1 * c3 + c0 * c1 * c4 + c0 * c2 * c3 + c0 * c2 * c4 + c0 * c3 * c4 + c1*  c2 * c3 + c1* c2 * c4 + c1* c3* c4 + c2* c3 * c4;


    return 0;
}

Measured memory_bytes: 256
text = input()
count = int(input())

for c in range(count):
    args = input().split()
    (a, b) = [int(x) for x in args[1:3]]
    if args[0] == 'print':
        print(text[a:b + 1])
    elif args[0] == 'reverse':
        text = text[0:a] + text[a:b + 1][::-1] + text[b + 1:]
    elif args[0] == 'replace':
        text = text[0:a] + args[3] + text[b + 1:]

Measured memory_bytes: 6724
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#include <algorithm>
#define reg register
using namespace std;
const int MaxN=200001;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[MaxN],b[MaxN];
signed main(void)
{
	int n;rd(n);
	for(int i=1;i<=n;++i)
		rd(a[i]),b[i]=a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
	{
		if(b[i]==a[n])
			printf("%d\n",a[n-1]);
		else
			printf("%d\n",a[n]);
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

constexpr int MAX = 252;

class Union_Find {
  public:
    int par[MAX], rank[MAX], gnum;
    
    Union_Find(int N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
        }
        gnum = N;
    }

    int find(int x)
    {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return;
        
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        gnum--;
    }

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

struct edge {
    int u, v, cost, col;
    edge() {}
    edge(int u, int v, int cost, int col) :
        u{u}, v{v}, cost{cost}, col{col} {}

    bool operator < (const edge& e) const {        
        if (cost != e.cost) {
            return cost < e.cost;
        }
        return col > e.col;
    }
};

int N, M, K;

void add_cost(int x, vector<edge>& es)
{
    for (auto& e : es) {
        if (e.col == 0) {
            e.cost += x;
        }
    }
}

pair<int, int> kruskal(int x, vector<edge> es)
{
    add_cost(x, es);
    sort(es.begin(), es.end());    
    
    Union_Find uf(N);
    int res = 0, k = 0;    
    for (const auto& e : es) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);     
            res += e.cost;
            k += (e.col == 0);
        }
    }
    return make_pair(res, k);
}

bool unconnected(const vector<edge>& es)
{
    Union_Find uf(N);
    for (const auto& e : es) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
        }
    }
    return (uf.gnum != 1);
}

void solve(const vector<edge>& es)
{
    constexpr int INF = 252521;    
    int l = -INF, r = INF;

    if (unconnected(es)) {
        cout << -1 << endl;
        return;
    }
    
    while (r - l > 1) {
        int mid = (l + r) / 2;            
        auto mst = kruskal(mid, es);

        if (mst.second < K) {
            r = mid;
        } else {
            l = mid;
        }
    }

    auto ll = kruskal(l, es);
    auto rr = kruskal(r, es);

    if (rr.second <= K && K <= ll.second) {
        cout << rr.first - r * K << endl;
    } else {
        cout << -1 << endl;
    }
}

int main()
{
    while (cin >> N >> M >> K, N) {
        vector<edge> es;
        for (int i = 0; i < M; i++) {
            int u, v, w;
            char l;
            cin >> u >> v >> w >> l;
            u--; v--;
            es.emplace_back(u, v, w, l - 'A');
        }
        solve(es);       
    }
    return 0;
}

Measured memory_bytes: 3144
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const int MN = 1e5 + 1;

int N, M, V, P;
int A[MN], B[MN];

bool check(int p) {
    for(int i = 0; i < N; i++) B[i] = A[i];

    ll total_points = (ll)M * V;
    auto give = [&](int i, int amount) {
        ll v = min(total_points, (ll)min(amount, M - (B[i] - A[i])));
        B[i] += v;
        total_points -= v;
    };
    give(p, M);
    int free = P - 1;
    for(int i = N-1; i >= 0 && free > 0; i--) {
        if(i == p) continue;
        give(i, M);
        free--;
    }
    for (int i = 0; i < N; i++) {
        if (i == p) continue;
        give(i, max(0, B[p] - B[i]));
    }
    if (total_points > 0) return false;
    int larger_count = 0;
    for(int i = 0; i < N; i++) {
        if (B[i] > B[p]) larger_count++;
    }
    return larger_count < P;
}

int main() {
    scanf("%d%d%d%d", &N, &M, &V, &P);
    for(int i = 0; i < N; i++)  scanf("%d", &A[i]);
    sort(A, A+N);
    int left = 0, right = N-1, mid, ans;
    while(left <= right) {
        mid = (left + right) / 2;
        if (check(mid)) {
            ans = mid;
            right = mid - 1;
        }
        else {
            left = mid + 1;
        }
    }

    printf("%d\n", N - ans);
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N, K, S;
    cin >> N >> K >> S;

    int rem = (int) 1e9;
    
    if(S == rem)
        rem = 1;

    for(int i=1; i<=N; i++)
        cout << (i <= K ? S : rem) << "\n";
    
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
using namespace std;
int mori[1001][1001]={0},umi[1001][1001]={0},hokkyoku[1001][1001]={0};
int main(){
int i,j,n,m,w,a,b,c,d,k;
char s[2001];
cin>>m>>n>>k;
for(i=1;i<=m;i++){
scanf("%s",s);
for(j=1;j<=n;j++){
if(s[j-1]=='J')mori[i][j]++;
if(s[j-1]=='O')umi[i][j]++;
if(s[j-1]=='I')hokkyoku[i][j]++;
mori[i][j]=mori[i][j]+mori[i-1][j]+(mori[i][j-1]-mori[i-1][j-1]);
umi[i][j]=umi[i][j]+umi[i-1][j]+(umi[i][j-1]-umi[i-1][j-1]);
hokkyoku[i][j]=hokkyoku[i][j]+hokkyoku[i-1][j]+(hokkyoku[i][j-1]-hokkyoku[i-1][j-1]);
}
}
/*cout<<"mori"<<endl;
for(i=1;i<=m;i++){
for(j=1;j<=n;j++)cout<<mori[i][j]<<' ';
cout<<endl;
}
cout<<"umi"<<endl;
for(i=1;i<=m;i++){
for(j=1;j<=n;j++)cout<<umi[i][j]<<' ';
cout<<endl;
}
cout<<"hokkyoku"<<endl;
for(i=1;i<=m;i++){
for(j=1;j<=n;j++)cout<<hokkyoku[i][j]<<' ';
cout<<endl;
}
*/
for(i=0;i<k;i++){
cin>>a>>b>>c>>d;
printf("%d %d %d\n",mori[c][d]-mori[a-1][d]-(mori[c][b-1]-mori[a-1][b-1]),umi[c][d]-umi[a-1][d]-(umi[c][b-1]-umi[a-1][b-1]),hokkyoku[c][d]-hokkyoku[a-1][d]-(hokkyoku[c][b-1]-hokkyoku[a-1][b-1]));
}
return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int A,B;
    Scd2(A,B);
    int H,M;
    Scd2(H,M);

    double da = PI/6*H+PI/360*M;
    double db = PI/30*M;

    double dc = abs( da-db );

    if( dc > PI ) dc = PI*2 - dc;


    double ans2 = 1.0*A*A + 1.0*B*B - 2.0*A*B*cos(dc);

    printf ("%.9lf\n", sqrt(ans2) );

    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define F(n) for(int i = 0; i < n; ++i)
#define Debug cout<<endl<<"I AM IRONMAN"<<endl

int main ()
{
    fastio;
    string a;
    cin >> a;
    int p1=0,p2=0;
    for(int i=0;i<a.length();i++)
    {
        if(i%2==0 && a[i]=='0')
        {
            p1++;
        }
        if(i%2==1 && a[i]=='1')
        {
            p1++;
        }
        
    }
    for(int i=0;i<a.length();i++)
    {
        if(i%2==0 && a[i]=='1')
        {
            p2++;
        }
        if(i%2==1 && a[i]=='0')
        {
            p2++;
        }
        
    }
    cout << min(p1,p2);
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	long long Q,H,S,D,N,ans;
	scanf("%lld %lld %lld %lld %lld",&Q,&H,&S,&D,&N);
	ans=(N%2==0)?(min(min(min(Q*8,H*4),S*2),D)*N/2):(min(min(Q*4,H*2),S)+min(min(min(Q*8,H*4),S*2),D)*(N-1)/2);
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
/************************************************************
	> File Name: b.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 22 Dec 2019 10:09:41 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
string s,t,res = "";
int main(void){
	IOS;
	int n;
	cin >> n;
	cin >> s >> t;
	int i = 0,j = 0;
	while(i < n && j < n){
		res += s[i++];
		res += t[j++];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int pt[100],pn[101];
int main(){
	int a,b;
	char z;
	int top=0;
	while(true){
		cin>>a>>z>>b;
		if(a==0&&b==0)
			break;
		pn[a]=b;
		bool t=true;
		for(int i=0;i<top;i++)
			if(pt[i]==b)t=false;
		if(t==true){
			pt[top]=b;
			top++;
		}
	}
	sort(pt,pt+top);
	int c;
	while(cin>>c){
		int ans=0;
		while(true){
			if(pt[ans]==pn[c])
				break;
			ans++;
		}
		cout<<top-ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
 
int main(){
    int n_max = 55555;
    vector<bool> prime(n_max,true);
    prime[0] = prime[1] = false;
    rep(i,n_max)if(prime[i]){
        for(int j = 2; j*i < n_max; j++){
            prime[i*j] = false;
        }
    }
    int n;
    cin >> n;
    vector<int> ans;
    rep(i,n_max){
        if(prime[i] && i%5==1){
            ans.push_back(i);
            if(ans.size() == n)break;
        }
    }
    rep(i,n){
        cout << ans[i];
        if(i < n-1)cout << " ";
        else cout << endl;
    }
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

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

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

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    int mi = INF,ma = SUP;
    rep(i,n){
        cin >> a[i];
        mins(mi,a[i]);
        maxs(ma,a[i]);
    }
    int ans = INF;
    FOR(i,mi,ma+1){
        int tmp = 0;
        rep(j,n){
            tmp += pow(a[j]-i,2);
        }
        mins(ans,tmp);
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
x = int(input())
dp = [0]*(x+106)
dp[0] = 1
for i in range(0, x+1):
    if dp[i] == 1:
        dp[i+100] = 1
        dp[i+101] = 1
        dp[i+102] = 1
        dp[i+103] = 1
        dp[i+104] = 1
        dp[i+105] = 1
print(dp[x])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    int cnt = 0;
    int ans = 0;
    for(int i=N-1; i>0; --i){
        if(H[i]<=H[i-1]){
            cnt++;
            ans = max(ans, cnt);
        }
        else cnt = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
	ll n;
	ld m;
	cin>>n>>m;
	ll M = m;
	m = 0.25 / m;
	vector<ll> a(n);
	for(int i=0; i<n; i++) cin>>a[i];
	ll sum = accumulate(a.begin(),a.end(),0);
	sort(a.rbegin(),a.rend());
	int cnt=0;
	bool found = true;
	for(int i=0; i<n; i++)
	{
		if(a[i]*1.0 >= m*sum)
			cnt++;
	}
	if(cnt < M)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	return 0;
}

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

using namespace std;

int main(){
    
    int x,a,b,n;
    string s;
    
    cin >> x >> a >> b >> n;
    while(n--){
        cin >> s;
        if(s == "nobiro"){
            x = max(0,x+a);
        }
        if(s == "tidime"){
            x = max(0,x+b);
        }
        if(s == "karero"){
            x = 0;
        }
    }
    cout << x << endl;
    return(0);
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main(int argc, char** argv){
  int x1, x2, y1, y2;
  
  while(cin >> x1 >> y1 >> x2 >> y2) {
    int difx = x2 - x1, dify = y2 - y1;
    int x3 = x2 - dify, y3 = y2 + difx;
    int x4 = x1 - dify, y4 = y1 + difx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
loop do
    a, op, b = gets.split
    a = a.to_i
    b = b.to_i
    if op == "?" then
        break
    end
    case op
    when "+"
        ans = a + b
    when "-"
        ans = a - b
    when "*"
        ans = a * b
    when "/"
        ans = a / b
    end
    puts ans
end




Measured memory_bytes: 6876
# 素因数分解の関数　
def prime_factorize(n):
    result = []
    # 偶数時の処理
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    # ここまでのresultの出力結果[(2, 3)]
    # 偶数で破れなかった奇数の処理
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        # 残例題の場合3が残る
        while n % i == 0:
            n //= i
            t += 1
        # 例1の場合(3,1)
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    # result出力結果[(2, 3), (3, 1)]
    return result


N = int(input())
# 偶数が2回奇数が1回処理される
result = 0
for p, e in prime_factorize(N):
    i = 1
    while e >= i:
        result += 1
        e -= i
        i += 1
print(result)

Measured memory_bytes: 9444
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    map<string,int> mp;
    int a[n];
    rep(i,0,n){
        string s;cin>>s;
        cin>>a[i];
        mp[s]=i;
    }
    string t;cin>>t;
    int r=mp[t];
    ll ans=0;
    rep(i,r+1,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, K;
	cin >> N >> K;
	if (N % K == 0) {
		cout << 0;
	}
	else {
		cout << 1;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0<=z<=2000 and x*10000+y*5000+z*1000 == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 998244353;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, S; cin >> n >> S;
    vector<LL> dp(S + 1, 0);
    dp[0] = 1;
    for (int i = 0 ; i < n ; i++) {
        int v; cin >> v;
        for (int j = S; j >= 0 ; j--) {
            (dp[j] *= 2) %= MOD;
            if (j - v >= 0)
                (dp[j] += dp[j - v]) %= MOD;
        }
    }
    cout << dp.back() << '\n';
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <iostream>

using namespace std;

#define SIZE 300

class point
{
public:
	int n;
	int d[SIZE * 2 + 1];
	int minw;
};

#define SIZE2 (200000 / SIZE + 10)

point m[SIZE2];

int p[200000];

int N;

void atu()
{
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		for(int ii = 0; ii < m[i].n; ii++)
		{
			p[now] = m[i].d[ii];
			now++;
		}
	}
}

int getm(int x,int a,int b)
{
	int w = 2000000000;
	for(int i = a; i <= b; i++)
	{
		w = min(w,m[x].d[i]);
	}
	return w;
}

void bun()
{
	for(int i = 0; i < SIZE2; i++)
	{
		m[i].n = 0;
	}
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		for(int ii = 0; ii < SIZE; ii++)
		{
			if(now >= N)
			{
				m[i].n = ii;
				goto aa;
			}
			m[i].d[ii] = p[now];
			now++;
			m[i].n++;
		}
	}
aa:
	for(int i = 0; i < SIZE2; i++)
	{
		m[i].minw = getm(i,0,m[i].n - 1);
	}
}

pair<int,int> findw(int a)
{
	int now = 0;
	for(int i = 0; i < SIZE2; i++)
	{
		if(now + m[i].n > a)
		{
			return make_pair(i,a - now);
		}
		now += m[i].n;
	}
}

void insert(int a,int x)
{
	pair<int,int> w = findw(a);
	for(int i = m[w.first].n; i > w.second; i--)
	{
		m[w.first].d[i] = m[w.first].d[i - 1];
	}
	m[w.first].d[w.second] = x;
	m[w.first].n++;
	if(m[w.first].n > SIZE * 2 + 1)
	{
		atu();
		bun();
	}
	else
	{
		m[w.first].minw = getm(w.first,0,m[w.first].n - 1);
	}
}

int erase(int a)
{
	pair<int,int> ww = findw(a);
	int w = m[ww.first].d[ww.second];
	for(int i = ww.second; i < m[ww.first].n - 1; i++)
	{
		m[ww.first].d[i] = m[ww.first].d[i + 1];
	}
	m[ww.first].n--;
	m[ww.first].minw = getm(ww.first,0,m[ww.first].n - 1);
	return w;
}

void shift(int a,int b)
{
	int w = erase(b);
	insert(a,w);
}

int minw(int a,int b)
{
	pair<int,int> aw = findw(a);
	pair<int,int> bw = findw(b);
	int w;
	if(aw.first == bw.first)
	{
		w = getm(aw.first,aw.second,bw.second);
	}
	else
	{
		w = min(getm(aw.first,aw.second,m[aw.first].n - 1),getm(bw.first,0,bw.second));
		for(int i = aw.first + 1; i < bw.first; i++)
		{
			w = min(w,m[i].minw);
		}
	}
	return w;
}

void oki(int a,int x)
{
	pair<int,int> w = findw(a);
	m[w.first].d[w.second] = x;
	m[w.first].minw = getm(w.first,0,m[w.first].n - 1);
}

int main()
{
	int q;
	scanf("%d%d",&N,&q);
	for(int i = 0; i < N; i++)
	{
		int w;
		scanf("%d",&w);
		p[i] = w;
	}
	bun();
	for(int i = 0; i < q; i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(a == 0)
		{
			shift(b,c);
		}
		else if(a == 1)
		{
			printf("%d\n",minw(b,c));
		}
		else
		{
			oki(b,c);
		}
	}
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
char s[20];
int main() {
	scanf("%s",s);
	if (strlen(s)<4)
		printf("No\n");
	else if (s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    for ( int j = N - 1; j >= i; j-- ) {
      if ( A[j].value < A[j - 1].value ) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

// ????????????????????¨?????????????????????????????????
bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,pre[100000],x;
string s;
map<string,int> v;

signed main(){
	read(n);
	for(int i=1;i<=n;i++) cin>>s,pre[i]=pre[i-1]+read(x),v[s]=pre[i];
	cin>>s;
	write(pre[n]-v[s]);
}

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

int main(){
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0 && w==0)break;
        
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if((i%2==0 && j%2==0) || (i%2==1 && j%2==1)) cout<<'#';
                else cout<<'.';
            }
            cout<<'\n';
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3084
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if a[i] + a[i+1] > x:
        sa = a[i] + a[i+1]
        if a[i+1] >= sa - x:
            a[i+1] -= sa - x

        else:
            a[i] = x - a[i+1]
            a[i+1] = 0
        ans += sa - x
print(ans)


Measured memory_bytes: 63984
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] point = new int[N+1];
		for( int i=0; i<Q; i++ ){
			point[sc.nextInt()]++;
		}
		for( int i=1; i<=N; i++ ){
			System.out.println( point[i]>Q-K ? "Yes" : "No" );
		}
	}
}


Measured memory_bytes: 55600
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
a = []
3.times do
  a.push gets.chomp.split.map(&:to_i)
end

n = gets.chomp.to_i

n.times do
  num = gets.chomp.to_i
  3.times do |i|
    3.times do |j|
      if a[i][j] == num
        a[i][j] = -1
      end
    end
  end
end

3.times do |i|
  if a[i].all?{|e|e == -1}
    puts 'Yes'
    exit
  end
end

3.times do |i|
  if a.all?{|e|e[i] == -1}
    puts 'Yes'
    exit
  end
end

if a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1
    puts 'Yes'
    exit
end

if a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1
    puts 'Yes'
    exit
end

puts 'No'


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

void solve(string X){
	stack<char> S;
	S.push('$');
	for(int i = 0; i < X.size(); ++i) {
		if(X[i] == 'T' && S.top() == 'S') {
			S.pop();
		} else {
			S.push(X[i]);
		}
	}
	cout << S.size() - 1 << endl;
}

int main(){	
	string X;
	cin >> X;
	solve(X);
	return 0;
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a < b){
    if(c > a && c < b){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(c > b && c < a){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256