akhauriyash/Code-Regression huggingface dataset:
//package atcoder;
import java.util.*;
import java.lang.String;
public class Main {

	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String[] arr=new String[n];
		int[][] a=new int[n][2];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.next();
			a[i][0]=sc.nextInt();
			a[i][1]=i;
			
			
			
		}
		for(int i=0;i<n;i++)
		{
			int Min=i;
			for(int j=i;j<n;j++)
			{
				if(arr[Min].compareTo(arr[j])>0)
				{
					Min=j;
				}
				else if(arr[Min].compareTo(arr[j])==0)
				{
					if(a[Min][0]<a[j][0])
					{
						Min=j;
					}
					else
					{
						continue;
					}
				}
				else
				{
					continue;
					
				}
			}
			String temp1=arr[i];
			arr[i]=arr[Min];
			arr[Min]=temp1;
			int temp2=a[i][0];
			int temp3=a[i][1];
			a[i][0]=a[Min][0];
			a[i][1]=a[Min][1];
			a[Min][0]=temp2;
			a[Min][1]=temp3;
			
			
		}
		for(int i=0;i<n;i++)
		{
			System.out.println(a[i][1]+1);
		}
		
	

	}

}


Measured memory_bytes: 21716
#include <stdio.h>          // printf(), scanf()
#define MAX_N 250

int parent(int i) { return i / 2; }
int left(int i)   { return 2 * i; }
int right(int i)  { return 2 * i + 1; }

int
main(int argc, char** argv)
{
	int a[MAX_N + 1];
	int h;
	int i;

	scanf("%d", &h);
	for (i = 1; i <= h; ++i)
		scanf("%d", &a[i]);

	for (i = 1; i <= h; ++i)
	{
		printf("node %d: key = %d, ", i, a[i]);
		if (parent(i) >= 1)
			printf("parent key = %d, ", a[parent(i)]);

		if (left(i) <= h)
			printf("left key = %d, ", a[left(i)]);

		if (right(i) <= h)
			printf("right key = %d, ", a[right(i)]);

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int counter = 0;
        String s = sc.next();
        String t = sc.next();

         for(int i = 0; i < 3; ++i){
            if(s.charAt(i) == t.charAt(i)) ++counter;     
         }
        
         System.out.println(counter);
    }
}

Measured memory_bytes: 23124
M,D=(int(x) for x in input().split())
count=0
for d in range(1,D+1):
  for m in range(1,M+1):
    if (d%10)>=2 and int(d//10)>=2:
    	if m==(d%10)*int(d//10):
      		count+=1
print(count)      

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    static int n;
    static long[] sumA;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sumA = new long[n+1];
        sumA[0] = sc.nextInt();
        for (int i = 1; i < n; i++) {
            sumA[i] = sumA[i-1] + sc.nextInt();
        }
        long ans = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            ans = Math.min(ans, Math.abs(sumA[i] - (sumA[n-1] - sumA[i])));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 65476
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
int main()
{
    ll N;
    cin >> N;
    
    ll ans = INF;
    for(ll i = 1; i*i <= N;i++)
    {
        if( N%i != 0 ) continue;
        else
        {
            //cout << i << " " << N/i << endl;
            ll tmp = max(to_string(N/i).size(),to_string(i).size());
            if( ans > tmp ) ans = tmp;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n, m, c;
  cin >> n >> m >> c;

  vector<int> b(m + 1);
  for (int i = 1; i <= m; i++) cin >> b[i];

  vector<vector<int>> a(n + 1, vector<int>(m + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }

  int ans = 0;

  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = 1; j <= m; j++) sum += a[i][j] * b[j];
    if (sum + c > 0) ans++;
  }

  cout << ans << endl;
}

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

#define cmp(a1,b1,c1,a2,b2,c2) (a1<a2||(a1==a2&&b1<b2)||(a1==a2&&b1==b2&&c1<=c2))

inline void output(int y,int m,int d){
	if(cmp(1989,1,8,y,m,d)){
		cout << "heisei ";
		cout << y-1989+1 << " " << m << " " << d << endl;
	}else if(cmp(1926,12,25,y,m,d)){
		cout << "showa ";
		cout << y-1926+1 << " " << m << " " << d << endl;
	}else if(cmp(1912,7,30,y,m,d)){
		cout << "taisho ";
		cout << y-1912+1 << " " << m << " " << d << endl;
	}else if(cmp(1868,9,8,y,m,d)){
		cout << "meiji ";
		cout << y-1868+1 << " " << m << " " << d << endl;
	}else{
		cout << "pre-meiji" << endl;
	}
	return ;
}

int main(void){
	int y,m,d;
	while(cin >> y >> m >> d){
		if(cin.eof()) break;
		output(y,m,d);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll; 

using namespace std;

int main(void)
{
    ll N, M, a;
    vector<ll> X , Xdiff;
    cin >> N >> M;
    for(int i = 0; i < M; ++i){
        cin >> a;
        X.push_back(a);
    }
    sort(X.begin(), X.end(), std::greater<ll>());
    for(int i = 0; i < M - 1; ++i){
        Xdiff.push_back(X[i] - X[i + 1]);
    }
    int ans = 0;
    if(M > 1){
        sort(Xdiff.begin(), Xdiff.end(), std::greater<int>());
        for(int i = N - 1; i < M - 1; ++i){
            ans += Xdiff[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[rune]bool, 26)
	r := 'a'
	for _, v := range s {
		m[v] = true
	}
	for {
		if m[r] == false {
			fmt.Println(string(r))
			break
		}
		if r == 'z' {
			fmt.Println("None")
			break
		}
		r++
	}
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long N = in.nextLong();
		long A = in.nextLong();
		long B = in.nextLong();
		if ((B - A) % 2 == 0) {
			System.out.println((B - A) / 2);
		} else {
			if ((A - 1) < (N - B)) {
				long diff = A - 1 + 1;
				System.out.println(diff + (B - diff) / 2);
			} else {
				long diff = N - B + 1;
				System.out.println(diff + ((N - (A + diff)) / 2));
			}
		}
		in.close();
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    bitset<10001> b(1);
    for (int i = 0, j; i < n; i++)
    {
        scanf("%d", &j);
        b |= b << j;
    }
    for (int i = 10000; i >= 0; i--)
    {
        if (i % 10 && b.test(i))
        {
            printf("%d\n", i);
            return 0;
        }
    }
    printf("0\n");
    return 0;
}


Measured memory_bytes: 256
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    int n,l; scanf("%d %d", &n, &l);
    int res = n*(l-1) + n*(1+n)/2;
    if((1-l) < 1 || n < (1-l)){
        int reta = l+1-1;
        int retb = l+n-1;
        if(abs(reta) <= abs(retb)){
            res -= reta;
        } else {
            res -= retb;
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
aaa = list(map(int,input().split()))

def hantei(n,aaa):
	dp = [0]*(n+1)
	dp[0] = 0
	dp[1] = abs(aaa[1]-aaa[0])
	for i in range(n-2):
		dp[i+2] = min(dp[i+1]+abs(aaa[i+2]-aaa[i+1]),dp[i]+abs(aaa[i+2]-aaa[i]))
	return dp[n-1]

print(hantei(n,aaa))

Measured memory_bytes: 13980
{
  const main = (input: string) => {
    const r = reader(input)
    const [a, b] = r.ns()

    const prise = n => {
      if (n === 1) {
        return 300000
      } else if (n === 2) {
        return 200000
      } else if (n === 3) {
        return 100000
      }
      return 0
    }
    const res = prise(a) + prise(b)

    console.log(res === 600000 ? 1000000 : res)
  }

  // const values = obj => Object.keys(obj).map(e => obj[e]);

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const line = s
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    return { lines, line, s, n, ss, ns }
  }

  main(require('fs').readFileSync('/dev/stdin', 'utf8'))
}


Measured memory_bytes: 7500
from math import sqrt, ceil

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

    up_b = ceil(sqrt(N))

    min_a = 10 ** 10
    for b in range(up_b):
        if N % (b+1) == 0:
            min_a = min(max(N/(b+1), b+1), min_a)
            min_a = int(min_a)
    
    print(len(str(min_a)))
        
main()

    

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[10],b[10],check[10];
int mult(int x){
	int ans=1;
	for(register int i=1;i<=x;i++)ans*=i;
	return ans;
}
int main(){
	n=read();
	int ans1=0,ans2=0;
	for(register int i=1;i<=n;i++){
		a[i]=read();
		int num=0;
		for(register int j=1;j<a[i];j++)if(!check[j])num++;
		check[a[i]]=1;
		ans1+=mult(n-i)*num;
	}
	memset(check,0,sizeof(check));
	for(register int i=1;i<=n;i++){
		b[i]=read();
		int num=0;
		for(register int j=1;j<b[i];j++)if(!check[j])num++;
		check[b[i]]=1;
		ans2+=mult(n-i)*num;
	}
	printf("%d\n",abs(ans1-ans2));
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()
ans = 0
hq = []
idx = 0
for i in range(1, m+1):
    for j in range(idx, n):
        if ab[j][0] == i:
            heappush(hq, (-ab[j][1], ab[j][0]))
            idx += 1
        else:
            break
    if len(hq) != 0:
        ans -= heappop(hq)[0]
    
print(ans)


Measured memory_bytes: 38124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    string ans=s+t[t.size()-1];
    if(ans==t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,ans;
char s[100005];
int main()
{
    n=read();reg int i;
    scanf("%s",s+1);ans=1;
    for(i=2;i<=n;++i)
        if(s[i]!=s[i-1])ans++;
    cout<<ans<<"\n";
	return 0;
}


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

int w[101],v[101];
long long f[100005];

int main()
{
	int N,W;
	scanf("%d%d",&N,&W);
	for(int i=1;i<=N;++i)
	scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=N;++i)
	for(int j=W;j>=w[i];--j)
	{
		if(f[j]<f[j-w[i]]+v[i])f[j]=f[j-w[i]]+v[i];
	}
	for(int j=W;j>=0;--j)
	if(f[j]){
		printf("%lld",f[j]);
		break;
	} 
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for(int i = 0; i < b; i++)
#define repr(i, b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n; cin >> n;
    if(n >= 30) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3656
import math

N = int(input())
ms = []

def solve(N):
    result = 0
    ms = [] 
    for m in range(1, N):
        d, r = divmod(N, m)
        if d == r:
            result += m
            ms.append(m)

    return result, ms

def solve1(N):
    s = 0
    ms = [] 
    for m in range(1, int(math.sqrt(N)+1)):
        d, r = divmod(N, m)
        if r == 0:
            if d < m-1:
                s += m - 1
                ms.append(m-1)
            else:
                s += d - 1
                ms.append(d-1)
    return s, ms

s = 0
cs = set()
for m in range(1, int(math.sqrt(N)+1)):
    q, r = divmod(N, m)
    if r != 0:
        continue
    cs.add(q-1)
    cs.add(m-1)

def check(c):
    if c == 0:
        return 0
    return c if N // c == N % c else 0
        
s = sum(check(c) for c in cs)
print(s) 


Measured memory_bytes: 3828
#include<bits/stdc++.h> 
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=2e5+5;
int n; char s[N]; ll ans;
int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1,j=1;i<=n;i++)
		if (s[i]=='W'){
			ans+=i-j;
			j++;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    # N = 2*(10**4)
    # K = 10**18
    # A = [i+2 for i in range(N)]
    # A[-1] = 1
    # print(A)

    visited = [0]
    visited_set = set([0])
    now = 0
    ind = 0
    my_append = visited.append
    my_add = visited_set.add
    for i in range(K):
        a = A[now]-1
        if a in visited_set:
            ind = visited.index(a)
            break
        else:
            my_add(a)
            my_append(a)
            now = a
            # ind = i

    loop_visited = visited[ind:]
    ans_ind = (K-ind) % len(loop_visited)

    print(loop_visited[ans_ind]+1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 114888
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	ll N;
	cin >> N;
	ll a[N + 100];
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
		a[i]-=(i+1);
	}
	sort(a,a+N);
	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		ans+=abs(a[i]-a[N/2]);
	}
	cout << ans;
}

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

int main() {
 int n;
  cin >>n ;
  double ans = 0;
 for(int i=0;i<n;i++){
   double x;
   string v;
   cin >>x >>v;
   if (v=="JPY")
     ans +=x;
   else 
     ans +=(x*380000.0);
 }
 printf("%.10lf\n", ans);
  
     
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a;
  for (int i=0; i<N; i++) {
    int num;
    cin >> num;
    a.push_back(num);
  }

int p = 0;
 for (int i=0; i<N; i++) {
    int j = a[i]-1;
    if (i < j && a[j]-1 == i) p++;
 }

cout << p << endl;
  return 0;
}

Measured memory_bytes: 892
def main():
    N = int(input())
    Cs = list(input())
    #print(Cs)
    r = Cs.count('R')
    w = Cs.count('W')
    lis = ['R']*r +['W']*w
    #print(lis)
    count=0
    for i in range(len(lis)):
        if Cs[i]!=lis[i]:
            count+=1
    

    return int(count/2) if count%2==0 else int(count/2+1) 

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 13644
#include<stdio.h>

int main()
{
    int a,b,c,x,i;
    scanf("%d %d %d",&a,&b,&c);
    for(x = a; x <= b; x++){
        if(c % x == 0){
        	i++;
        }
    }
    
    printf("%d\n",i);
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> > 

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=2e5+10, M=(ll)1e9+1 ;
const int mod = 998244353  ;

void work(){
 ll n;
 cin >> n;
 vll a(n);
 for(ll i=0;i<n;i++){
    ll u,v;
    cin >> u >> v;
    a[i]={u,v};
 }
 sort(a.begin(),a.end());
 ll ma=-1;
 map<pll,ll>m;
 for(ll i=0;i<n-1;i++){
   for(ll j=i+1;j<n;j++){
   ll dif1=a[i].first-a[j].first,dif2=a[i].second-a[j].second;
    m[{dif1,dif2}]++;
    ma=max(ma,m[{dif1,dif2}]);
   }
 }
 if(ma!=-1)
  cout << n-ma;
else
  cout << 1;
  
 return;
}
int main(){
 ios_base::sync_with_stdio(0);

    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}

Measured memory_bytes: 384
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
vector<string> s;
vector<ll>t;
ll n;
string x;

void input(){
    cin>>n;
    s.resize(n);
    t.resize(n);
    rep(i,n){
        cin>>s[i]>>t[i];
    }
    cin>>x;
}
void src(){
    int st=distance(s.begin() ,find(ALL(s),x));
    int sum=0;
    repi(i,st+1,n){
        sum+=t[i];
    }
    cout<<sum;
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        
        
        
        
        for (int i = 0; i < lines.length; i++){
            int num = Integer.parseInt(lines[i]);
            int zero = 0;
                if (num == zero){
                    continue;
                }
            System.out.println("Case " + (i + 1) + ": " + num);
        }
    }

  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

vector <ll> V[111];
ll K[111], D[111], Q[111];
ll n, f, r;
pll ans;

void bfs(ll p)
{
	ll i;
	pll ret;
	
	f = r = 0;
	
	for(i=1;i<=n;i++){
		K[i] = D[i] = 0;
	}
	
	Q[++f] = p;
	D[p] = 1;
	K[1] = V[p].size();
	
	for(;r<f;){
		p = Q[++r];
		for(auto t: V[p]){
			if(!D[t]){
				Q[++f] = t;
				D[t] = D[p] + 1;
				K[D[t]] = max(K[D[t]], (ll)V[t].size() - 1);
			}
		}
	}
	
	ret = pll(D[p], 1);
	
	for(i=1;i<ret.first;i++){
		ret.second *= K[i];
	}
	
	ans = min(ans, ret);
}

void bfs(ll p, ll q)
{
	ll i;
	pll ret;
	
	f = r = 0;
	
	for(i=1;i<=n;i++){
		K[i] = D[i] = 0;
	}
	
	Q[++f] = p, Q[++f] = q;
	D[p] = D[q] = 1;
	K[1] = max((ll)V[p].size(), (ll)V[q].size()) - 1;
	
	for(;r<f;){
		p = Q[++r];
		for(auto t: V[p]){
			if(!D[t]){
				Q[++f] = t;
				D[t] = D[p] + 1;
				K[D[t]] = max(K[D[t]], (ll)V[t].size() - 1);
			}
		}
	}
	
	ret = pll(D[p], 2);
	
	for(i=1;i<ret.first;i++){
		ret.second *= K[i];
	}
	
	ans = min(ans, ret);
}

int main()
{
	ll i, a, b;
	
	ans = pll(1e9, 0);
	
	scanf("%lld", &n);
	
	for(i=1;i<n;i++){
		scanf("%lld%lld", &a, &b);
		V[a].push_back(b);
		V[b].push_back(a);
	}
	
	for(i=1;i<=n;i++){
		bfs(i);
	}
	
	for(i=1;i<=n;i++){
		for(auto j: V[i]) bfs(i, j);
	}
	
	printf("%lld %lld\n", ans.first, ans.second);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,K,T,U,V,L;
	cin>>n>>K>>T>>U>>V>>L;
	vint v(L+1,0);
	rep(i,n){
		int t;
		cin>>t;
		v[t]++;
	}
	int cnt=0;
	int a=0;
	int b=0;
	int boost;
	bool f=false;
	reep(i,1,L+1){
		if(f) a++;
		else b++;
		// cout<<boost<<endl;
		if(boost==i){
			// cout<<i<<endl;
			f=false;
		}
		if(v[i]){
			if(f){
				if(cnt==K){
					boost=i+V*T;
				}
				else{
					cnt++;
				}
			}
			else{
				boost=i+V*T;
				f=true;
			}
		}
		else{
			if(!f&&cnt){
				cnt--;
				boost=i+V*T;
				f=true;
			}
		}
	}
	// cout<<a<<" "<<b<<endl;
	cout<<(double)b/U+(double)a/V<<endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(10);
    mainmain();
}

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

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

    int N; cin >> N;
    if(N % 2 == 0){
        printf("%.10f\n", 0.5);
        return 0;
    }
    
    double n = N;
    double res = ((n + 1) / 2) / n;
    
    printf("%.10f\n", res);
    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double

/* aとbの最大公約数を求める. */
ll gcd(ll a, ll b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

signed main() {
	ll a, b; cin >> a >> b;
	cout << (a * b / gcd(a, b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#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 <cmath>
using namespace std;

int main() {

    string s;
    cin >> s;
    if (s=="Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s== "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int a[100010];

int main () {
  int N; cin >> N;
  vi a(N); REP(i,N) cin >> a[i];

  map<int,int> mp;
  REP(i,N) mp[a[i]]++;

  int ans = 0;
  for (auto p : mp) {
    int x = p.FI;
    int n = p.SE;
    if (n < x) {
      ans += n;
    }
    else {
      ans += n-x;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#define foor for(int i=0;i<n;i++)
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define ic int a;cin>>a;
#define ic2 ic int b;cin>>b;
#define ic3 ic2 int c;cin>>c;
int s = 0;
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	ic2
		string o; cin >> o;
	if (s == o)a--;
	else b--;
	cout << a << " " << b << endl;
}

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

int main(){
    int N;
    scanf("%d",&N);
    char S[N+1];
    scanf("%s",S);
    int count = 0;
    int flag = 0;
    
    for(int s = 0;s<1000;s++){
        for(int i = 0;i<N;i++){
            if(flag == 0 && S[i]== (s/100+'0')){
                flag++;
                continue;
            }
            if(flag == 1 && S[i]== ((s/10)%10+'0')){
                flag++;
                continue;
            }
            if(flag == 2 && S[i] == (s%10+'0')){
                count++;
                break;
            }
        }
        flag = 0;
    }
    printf("%d\n",count);
    return 0;
}

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

int main() {

  long N,M;
  cin>>N;
  vector<long> t(N);
  for(int i=0;i<N;i++) cin>>t[i];
  cin>>M;
  vector<long> p(M);
  vector<long> x(M);

  for(int i=0;i<M;i++) cin>>p[i]>>x[i];

  long all=0;
  for(int i=0;i<N;i++) all+=t[i];

  for(int i=0;i<M;i++){
    long tmp= all-t[p[i]-1]+x[i];
    cout<<tmp<<endl;
  }

  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 200000+5
using namespace std;

ll f[MAX];

void pre()
{
	f[0]=1;
	rep(i,1,MAX)
	{
		f[i]=i*f[i-1];
		f[i]%=MOD;
	}
}

ll powmod(ll a,ll b,ll mod)
{
    ll x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%mod;
        }
        y = (y*y)%mod;
        b /= 2;
    }
    return x%mod;
}


ll ways(ii start, ii end)
{
	ll m=end.F-start.F;
	ll n=end.S-start.S;
	ll ret=f[m+n];
	ret*=powmod(f[m],MOD-2,MOD);
	ret%=MOD;
	ret*=powmod(f[n],MOD-2,MOD);
	ret%=MOD;
	return ret;
}

int main()
{
	pre();
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	ll ans=0;
	rep(i,1,h-a+1)
	{
		//printf("(%lld %lld)->(%lld %lld) , (%lld %lld)->(%lld %lld)\n",1ll,1ll,i,b,i,b+1,h,w);
		ll p=ways(mp(1,1),mp(i,b));
		p*=ways(mp(i,b+1),mp(h,w));
		p%=MOD;
		ans+=p;
		ans%=MOD;
	}
	prll(ans);	
	return 0;
}

Measured memory_bytes: 1792
n,k = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
a1 = Counter(a).most_common()
num = 0
if k < len(a1):
    for i in range(1,len(a1)-k+1):
        num += a1[-i][1]
    print(num)
else:
    print(0)

Measured memory_bytes: 42992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

const int INF = 1e10;
const int ZERO = 0;
int memo[100];
int lucas(int a) {
	if(a == 0) {
		return 2;
	}
	else if(a == 1) {
		return 1;
	}
	else if(memo[a] != 0) {
      	return memo[a];
    }
	memo[a] = lucas(a - 1) + lucas(a - 2);
}
signed main() {
	int N;
	cin >> N;
	cout << lucas(N) << endl;
}


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

int main(){
  int N; cin>>N;
  int cnt=0;
  rep(i,N){
    int a; cin>>a;
    while(a%2==0){
      a/=2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 384
from sys import setrecursionlimit
setrecursionlimit(2 * 10 ** 9)

N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

f_G = [[] for _ in range(N)]
for a, b in AB:
  a, b = a-1, b-1
  f_G[a].append(b)
  f_G[b].append(a)

b_G = [[] for _ in range(N)]
for c, d in CD:
  c, d = c-1, d-1
  b_G[c].append(d)
  b_G[d].append(c)

def dfs(v):
  if visited[v]:
    return
  visited[v] = True
  for nv in f_G[v]:
    s.add(nv)
    dfs(nv)  

ans = [0] * N
visited = [False] * N

for i in range(N):
  if not visited[i]:
    s = set()
    dfs(i)
    l = len(s)
    for u in s:
      ans[u] = l - 1
      ans[u] -= len(set(f_G[u]) & s)
      ans[u] -= len(set(b_G[u]) & s)

print(*ans)

Measured memory_bytes: 105076
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define endl "\n"
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/
bool check(string s)
{
    ll n=s.length();
    ll ans=0;
    if(n%2==0)
    {
        For(i,n/2)if(s[i]!=s[n-1-i])ans++;
    }
    else 
    {
        For(i,n/2)if(s[i]!=s[n-1-i])ans++;
    }
    if(ans)return false;
    else return true;
}
signed main()/*Check flow...question galat mat padhna */
{
    fast;   
    string s;
    cin>>s;
    ll n=s.length();
    string a,b;
    a=s.substr(0,n/2);
    b=s.substr(n/2+1,n/2);

    if(check(s)&&check(a)&&check(b))cout<<"Yes"<<endl;

    else cout<<"No"<<endl;
}      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

const int N = 2e3+3;
int n, x, y;
vector<int> g[N];
int dis[N][N];

void solve() {
    cin >> n >> x >> y;
    for(int i=1; i<n; i++) {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n; j++) {
            dis[i][j] = (i==j ? 0 : 1e9);
        }
    }
    for(int root = 1; root <= n; root++) {
        vector<bool> vis(n + 1, 0);
        queue<int> q;
        vis[root] = 1;
        q.push(root);
        int d = 0;
        while(!q.empty()) {
            int m = q.size();
            while(m--) {
                int t = q.front(); q.pop();
                dis[root][t] = d;
                for(int to : g[t]) {
                    if(vis[to]==0) {
                        q.push(to);
                        vis[to] = 1;
                    }
                }
            }
            d++;
        }
    }
    int cnt[n];
    memset(cnt, 0, sizeof cnt);
    for(int i=1; i<=n; i++) {
        for(int j=i+1; j<=n; j++) {
            cnt[dis[i][j]]++;
        }
    }
    for(int i=1; i<n; i++) {
        cout << cnt[i] << endl;
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int tt=1; tt<=T; tt++) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){ 
  int n, a, b;
  cin >> n >> a >> b;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    int now = i;
    while (now) {
      sum += now % 10;
      now /= 10;
    }
    if (a <= sum && sum <= b) res += i;
  }
  cout << res << endl;
  return 0;  
} 

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int N = 20;
int mp[N+1][N+1];

int main() {
  int n, m;
  while (1) {
    memset(mp, 0, sizeof(mp));
    scanf("%d ", &n);
    if (!n) break;
    int x, y;
    REP(i,n) {
      scanf("%d%d ", &x, &y);
      mp[x][y] = 1;
    }
    scanf("%d ", &m);
    int c = 0;
    x = 10, y = 10;
    REP(i,m) {
      char d;
      int dxy;
      scanf("%c%d ", &d, &dxy);
      REP(j,dxy) {
        if (d == 'N')
          y++;
        else if (d == 'E')
          x++;
        else if (d == 'W')
          x--;
        else 
          y--;
        if (mp[x][y]) {
          c++;
          mp[x][y] = 0;
        }
      }
    }
    puts(c==n ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3036
#include<stdio.h>
int main(void){
    int a,b,c,d,sum=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);

    if(a < b){
        sum += a;
    }else{
        sum += b;
    }
    if(c < d){
        sum += c;
    }else{
        sum +=d;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
//#define INF(1<<21)                                                            
int min(int,int);

static const int N=100;
int min(x,y){

  int min=0;

  if(x>y){
    min = y;
  }
  else{
    min = x;
  }

  return min;
}



int main(){
  int n, p[N+1], m[N+1][N+1],i,k,l,j;

  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1; i<=n; i++){
    m[i][i]=0;
  }
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j=i+l-1;
      m[i][j] = (1<<21);
      for(k=i; k<=j-1; k++){

        m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}

Measured memory_bytes: 636
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 1e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int arr[105], dp[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;

    for (int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    sort(arr + 1, arr + 1 + n);

    dp[0] = 0;
    for (int mov = 1; mov <= k; mov++){
        for (int i = 1; i <= n; i++){
            if (arr[i] > mov) break;

            if (dp[mov - arr[i]] == 0){
                dp[mov] = 1;
            }
        }
    }

    cout << ((dp[k] == 1) ? "First\n" : "Second\n");

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,m;
  cin >> n >> m;
  ll sum_time = 1900*m + 100*(n-m);
  ll ans = sum_time * (1<<m); //ACするまでに必要な回数の期待値 2^m
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,a,b,c,d,i,j;
string st;
int main()
{
	cin>>n>>a>>b>>c>>d>>st;st="#"+st+"#";
	for(i=a;i<max(c,d);i++){
		if(st[i]=='#'&&st[i+1]=='#'){
			puts("No");
			return 0;
		}
	}
	if(c>d){
		for(i=b;i<=d;i++){
			if(st[i]=='.'&&st[i-1]=='.'&&st[i+1]=='.'){
				puts("Yes");
				return 0;
			}
		}
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 772
command = list(input()) + ["*"]
x, y = map(int, input().split())

d = 0
move = 0
dx = []
dy = [abs(y)]

fst = True

fmove = 0

for c in command:
    if c == 'F':
        move += 1
    else:
        if fst:
            fmove = move
            fst = False
        else:
            if d % 2 == 0:
                dx.append(move)
            else:
                dy.append(move)
        move = 0
        d += 1

temp = -x + fmove
for x in sorted(dx, reverse=True):
    if temp < 0:
        temp += x
    else:
        temp -= x

adx = temp
temp = 0

for y in sorted(dy, reverse=True):
    if temp < 0:
        temp += y
    else:
        temp -= y
ady = temp

print("Yes" if adx == ady == 0 else "No")




Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>

using namespace std;

int N, S;

int f(int tar, int n, int m)
{
  if (tar < 0) {
    return 0;
  }
  if (n == 0) {
    if (tar == 0) {
      return 1;
    } else {
      return 0;
    }
  }
  if (tar < m) {
    return 0;
  }

  int s = 0;
  for (int i = m + 1; i <= 9; i++) {
    s += f(tar - i, n - 1, i);
  }
  return s;
}
  
void solve()
{
  printf("%d\n", f(S, N, -1));
}

int main()
{
  for (;;) {
    scanf("%d %d ", &N, &S);
    if (N == 0 && S == 0) {
      break;
    }
    solve();
  }
}

Measured memory_bytes: 0
import sys
import math


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    D, G = map(int, input().split())
    problems = [list(map(int, input().split())) for _ in range(D)]
    answer = INF
    for i in range(2 ** D):
        ans = 0
        point = 0
        for j in range(D):
            if (i >> j) & 1:
                point += problems[j][0] * 100 * (j + 1) + problems[j][1]
                ans += problems[j][0]
        j = D - 1

        while point < G and j >= 0:
            if not (i >> j) & 1:
                p = math.ceil((G - point) / (100 * (j + 1)))
                if problems[j][0] >= p:
                    point += p * 100 * (j + 1)
                    ans += p
                    j = 0
                else:
                    j = 0
            j -= 1
        if answer > ans and point >= G:
            answer = ans
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int M = 105;
#define mod   1000000007
int dp[N][M][2];
int n, m;
string num;
int d;
int add(long long a, long long b)
{
    return ((a % mod) + (b % mod)) % mod;
}
long long help(long long idx, long long sum, long long tight)
{
    if (idx == n)
        return sum == 0;
    if (dp[idx][sum][tight] != -1)
        return dp[idx][sum][tight];
    long long res = 0;
    int biggest;
    if (tight)
     biggest= (num[idx]-'0') ;
     else
        biggest=9;
    for (int i = 0; i <= biggest; i++)
    {
        int newtight = ((num[idx]-'0')== i) ? tight : 0;
        res = add(res,help(idx + 1, (sum + i) % d, newtight));
    }
    return dp[idx][sum][tight] = res;
}
void solve()
{
    memset(dp, -1, sizeof dp);
    cin >> num;
    cin >> d;
    n = num.size();
    cout << ((help(0, 0, 1) % mod - 1 % mod) + mod) % mod << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 9472
#include<stdio.h>

int main(){
  int n;
  long x=0,y=0,t[1000],a[1000],j;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%ld %ld",&t[i],&a[i]);
  x=t[0];
  y=a[0];
  for(int i=1;i<n;i++){
    if(x/t[i]>y/a[i])
      j=x/t[i];
    else
      j=y/a[i];
    if(x>j*t[i]||y>j*a[i])
      j++;
    x=t[i]*j;
    y=a[i]*j;
  }
  printf("%ld\n",x+y);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n, k, cnt=0;
    cin >> n >> k;
    vector<int>a(200001,0);
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    sort(a.rbegin(), a.rend());
    int ans = 0;
    for(int i=0; i<k; i++){
        ans += a[i];
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 4024