akhauriyash/Code-Regression huggingface dataset:
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int N = int.Parse(words[0]);
        int K = int.Parse(words[1]);

        double result = 0;
        for(int i = 1; i <= N; i++)
        {
            result += kakuritsu(i, K) / N;
        }

        Console.WriteLine(result);
    }

    static double kakuritsu(int N, int K)
    {
        double d = 1.0;
        while(N < K)
        {
            N *= 2;
            d /= 2.0;
        }

        return d;
    }
}

Measured memory_bytes: 11220
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

count = 0

for i in 0..A do
  for j in 0..B do
    for k in 0..C do
      if 500 * i + 100 * j + 50 * k == X then
        count += 1
      end
    end
  end
end

puts count


Measured memory_bytes: 1788
import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    change = [[int(i) for i in input().split()] for _ in range(M)]
    change.sort(key = itemgetter(1), reverse = True)

    ai = 0
    for i in range(M):
        cb, c = change[i]
        if ai >= N or c < A[ai]: break
        for _ in range(cb):
            if ai >= N: break
            if A[ai] <= c:
                A[ai] = c
                ai += 1
            else: break
    print(sum(A))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 27048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string p = Console.ReadLine();
            if((n+n).Contains(p))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }



        }
    }
}



Measured memory_bytes: 17904
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    if (K == 0) {
        println(N.toLong() * N)
        return
    }
    var ans = 0L
    for (b in K + 1..N) {
        val n = (N - b + 1) / b + 1
        val c = (N - (K + b * n) + 1).coerceAtLeast(0)
        ans += (b - K) * n + c
    }
    println(ans)
}

Measured memory_bytes: 36020
import sys
import math
import itertools

nums = list(map(int, list(input())))
k = int(input())

dp0 = [[0 for _ in range(3)] for _ in range(len(nums))]
dp1 = [[0 for _ in range(3)] for _ in range(len(nums))]

dp0[0][0] = nums[0] - 1
dp1[0][0] = 1

for i in range(1, len(nums)):
	if nums[i] > 0:
		dp0[i][0] = dp0[i - 1][0] + dp1[i - 1][0] + 9
		dp0[i][1] = dp0[i - 1][1] + dp1[i - 1][1] + dp0[i - 1][0] * 9 + dp1[i - 1][0] * (nums[i] - 1)
		dp0[i][2] = dp0[i - 1][2] + dp1[i - 1][2] + dp0[i - 1][1] * 9 + dp1[i - 1][1] * (nums[i] - 1)
		dp1[i][0] = 0
		dp1[i][1] = dp1[i - 1][0] 
		dp1[i][2] = dp1[i - 1][1]
	else:
		dp0[i][0] = dp0[i - 1][0] + 9
		dp0[i][1] = dp0[i - 1][1] + dp0[i - 1][0] * 9
		dp0[i][2] = dp0[i - 1][2] + dp0[i - 1][1] * 9
		dp1[i][0] = dp1[i - 1][0] 
		dp1[i][1] = dp1[i - 1][1] 
		dp1[i][2] = dp1[i - 1][2]


print(dp0[-1][k-1] + dp1[-1][k-1])

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/(b))
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

//Data Structure
struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int K;
    cin >> K;
    for(int i = 0;i < K;i++){
        cout << "ACL";
    }
    cout << endl;
    return;
}


Measured memory_bytes: 3640
n = gets.to_i
as = gets.chomp.split.map(&:to_i).sort
m = as[-1].to_f
r = -1
as.each do |a|
  if (m/2-a).abs < (m/2-r).abs
    r = a
  end
end
puts "#{m.to_i} #{r}"


Measured memory_bytes: 12216
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,m;
  cin>>n>>m;
  vector<llong> v1,v2,v3,v4,v5,v6,v7,v8;
  REP(i,n){
    llong x,y,z;
    cin>>x>>y>>z;
    v1.pb(x+y+z);
    v2.pb(x+y-z);
    v3.pb(x-y+z);
    v4.pb(x-y-z);
    v5.pb(-x+y+z);
    v6.pb(-x+y-z);
    v7.pb(-x-y+z);
    v8.pb(-x-y-z);
  }

  VSORT(v1);
  VSORT(v2);
  VSORT(v3);
  VSORT(v4);
  VSORT(v5);
  VSORT(v6);
  VSORT(v7);
  VSORT(v8);

  llong sum[8];
  REP(i,8){
    sum[i] = 0;
  }
  llong ans = 0;
  for(int i=n-1;i>n-1-m;i--){
    sum[0] += v1[i];
    sum[1] += v2[i];
    sum[2] += v3[i];
    sum[3] += v4[i];
    sum[4] += v5[i];
    sum[5] += v6[i];
    sum[6] += v7[i];
    sum[7] += v8[i];
  }
  REP(i,8){
    ans = max(sum[i],ans);
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	long long x, t;
	cin >> x >> t;
	if (t >= x)
	{
		cout << "0" << endl;
		return 0;
	}
	else
		cout << x-t << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define YES printf("YES\n")
#define NO printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e15;
const int M = (1e9)+7 ;
const int N = (1e6);  // check the limit, man
int main()
{
    int n,q,i;
    in2(n,q);
    string str;
    llin(str);
    n=str.size();
    vi v(n);
    rep(i,n-1)
    {
        if(str.substr(i,2)=="AC")
            v[i]=1;
    }
    lp(i,1,n)
        v[i]+=v[i-1];
    int l,r;
    while(q--)
    {
        in2(l,r);
        l--,r--;
        r--;
        i=v[r];
        if(l>0)
            i-=v[l-1];
        out(i);
    }
}






Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int N = 10, REM = 1e4 + 4;
int dp[N][REM];
int n, a[N], m, c[10] = {0,2,5,5,4,5,6,3,7,6};
void build_path(int i, int rem)
{
	if(i == m)
		return;
	int mx = dp[i+1][rem];
	if(rem>=c[a[i]]){
		if(mx<=dp[i][rem-c[a[i]]]+1){
			cout << a[i];
			build_path(i, rem-c[a[i]]);
	    }
	    else if(mx<=dp[i+1][rem-c[a[i]]]+1)
	    cout << a[i],build_path(i+1, rem-c[a[i]]);
		else
			build_path(i+1, rem);
		}
		else
			build_path(i+1, rem);
}
int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
		cin >> a[i];
	sort(a, a +m);
	reverse(a, a+m);

	for(int i = m; i>-1; i--){
		for(int rem = 0; rem<=n; ++rem){
			if(i==m){
				if(rem)
					dp[i][rem] = -1e9;
				continue;
			}
        dp[i][rem] = -1e9;
		if(rem>=c[a[i]])
			dp[i][rem] = max(1+dp[i][rem-c[a[i]]], 1+dp[i+1][rem-c[a[i]]]);
		dp[i][rem] = max(dp[i][rem], dp[i+1][rem]);
	//	cout << i << " " << rem << " " << dp[i][rem]<<endl;
		}

	}
	build_path(0, n);
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 200001;
int main()
{
  long long n,i,j=1,t,res=0;
  long long s[N_MAX];
  cin >> n;
  s[0]=0;
  for(i=0;i<n;i++){
    cin >> t;
    s[i+1]=s[i]+t;
  }
  sort(s,s+n+1);
  t=s[0];
  for(i=1;i<n+1;i++){
    if(s[i]==t){
      j++;
    } else {
      res+=j*(j-1)/2;
      j=1;
    }
    t=s[i];
  }
  res+=j*(j-1)/2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pii> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

int checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e5+5;
//vector<ll>Graph[maX],cost[maX];
map<ll,ll>check;
///check n=1;
///check corner case;

void solve()
{
   ll a,v,n,m,t;
   cin>>a>>v>>n>>m>>t;
   ll x=abs(n-a);
   //cout<<x<<endl;
   ll y=v*t;
   ll z=m*t;
   z+=x;
   if(y>=z)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
int main()
{
    ll test;
    test=1;
     //scanf("%lld",&test);
    while(test--)solve();
return 0;
}
/*
6 8
1 2 3
1 3 7
2 4 7
3 4 2
3 5 3
5 4 5
5 6 11
4 6 3
*/


Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()

def resolve():
    n, p = map(int, input().split())
    
    base = [list(map(int, input().split())) for _ in range(n)]
    dp = [[(i == j) + 0 for j in range(n)] for i in range(n)]
    while p:
        if p & 1:
            dp = [[sum(dp[i][k] * base[k][j] % MOD for k in range(n)) % MOD for j in range(n)] for i in range(n)]
        base = [[sum(base[i][k] * base[k][j] % MOD for k in range(n)) % MOD for j in range(n)] for i in range(n)]
        p >>= 1

    print(sum(dp[i][j] for i in range(n) for j in range(n)) % MOD)
resolve()

Measured memory_bytes: 49628
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<ll,ll>
using namespace std;
const int N=2e5+10,size=1<<20,mod=1000000007;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}


map<pi,int> s;
int n;
ll ans,a,b,p[N],x,y,z,cnt;

int main() {
	qr(n); p[0]=1; for(int i=1;i<=n;i++) p[i]=p[i-1]*2LL%mod;
	for(int i=1;i<=n;i++) {
		qr(x); qr(y);
		if(!x&&!y) {cnt++; continue;}
		if(!x) a++;
		else if(!y) b++;
		else {
			z=gcd(abs(x),abs(y));
			if((x<0)==(y<0)) x=abs(x)/z,y=abs(y)/z;
			else x=-abs(x)/z,y=abs(y)/z;
			s[mk(x,y)]++;
		}
	}
	ans=(p[a]+p[b]-1)%mod;
	for(auto i:s) {
		pi u=i.fi,t=u;
		swap(t.fi,t.se);
		if(t.se<0) t.se=-t.se;
		else t.fi=-t.fi;
		ll v=i.second;
		if(s.count(t)) {
			if(u.fi<0) ans=ans*(p[v]+p[s[t]]-1)%mod;
		}
		else ans=ans*p[v]%mod;
	}
	pr2((ans-1+mod+cnt)%mod);
	return 0;
}



Measured memory_bytes: 17512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

const int MAXN = 2005;
const int INF = (1 << 30) - 1;

struct Edge
{
	int to;
	int nxt;
}edge[MAXN << 1];

int n,m,id,ans;
int size[MAXN];
int depth[MAXN];
int first[MAXN];
int f[MAXN][MAXN];

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

void dfs(int u,int fa)
{
	size[u] = 1;
	depth[u] = 0;
	f[u][0] = 0;
	for (int i = first[u];i;i = edge[i].nxt)
	{
		int v = edge[i].to;
		if (v == fa)
			continue;
		dfs(v,u);
		size[u] += size[v];
		int predepth = depth[u];
		depth[u] = max(depth[u],depth[v] + 1);
		for (int j = min(m,depth[u]);j >= 0;j--)
		{
			int MIN = min(f[u][j] + size[v],(j ? f[v][j - 1] : size[v]) + size[u] - size[v] - 1);
			for (int k = 0;k <= min(m - 1,min(j - 1,depth[v]));k++)
				MIN = min(MIN,f[u][min(min(predepth,j),m - k - 1)] + f[v][k]);
			f[u][j] = MIN;
		}
	}
	for (int i = 1;i <= depth[u];i++)
		f[u][i] = min(f[u][i],f[u][i - 1]);
	ans = min(ans,f[u][min(depth[u],m)] + n - size[u]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int u,v,i = 1;i < n;i++)
	{
		cin >> u >> v;
		addE(u,v);
		addE(v,u);
	}
	for (int i = 1;i <= n;i++)
		for (int j = 0;j <= m;j++)
			f[i][j] = INF;
	ans = INF;
	dfs(1,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x;
    cin >> x;
    ll ans = 0;
    ll tmp = x / 500;
    ans += tmp * 1000;

    tmp = x % 500;
    tmp = tmp / 5;
    ans += tmp * 5;
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), s = 0, t = 0;
		while (N>=A) {
			boolean ok = true; s = 0;
			for (char ch : (""+N).toCharArray()) s+=Character.getNumericValue(ch);
			if (s>=A && s<=B) t+=N;
			N--;
		}
		System.out.println(t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 40100
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007

int pow(int a, int n, int mod) {
  int res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1)
      res = 1LL * res * a % mod;
    a = 1LL * a * a % mod;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  int i = 1;
  if (n & 1) {
    if (a[0] != 0) {
      cout << 0 << endl;
      return 0;
    }
    i = 2;
  }
  while (i < n) {
    if (a[i-1] != i || a[i] != i) {
      cout << 0 << endl;
      return 0;
    }
    i += 2;
  }
  cout << pow(2, n / 2, MOD) << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")

#include <iostream>
#include <queue>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void printVector(const std::vector<double>& vec) {
    for (double value : vec) {
		std::cout << value << " ";
    }
	std::cout << std::endl;
}

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

	ll n,k;
	std::cin >> n >> k;
	// std::vector<std::vector<int>> a;
	ll a[2][200002] = {0};
	std::vector<int> kiroku;
	for ( int i = 0 ; i < n ; i++ ) {
		std::cin >> a[0][i];
	}

	int now = 1;
	ll point = 0;
	bool flag = false;

	kiroku.push_back(now);
	for ( ll i = 0 ; i < k ; i++ ) {
		if(a[1][now-1] > 0) {
			point = i;
			flag = true;
			break;
		}
		a[1][now-1] = i;
		now = a[0][now-1];
		kiroku.push_back(now);
	}

	if(flag)
	{
		ll syuuki = point - a[1][now-1];
		int nokori = (k-point) % syuuki;
		std::cout << kiroku[a[1][now-1] + nokori] << '\n';
	}
	else {
		std::cout << now << '\n';
	}

	// for ( int i = 0 ; i < nokori ; i++ ) {
	// 	now = a[0][now-1];
	// }
	return 0;
}


Measured memory_bytes: 7396
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a+b==3)
        System.out.println("3");
        else if(a+b==4)
        System.out.println("2");
        else
        System.out.println("1");
    }
}

Measured memory_bytes: 22996
#include<stdio.h>

int main(void){

	char map[101][102];
	int access[101][102];
	int x,y;
	int muki;
	int h,w;
	int loopflag;
	int i,j;

	while(1){
		
		x=0,y=0;
		loopflag = 0;

		scanf("%d %d",&h,&w);
		if(h==0 && w==0)
			break;

		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
				access[i][j] = 0;

		for(i=0;i<h;i++){
			scanf("%s",map[i]);
		}

		while(map[y][x]!='.'){
			access[y][x] = 1;

			if(map[y][x] == '^'){
				if(access[y-1][x] == 1){
					loopflag = 1;
					break;
				}
				else
					y--;
			}
			else if(map[y][x] == '>'){
				if(access[y][x+1] == 1){
					loopflag = 1;
					break;
				}
				else
					x++;
			}
			else if(map[y][x] == 'v'){
				if(access[y+1][x] == 1){
					loopflag = 1;
					break;
				}
				else
					y++;
			}
			else if(map[y][x] == '<'){
				if(access[y][x-1] == 1){
					loopflag = 1;
					break;
				}
				else
					x--;
			}

		}

		if(loopflag == 1)
			puts("LOOP");
		else
			printf("%d %d\n",x,y);

	}


	return 0;
}

	

Measured memory_bytes: 664
import java.util.Arrays;
import java.util.Scanner;

//ICPC Ranking
public class Main{

	class R implements Comparable<R>{
		int id, correct, time, score;
		int[] penalty;
		int[] submit;
		boolean[] corrected;
		public R(int id) {
			this.id = id;
			corrected = new boolean[11];
			penalty = new int[11];
			submit = new int[11];
		}
		public void calc(){
			score = correct * 100000000 - time;
		}
		@Override
		public int compareTo(R r) {
			if (score != r.score) return r.score - score;
			return r.id-id;
		}
	}
	
	public void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int M = sc.nextInt(), T = sc.nextInt(), P = sc.nextInt(), R = sc.nextInt();
			if ((M|T|P|R)==0)break;
			R[] teams = new R[T];
			for(int i=0;i<T;i++)teams[i]=new R(i+1);
			while(R--!=0){
				int m = sc.nextInt(), t = sc.nextInt()-1, p = sc.nextInt(), j = sc.nextInt();
				if (j!=0) {
					teams[t].penalty[p]++;
				} else {
					teams[t].submit[p] = m;
					teams[t].corrected[p] = true;
				}
			}
			for(int i=0;i<T;i++){
				for(int j=1;j<=P;j++){
					if (teams[i].corrected[j]){
						teams[i].correct++;
						teams[i].time += teams[i].submit[j] + 20 * teams[i].penalty[j];
					}
				}
				teams[i].calc();
			}
			Arrays.sort(teams);
			System.out.print(teams[0].id);
			for(int i=1;i<T;i++){
				if (teams[i].score == teams[i-1].score) System.out.print("="+teams[i].id);
				else System.out.print(","+teams[i].id);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 60912
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    sunuke = [0] * N
    for _ in range(K):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            sunuke[a-1] += 1

    print(len([s for s in sunuke if s == 0]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	for(;;) {
		long long n, a[10001],sum;
		cin >> n; if(n==0) break;
		for(int i=0;i<n;i++) cin >> a[i];
		sort(a, a+n, greater<int>());
		sum = 0;
		for(int i=1;i<n;i++ ) sum += a[i]*i;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	long long int N, b = 0, a[100000 * 2] = {}, ans = 0, sum[100000 * 2 + 1] = {}, dif = 0, mini = 1000000000 * 2 + 1;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	for (int i = 0; i < N - 1; i++)
	{
		b = (sum[N] - sum[i + 1]) - sum[i + 1];
		dif = abs(b);
		mini = min(dif, mini);
	}
	cout << mini;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    long long k;
    cin>>n>>k;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    long long steps = 0;
    int start = 0;
    set<int> visited;
    vector<int> copy;
    visited.insert(start + 1);
    copy.push_back(start + 1);
    bool flag = true;
    int begsteps;
    int cycle;
    int cycbegin;
    int next;
    while(steps < k)
    {
         next = v[start];
        if(visited.find(next) == visited.end())
        {
            steps++;
            visited.insert(next);
            copy.push_back(next);
            start = next - 1;
        }
        else
        {
            flag = false;
            cycbegin = next - 1;
            for(int y = 0;y<copy.size();y++)
            {
                if(copy[y] == next)
                {
                    begsteps = y;
                    break;
                }
            }
            cycle = steps - begsteps + 1;
            break;
        }
        
    }
    if(flag)
    {
        cout<<next<<"\n";
    }
    else
    {
        if(k <= begsteps)
        {
            cout<<copy[k]<<"\n";
        }
        else
        {
            k = k - begsteps;
            k = k % cycle;
            int startn = cycbegin + 1;
            for(int i = 0;i<k;i++)
            {
                startn = v[startn-1];
            }

            cout<<startn<<"\n";
        }
        
    }
    


    return 0;
}

Measured memory_bytes: 12232
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = [Counter(input()) for _ in range(n)]
d = dict(li[0])
for c in li:
    li = []
    for k, v in d.items():
        if k not in c.keys():
            li.append(k)
        else:
            d[k] = min(d[k], c[k])
    for k in li:
        del d[k]
if len(c) == 0:
    print()
else:
    d = sorted(d.items(), key=itemgetter(0))
    ans = ""
    for k, v in d:
        ans += k * v
    print(ans)

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
string a,b;
unsigned int len,len1;
int main()
{
	cin>>a>>b;
	if(b.size()<a.size())
	{
		len=b.size();
		len1=a.size();
	}
	else
	{
		len=a.size();
		len1=b.size();
	}
	for(int i=0;i<len;i++)
	{
		cout<<a[i]<<b[i];
	}
	for(int i=len;i<len1;i++)
	{
		if(i<b.size())
	 	{
	 		cout<<b[i];
	 	}
	 	if(i<a.size())
	 	{
	 		cout<<a[i];
	 	}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,A;cin >> H >> A;
  cout << (H+A-1)/A;
  return 0;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int K;
    cin >> K;

    string S;
    cin >> S;
    bool flag = false;
    if (K < S.size()) flag = true;
    rep(i, K) {
        cout << S[i];
        if (i + 1 == S.size()) break;

    }
    if (flag) cou("...");
}


Measured memory_bytes: 3676
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	ll ans = 0;
	for(P i : ump) ans += i.sc * (i.sc - 1) / 2;

	for(ll i : a){
		ll k = ump[i];
		co(ans - k * (k - 1) / 2 + (k - 1) * (k - 2) / 2);
	}

	return 0;
}


Measured memory_bytes: 9160
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0") break;
            var one = 0; var psum = 0;
            for (int i = 0; i < line.Length; i++)
            {
                var w = int.Parse(line[i]);
                if (w >= 10) psum += 10;
                else if (w >= 2 && w <= 9) psum += w;
                else one++;
            }
            Console.WriteLine(getAnswer(psum, one));
        }
    }
    public static int getAnswer(int p, int one)
    {
        if (one == 0)
            if (p >= 22) return 0;
            else return p;
        var small = p + one;
        var big = small + 10;
        if (small >= 22) return 0;
        if (big >= 22) return small;
        else return big;
    }
}

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	if (ci - cn + 16 > cm) {
		int A = getcha() - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
		return A;
	}
	else {
		int A = *ci++ - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
		return A;
	}
}

//UnionFindのほうがはやいのかなぁ
int P[100001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	return true;
}

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


	int N = getint(), M = getint();
	rep1(i, N) P[i] = -1;
	for (int i = 1; i < 2 * M; i += 2) {
		int x = getint();
		int y = getint();
		getint();
		Unite(x, y);
	}
	
	int kotae = 0;
	rep1(i, N) {
		if (P[i] < 0) kotae++;
	}
	co(kotae);

	Would you please return 0;
}

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

int main() {
  int N;
  cin>>N;
  int A;
  int n;
  int ans;
  for(int i=0;i<N;i++){
    n=0;
    cin>>A;
    for(int j=0;A%2==0;j++){
      A/=2;
      n++;
    }
    if(i==0){
      ans=n;
    }
    if(i>0){
      if(ans>n){
        ans=n;
      }
    }
  }
  cout<<ans<<endl;
}


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

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

  vector<pair<string, ll>> st(n);
  for (ll i = 0; i < n; ++i) {
    string s;
    ll t;
    cin >> s >> t;
    st[i] = make_pair(s, t);
  }

  string x;
  cin >> x;

  ll ans = 0;
  ll c = false;
  each (i, st) {
    if (i.first == x) {
      c = true;
      continue;
    }
    if (c) {
      ans += i.second;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
  ll N; cin >> N;
  ll mod = N % 26;
  ll result = N / 26;
  char a = 'a';
  string dogs;
  while(N > 0) {
    mod = N % 26;
    N /= 26;
    if (mod == 0) {
      N -= 1;
      dogs += 'z';
    } else {
      dogs += a - 1 + mod;
    }
  }
  reverse(dogs.begin(), dogs.end());
  cout << dogs << endl;
  return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

// #define DEBUG

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, M, Q;
    cin >> N >> M >> Q;

    vector<string> S(N);
    rep(i, N) cin >> S[i];

    vector<vector<int>> sum_blue(N+1, vector<int>(M+1));
    for (int y=1; y<=N; y++) {
        for (int x=1; x<=M; x++) {
            sum_blue[y][x] = sum_blue[y][x-1] + sum_blue[y-1][x] - sum_blue[y-1][x-1] + (S[y-1][x-1] == '1');
        }
    }

    vector<vector<int>> sum_edge_x(N+1, vector<int>(M+1));
    vector<vector<int>> sum_edge_y(N+1, vector<int>(M+1));
    for (int y=1; y<=N; y++) {
        for (int x=1; x<=M; x++) {
            int tmp_x = 0, tmp_y = 0;
            if (x > 1 && S[y-1][x-1] == '1' && S[y-1][x-2] == '1') tmp_x = 1;
            sum_edge_x[y][x] = sum_edge_x[y][x-1] + sum_edge_x[y-1][x] - sum_edge_x[y-1][x-1] + tmp_x;

            if (y > 1 && S[y-1][x-1] == '1' && S[y-2][x-1] == '1') tmp_y = 1;
            sum_edge_y[y][x] = sum_edge_y[y][x-1] + sum_edge_y[y-1][x] - sum_edge_y[y-1][x-1] + tmp_y;
        }
    }

#ifdef DEBUG
    rep(y, N+1) { 
        rep(x, M+1) {
            cerr << sum_edge_x[y][x] << " ";
        }
        cerr << endl;
    }
    cerr << endl;
    rep(y, N+1) { 
        rep(x, M+1) {
            cerr << sum_edge_y[y][x] << " ";
        }
        cerr << endl;
    }
#endif

    rep(_q, Q) {
        int X1, Y1, X2, Y2;
        cin >> Y1 >> X1 >> Y2 >> X2;

        int blue_num =   sum_blue[Y2][X2]   - sum_blue[Y2][X1-1]   - sum_blue[Y1-1][X2]   + sum_blue[Y1-1][X1-1];
        int edge_x_num = sum_edge_x[Y2][X2] - sum_edge_x[Y2][X1] - sum_edge_x[Y1-1][X2] + sum_edge_x[Y1-1][X1];
        int edge_y_num = sum_edge_y[Y2][X2] - sum_edge_y[Y2][X1-1] - sum_edge_y[Y1][X2] + sum_edge_y[Y1][X1-1];

#ifdef DEBUG
        DUMP(blue_num);
        DUMP2(edge_x_num, edge_y_num);
#endif

        cout << blue_num - (edge_x_num + edge_y_num) << endl;
    }

    
}



Measured memory_bytes: 54144
N,M = map(int,input().split())
S = input()
T = input()

def gcd(a,b):
    while b>0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

L = lcm(N,M)
G = gcd(N,M)
n = L//N
m = L//M

s = [S[i*m] for i in range(G)]
t = [T[i*n] for i in range(G)]

if s == t or (G == 1 and S[0]==T[0]):
    print(L)
else:
    print(-1)


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Dice
{
	int top, left, right, up, down, bottom;
	void roll(char c)
	{
		switch (c)
		{
		case 'S':
		{
			int t = top;
			top = up;
			up = bottom;
			bottom = down;
			down = t;
		}
		break;
		case 'N':
		{
			int t = top;
			top = down;
			down = bottom;
			bottom = up;
			up = t;
		}
		break;
		case 'W':
		{
			int t = top;
			top = right;
			right = bottom;
			bottom = left;
			left = t;
		}
		break;
		case 'E':
		{
			int t = top;
			top = left;
			left = bottom;
			bottom = right;
			right = t;
		}
		break;
		default:
			break;
		}
	}
};

int main()
{
	Dice d;
	cin >> d.top >> d.down >> d.right >> d.left >> d.up >> d.bottom;
	string S;
	cin >> S;
	REP(i, S.length())
	{
		d.roll(S[i]);
	}
	cout << d.top << endl;
	return 0;
}


Measured memory_bytes: 3204
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		//String S=sc.next();
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int K=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		boolean x=false;
		for(int i=A;i<=B;i++) {
			if(i%K==0) {
				x=true;
				break;
			}
		}
		if(x)p("OK");
		else p("NG");
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35776
nd=list(map(int,input().split()))
listx=[]
count=0#整数型の個数をカウント
for i in range(nd[0]):
    listx=listx+[list(map(int,input().split()))]
for i in range(nd[0]-1):
    for k in range(i+1,nd[0]):
        d2=0
        for n in range(nd[1]):
            d2+=(listx[i][n]-listx[k][n])**2
        if float.is_integer(d2**0.5)==True:
                count+=1
print(count)

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,c;
    cin >> n >> c;
    vector<int> a(n),b(n);
    vector<vector<ll>> sums(410,vector<ll>(410,0)),dp(n+1,vector<ll>(c+1,0));
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) cin >> b[i];
    for (int i = 1;i < 401;++i) sums[0][i] = 1;
    for (int i = 1;i < 401;++i) for (int j = 1;j < 401;++j) sums[i][j] = sums[i-1][j]*j%mod;
    for (int i = 0;i < 401;++i) for (int j = 1;j < 401;++j) (sums[i][j] += sums[i][j-1]) %= mod;
    dp[0][c] = 1;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j <= c;++j) {
            for (int k = 0;k <= j;++k) (dp[i+1][j-k] += dp[i][j]*(sums[k][b[i]]-sums[k][a[i]-1])) %= mod;
        }
    }
    cout << (dp[n][0]+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 2816