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

int main()
{
    int x,sign=0;
    int sum1=0,sum2=0;
    for(int i=0;i<3;i++)
    {
        cin>>x;
        if(x==5)
        {
            sum1++;
        }
        if(x==7)
        {
            sum2++;
        }
    }
    if(sum1==2 &&sum2==1)
    {
        sign=1;
    }
    if(sign==1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int A,B,X;
	cin>>A>>B>>X;
	
	if(X>=A&&A+B>=X){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
		
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');
	int n = int.Parse(input[0]);
	int x = int.Parse(input[1]);
	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    Array.Sort(nums);
    int answer = 0;
      
    for(int i = 0; i < n; i++)
    {
      if(x >= nums[i] && i != n-1)
      {
        x -= nums[i];
        answer ++;
      }else if(x == nums[i])
      {
        answer ++;
      }
      else break;
    }
      
	//出力
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>

#define INF 1<<30-1

using namespace std;

int n;
int c[101][101];
int t[101][101];
int flg;

int washa(int st,int en,int va){
	if(flg==1){
		for(int k=1;k<=n;k++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					if(c[i][j]>c[i][k]+c[k][j]){
						c[i][j]=c[i][k]+c[k][j];
					}
					if(t[i][j]>t[i][k]+t[k][j]){
						t[i][j]=t[i][k]+t[k][j];
					}
				}
			}
		}
		flg=0;
	}
	if(va==0){
		return c[st][en];
	}else{
		return t[st][en];
	}
}

int main(){
	while(1){
		int m;
		for(int i=0;i<101;i++){
			for(int j=0;j<101;j++){
				c[i][j]=t[i][j]=INF;
			}
		}
		flg=1;
		
		scanf("%d%d",&m,&n);
		if(m==0 && n==0){
			break;
		}
		for(int i=0;i<m;i++){
			int a,z,s,x;
			scanf("%d%d%d%d",&a,&z,&s,&x);
			c[a][z]=c[z][a]=s;
			t[a][z]=t[z][a]=x;
		}
		
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			int a,z,s;
			scanf("%d%d%d",&a,&z,&s);
			
			printf("%d\n",washa(a,z,s));
		}
	}
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
  //#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      //freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      //freopen("output.txt", "w", stdout);
  //#endif
fast();
//ll  t;cin>>t;while(t--)
{
  ll n,x,s=0;
  cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s+=a[i];
    
  }
  sort(a,a+n);
  x-=s;
  int b=x/a[0];
  cout<<n+b<<endl;
  
  
  

}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

vector<string> semi;
void make (string s) {
    if (s.size() > 9) return;
    string s3 = s + '3';
    string s5 = s + '5';
    string s7 = s + '7';
    semi.push_back(s3);
    semi.push_back(s5);
    semi.push_back(s7);
    make(s3);
    make(s5);
    make(s7);

}

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

    ll N;
    cin >> N;
    make("");
    vector<ll> semill;
    for (auto e : semi) {
        if (e.find('3') == string::npos|| e.find('5') == string::npos || e.find('7') == string::npos) continue;
        ll f = stol(e);
        semill.push_back(f);
    }

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

    cout << upper_bound(semill.begin(), semill.end(), N) - semill.begin() << endl;
}

Measured memory_bytes: 6900
N,D,=map(int,input().split())

def in_cir(x,y,d):
  return x*x+y*y<=d*d

count=0
for i in range(N):
  x,y, = map(int,input().split())
  if in_cir(x,y,D):
     count+=1
print(count)

Measured memory_bytes: 9184
def main():
    N = int(input())
    st = [list(input().split()) for i in range(N)]
    X = input()
    ans = 0
    for i in range(N):
        if st[i][0] == X:
            i += 1
            break

    for j in range(i,N,1):
        ans += int(st[j][1])

    return ans

print(main())


Measured memory_bytes: 9072
#include "bits/stdc++.h"
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin >> a;
  int b = 700;
  if (a[0] == 'o') b += 100;
  if (a[1] == 'o') b += 100;
  if (a[2] == 'o') b += 100;
  cout << b;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    int res = INF;
    for (int mini : A) {
        vector<int> pos, tmp;
        for (int i=0; i<N; ++i) {
            if (A[i] < mini || i == N-1) {
                if (A[i] >= mini)
                    tmp.push_back(A[i]);
                sort(tmp.begin(), tmp.end());
                int len = (int)tmp.size();
                for (int i=0; i<len-K+1; ++i)
                    pos.push_back(tmp[i]);
                tmp.clear();
            } else {
                tmp.push_back(A[i]);
            }
        }
        if ((int)pos.size() < Q)
            continue;
        sort(pos.begin(), pos.end());
        chmin(res, pos[Q-1] - pos[0]);
    }

    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3696
A,B=input().split()
A,B=[int(A),int(B)]

N = 0
sum = 0

for N in range(A,B+1):
	tmp1 = str(N)
	tmp1 = tmp1[::-1]
	tmp2 = str(N)
	if tmp1 == tmp2:
		sum += 1

print(sum)

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

int main(){
    int k;
    cin >> k;
    vector<int> used(k, 0);
    deque<pair<int, int>> dq; // 頂点, コスト
    dq.push_front(make_pair(1, 1)); // 1 -> 0 への最短距離
    while(!dq.empty()){
        auto cur = dq.front(); dq.pop_front();
        if(used[cur.first]) continue;
        used[cur.first] = 1;
        if(cur.first == 0){
            cout << cur.second << endl;
            return 0;
        }
        // 辺の重みが0なら先頭へ
        dq.push_front(make_pair((10 * cur.first) % k, cur.second));
        // 辺の重みが1なら後ろへ
        dq.push_back(make_pair((cur.first + 1) % k, cur.second + 1));
    }
}

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

int main() {
  int a,b,k,total;
  bool c=false;
  cin >> k;
cin >> a >> b;
for(total=0;total<=b;total+=k)
{
	if(total>=a)
	{
		c=true;
	}
}
if(c==true)
{
	cout << "OK";
}
  else
  {
	  cout << "NG";
  }
}


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

int main(){
  vector<int> H(100);
  int count=1;
  int N;
  cin >> N;
  int k;
  
  for(int i=0; i < N; i++){
    cin >> H.at(i);
  }
  
  for(int i=1; i < N; i++){
    k=0;
    for(int j=0; j < i; j++){
      if(H.at(j) <= H.at(i))
        k++;
    }
    if(k==i)
      count++;
  }
  
  cout << count << endl;
}

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

#define int long long

using namespace std;

int dp[100010][110];
int a[110][2];

int32_t main()
{
    int n,w;
    cin >> n >> w;

    for(int i=1;i<=n;i++)
        cin >> a[i][0] >> a[i][1];

    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j] = dp[i][j-1];

            if(a[j][0] <= i)
                dp[i][j] = max(dp[i][j],dp[i-a[j][0]][j-1] + a[j][1]);
        }
    }

    // for(int i=0;i<=w;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //         cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << dp[w][n] << endl;
}

Measured memory_bytes: 86144
#include<iostream>
#include<cstdio>
using namespace std;
int m,d;
int getk(int x)
{
	int ans=1;
	while(x)
	{
		ans*=x%10;
		x/=10;
	}
	return ans;
}
int main(){
	int ans=0;
	scanf("%d%d",&m,&d);
	for(int j=1;j<=m;j++)
	for(int i=1;i<=d;i++)
	{
		if(i%10<2||(i/10)%10<2) continue;
		if(getk(i)==j) ans++;
	}
	cout<<ans;
	return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    if (all_of(begin(As), end(As), [](auto a) { return a % 2 == 0; })) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

vector<int> v[100009];
int d[100009];

int ds(int n)
{
	if (v[n].size() == 0) 
		return d[n] = 0;
	if (d[n] != 0) return d[n];
	for (int i = 0; i < v[n].size(); i++)
		d[n] = max(d[n], ds(v[n][i]) + 1);
	return d[n];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		int a, b; cin >> a >> b;
		v[b].push_back(a);
	}
	for (int i = 1; i <= n; i++)
		if (d[i] == 0)
			ds(i);
	for (int i = 1; i <= n; i++) {
		if (d[i] == 0) {
			cout << 0 << '\n';
			continue;
		}
		for (int j = 0; j < v[i].size(); j++)
			if (d[i] - 1 == d[v[i][j]]) {
				cout << v[i][j] << '\n';
				break;
			}
	}
	return 0;
}

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

vector<int> g[505];
int l_cnt[505], r_cnt[505];
bool used[505];

int print(bool ok) {
        if (ok) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
}

bool dfs(int v) {
        if (g[v].empty()) return true;
        used[v] = true;
        bool res = l_cnt[v] != r_cnt[v]; //端になりうる？
        for (auto u : g[v]) if (!used[u]) res |= dfs(u); //パーツが足りる？
        return res;
}

int main() {
        int n, h, a, b, c, d;
        cin >> n >> h;
        for (int i = 0; i < n; i ++) {
                cin >> a >> b >> c >> d;
                int lh = (c == 0 ? a : c + 250);
                int rh = (d == 0 ? b + 250 : d);
                l_cnt[lh] ++;
                r_cnt[rh] ++;
                g[lh].push_back(rh);
                g[rh].push_back(lh);
//cerr << lh << ' ' << rh << endl;
        }
        for (int i = 0; i < h + 1; i ++) if (r_cnt[i] > l_cnt[i]) return print(0);
        for (int i = 251; i < h + 251; i ++) if (l_cnt[i] > r_cnt[i]) return print(0);
        for (int i = 0; i < 501; i ++) if (!used[i]) if (!dfs(i)) return print(0);
        return print(1);
}


Measured memory_bytes: 1664
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;
const int Mod = 1e9 + 7;
typedef pair<int, int> pii;

bool Legal(int a, int b, int c) {
	if ((a == 0 && b == 1 && c ==2 ) || (a == 0 && b == 2 && c == 1) || (a == 1 && b == 0 && c == 2)) return false;
	return true;
}

bool Legal2(int a, int b, int c, int d) {
	if ((a == 0 && b == 1 && c ==2 ) || (a == 0 && b == 2 && c == 1) || (a == 1 && b == 0 && c == 2) || (d == 0 && a == 1 && c == 2) || (d == 0 && b == 1 && c == 2)) return false;
	return true;
}
int n, ans;
int dp[105][4][4][4];
int main() {
	INIT
	cin >> n;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				if(Legal(i, j, k)) {
					dp[3][i][j][k] = 1;
				}
			}
		}
	}
	
	for (int l = 4; l <= n; ++l) {
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				for (int k = 0; k < 4; ++k) {
					for (int u = 0; u < 4; ++u) {
						if (Legal2(i, j, k, u)) {
							dp[l][i][j][k] = (dp[l][i][j][k] + dp[l-1][u][i][j]) % Mod;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < 4 ; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				ans = (ans + dp[n][i][j][k]) % Mod;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import std.stdio : writeln, writefln;
import std.array;
import std.range;
import std.math : fabs;

void swap(T)(ref T a, ref T b){
	T tmp = a;
	a = b;
	b = tmp;
}

void main(){
	while(true){
		int q = next!int();
		if(q==-1) break;
		
		double x = q/2.;
		while(true){
			if(fabs(x*x*x -q) < q*0.00001){
				break;
			}
			x = x - (x*x*x -q)/(3.*x*x);
		}
		writefln("%.6f", x);
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
int x, y;
int main()
{
  cin >>x>>y;
  for (int i = 0; i <= x; i+=1)
  {
    int j = x - i;
    if (i * 2 + j * 4 == y) {puts("Yes"); return 0;}
  }
  puts("No");
}

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


int main(void) {
    int A, P;
    cin >> A >> P;
    int piece = P + 3 * A;
    int ans = piece /2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
x,y,z,K=list(map(int,input().split()))
alst=sorted(list(map(int,input().split())),reverse=True)
blst=sorted(list(map(int,input().split())),reverse=True)
clst=sorted(list(map(int,input().split())),reverse=True)

hq=[(-alst[0]-blst[0]-clst[0],0,0,0)]
used=set()

while K>0:
    s,i,j,k=heapq.heappop(hq)
    s*=-1
    if (i,j,k) in used:
        continue
    used.add((i,j,k))
    print(s)

    heapq.heappush(hq,(-s+alst[i]-alst[i+1],i+1,j,k)) if i+1<x else 0
    heapq.heappush(hq,(-s+blst[j]-blst[j+1],i,j+1,k)) if j+1<y else 0
    heapq.heappush(hq,(-s+clst[k]-clst[k+1],i,j,k+1)) if k+1<z else 0

    K-=1


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


int main(){
	long long N,K;
	cin>>N>>K;
	int ans = -1;
	vector<pair<int,int>> V;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		V.push_back(make_pair(a,b));
	}
	
	sort(V.begin(),V.end());
	
	for(int i=0;i<N;i++){
		K-=V[i].second;
		if(K<=0){
			ans=V[i].first;
			break;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();
			List<Dice> allDice = new ArrayList<>();
			
			for(int i = 0; i < n; i++) {
				int[] labels = new int[6];
				for(int j = 0; j < 6; j++) {
					labels[j] =  sc.nextInt();
				}
				allDice.add(new Dice(labels));
			}
			
			
			Dice dice1;
			Dice dice2;
			for(int i = 0; i < n - 1; i++) {
				dice1 = allDice.get(i);
				
				for(int j = i + 1; j < n; j++) {
					dice2 = allDice.get(j);
					if(dice1.isSame(dice2)) {
						System.out.println("No");
						return;
					}
				}
			}
			
			System.out.println("Yes");
		}
	}
}

class Dice {
	
	private int position[];
	
	Dice(int labels[]){
		this.position = labels;
	}
	
	void move(String order) {
		if(order.equals("N")) {
			position = new int[]{position[1], position[5], position[2], position[3], position[0], position[4]};
			return;
		}
		if(order.equals("E")) {
			position = new int[]{position[3], position[1], position[0], position[5], position[4], position[2]};
			return;
		}
		if(order.equals("S")) {
			position = new int[]{position[4], position[0], position[2], position[3], position[5], position[1]};
			return;
		}
		if(order.equals("W")) {
			position = new int[]{position[2], position[1], position[5], position[0], position[4], position[3]};
			return;
		}
	}
	
	boolean isSame(Dice dice) {
		int countS = 0;
		while(this.getSideS() != dice.getSideS()) {
			if(countS == 8) {
				return false;
			}
			if(countS++ == 4) {
				dice.move("E");
			}
			dice.move("S");
		}
		
		int countE = 0;
		while(this.getTop() != dice.getTop()) {
			if(countE++ >= 4) {
				return false;
			}
			dice.move("E");
		}
		
		if(this.getSideE() != dice.getSideE()) {
			return false;
		}
		if(this.getSideW() != dice.getSideW()) {
			return false;
		}
		if(this.getSideN() != dice.getSideN()) {
			return false;
		}
		if(this.getBottom() != dice.getBottom()) {
			return false;
		}
		
		return true;
	}
	
	int getTop() {
		return position[0];
	}
	int getSideS() {
		return position[1];
	}
	int getSideE() {
		return position[2];
	}
	int getSideW() {
		return position[3];
	}
	int getSideN() {
		return position[4];
	}
	int getBottom() {
		return position[5];
	}
}


Measured memory_bytes: 30248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<int> s(N);
	bool b = false;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
		sum += s[i];
		if (s[i] % 10 != 0) {
			b = true;
		}
	}
	if (!b) {
		cout << "0" << endl;
		cin >> N;
		return 0;
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		cin >> N;
		return 0;
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < N; ++i) {
		if (s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
			cin >> N;
			return 0;
		}
	}

	cin >> N;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool solve(const string& S){
  string key = "keyence";
  rep(i,S.size()){
    REP(j,i,S.size()){
      string t = S.substr(0,i) + S.substr(j);
      if(key == t) return true;
    }
  }

  return false;
}

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

  if(solve(S)) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
aa = [[0, 0, 0]]

for i in range(n):
    aa.append(list(map(int, input().split())))


def get_distance(a1, a2):
    return abs(a1[1] - a2[1]) + abs(a1[2] - a2[2])

for i, a in enumerate(aa):
    if i > 0:
        xy_d = get_distance(aa[i], aa[i-1])
        t_d = aa[i][0] - aa[i-1][0]
        if xy_d > t_d or (xy_d - t_d) & 1:
            print('No')
            break
else:
    print('Yes')


Measured memory_bytes: 27380
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    
    int A,B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
    return 0;
}

Measured memory_bytes: 256
a = gets.chomp.to_i
ary = gets.chomp.split(" ").map(&:to_i).sort

if ary.first == 0
  puts 0
else
  t = 1
  ary.each do |v|
    t *= v
    if t > (10 ** 18)
      t = -1
      break
    end
  end
  puts t
end

Measured memory_bytes: 24948
#include <iostream>

using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = a * x + b * y; 
  for (int cc=0;cc<=100000;cc++) {
    int aa = max(x - cc, 0);
    int bb = max(y - cc, 0);
    
    int sum = aa * a + bb * b + cc * 2 * c;
    ans = min(ans, sum);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(k==1) cout<<0<<endl;
    else cout<<n-k<<endl;
}

Measured memory_bytes: 256
use std::collections::{BTreeSet, VecDeque};

fn main() {
    //    let n = 3;
    //    for mask in 0..(1 << (n * n)) {
    //        let mut s = vec![vec!['.'; n]; n];
    //        for i in 0..n {
    //            for j in 0..n {
    //                let m = i * n + j;
    //                if mask & (1 << m) != 0 {
    //                    s[i][j] = '#';
    //                }
    //            }
    //        }
    //
    //        let ans1 = solve(&s);
    //        let ans2 = naive(&s);
    //        assert_eq!(ans1, ans2, "{:?} {:?} {:?}", s, ans1, ans2);
    //    }

    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s: Vec<Vec<char>> = (0..n).map(|_| sc.chars()).collect();

    match solve(&s) {
        Some(ans) => println!("{}", ans),
        None => println!("-1"),
    }
}

fn solve(s: &Vec<Vec<char>>) -> Option<usize> {
    let n = s.len();

    let min_fill = (0..n)
        .map(|r| {
            let holes = s[r].iter().filter(|&&c| c == '.').count();
            let has_column = s.iter().any(|row| row[r] == '#');
            holes + if has_column { 0 } else { 1 }
        })
        .min()
        .unwrap();
    let filled_columns = (0..n)
        .filter(|&c| s.iter().all(|row| row[c] == '#'))
        .count();
    let ans = n - filled_columns + min_fill;
    if ans <= 2 * n {
        Some(ans)
    } else {
        None
    }
}

//fn naive(s: &Vec<Vec<char>>) -> Option<usize> {
//    if s.iter().all(|row| row.iter().all(|&c| c == '.')) {
//        return None;
//    }
//    let n = s.len();
//    let mut q = VecDeque::new();
//    let mut set = BTreeSet::new();
//    set.insert(s.clone());
//    q.push_back((s.clone(), 0));
//    while let Some((s, c)) = q.pop_front() {
//        if s.iter().all(|row| row.iter().all(|&c| c == '#')) {
//            return Some(c);
//        }
//
//        for i in 0..n {
//            for j in 0..n {
//                let mut s = s.clone();
//                let v = s[i].clone();
//                for i in 0..n {
//                    s[i][j] = v[i];
//                }
//                if !set.contains(&s) {
//                    set.insert(s.clone());
//                    q.push_back((s, c + 1));
//                }
//            }
//        }
//    }
//    unreachable!()
//}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Measured memory_bytes: 9192
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 10000005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b;
   cin>>a>>b;
   if(a<10 && b<10)
    cout<<(a*b)<<endl;
   else
    cout<<-1<<endl;

}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define N 19
#define M 35009
using namespace std;

int n,m,a[N][N],f[M],g[M][N],dp[M][N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k,x,y,z;
	for (i=1; i<=m; i++){
		scanf("%d%d%d",&x,&y,&z);
		a[x][y]=a[y][x]=z;
		f[1<<x-1|1<<y-1]+=z;
	}
	int tot=1<<n;
	for (i=1; i<=n; i++)
		for (j=1; j<tot; j++) if (j>>i-1&1) f[j]+=f[j^1<<i-1];
	memset(dp,195,sizeof(dp)); memset(g,195,sizeof(g));
	int ans=-1000000000;
	for (i=1; i<tot; i+=2){
		if (!(i>>n-1&1)) dp[i][1]=f[i];
		for (j=1; j<=n; j++) if (i>>j-1&1){
			for (k=i-1&i; k; k=k-1&i) if (k&1)
				dp[i][j]=max(dp[i][j],g[k][j]+f[i^k]);
			if (i>>n-1&1){ if (j==n) ans=max(ans,dp[i][j]); continue; }
			for (k=1; k<=n; k++) if (!(i>>k-1&1) && a[j][k]>0)
				g[i][k]=max(g[i][k],dp[i][j]+a[j][k]);
		}
	}
	printf("%d\n",f[tot-1]-ans);
	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t a, b, c;
  cin >> a >> b >> c;

  for (auto i : irange(0L, b + 1)) {
    if (i * a % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
void koch(double x1, double y1, double x2, double y2, int n){
  double sx,sy,ux,uy,tx,ty;
  if(n != 0){
     
    sx = (x2 - x1)/3 + x1;
    sy = (y2 - y1)/3 + y1;
     
    tx = 2 * (x2 - x1) / 3 + x1;
    ty = 2 * (y2 - y1) / 3 + y1;
     
    ux = (cos(M_PI/3)*(tx - sx) - sin(M_PI/3)*(ty-sy)) + sx;
    uy = (sin(M_PI/3)*(tx - sx) + cos(M_PI/3)*(ty-sy)) + sy;
     
    koch(x1,y1,sx,sy,n-1);
    koch(sx,sy,ux,uy,n-1);
    koch(ux,uy,tx,ty,n-1);
    koch(tx,ty,x2,y2,n-1);
  }else {
    printf("%f %f\n",x2,y2);
  }
}
 
int main(){
  int n;
  double x1 = 0.0,y1 = 0.0;
  double x2 = 100.0,y2 = 0.0;
 
  scanf("%d",&n);
  printf("%f %f\n",x1,y1);
  koch(x1,y1,x2,y2,n);
  return 0;
}

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

int main() {
  int s1,s2,s3,x;
  cin >>x;
  s1=x%10;
  s2=((x-s1)/10)%10;
  s3=(x-s1-10*s2)/100;
  cout << s1+s2+s3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n,d,x;
	int a[100];
	int ans=0;
	
	cin>>n>>d>>x;
	ans=x;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans += d/a[i];
		if(d%a[i]!=0)
		{
			ans++;
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N; ll W; cin >> N >> W;
  ll ans = 0;
  vector<vector<ll>> V(4);
  ll w,v;
  ll ww;
  rep(i,N){
    if(i==0){
      cin >> ww >> v;
      V[0].pb(v);
    }
    else{
      cin >> w >> v;
      V[w-ww].pb(v);
    }
  }
  rep(i,4) sort(rall(V[i]));
  vector<vector<ll>> sums(4);
  rep(i,4) {
    sums[i].pb(0);
    rep(j,sz(V[i])){
      sums[i].pb(sums[i].back()+V[i][j]);
    }
  }
  rep(w0,sz(V[0])+1){
    rep(w1,sz(V[1])+1){
      rep(w2,sz(V[2])+1){
        rep(w3,sz(V[3])+1){
          ll sumw = ww*w0+(ww+1)*w1+(ww+2)*w2+(ww+3)*w3;
          ll sumv = sums[0][w0]+sums[1][w1]+sums[2][w2]+sums[3][w3];
          if(sumw <= W){
            ans = max(ans, sumv);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int Nmax = 100001;
const int MOD = 1000000007;

int N;
string S[2];
vector<int> v;

int cot(int prev,int next) {
    return next + (prev == next);
}

int main() {
    cin>>N;
    cin>>S[0];
    cin>>S[1];
    for(int i=0; i<N; i++) {
        if(S[0][i] == S[1][i]) {
           v.push_back(1); 
        }
        else {
           if(i==0 || S[0][i] != S[0][i-1]) {
               v.push_back(2);
           }
        }
    }
    int ans = 3;
    ans *= v[0];
    for(int i=1; i<v.size(); i++) {
        ans = ( 1LL * ans * (v[i] + (v[i-1] == v[i])) ) % MOD;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();
        sc.close();
        Set<String> ts = new TreeSet<>();

        for (int i = 0; i <= s.length(); i++) {
            for (int j = i + 1; j <= s.length(); j++) {
                if (j > i + k) {
                    break;
                } else {
                    ts.add(s.substring(i, j));
                }
            }
        }

        Iterator<String> it = ts.iterator();
        int cnt = 1;

        while (it.hasNext()) {
            if (cnt == k) {
                System.out.println(it.next());
                return;
            }
            it.next();
            cnt++;
        }
    }
}

Measured memory_bytes: 26580
S = input()
T = "abcdefghijklmnopqrstuvwxyz"
A = [str(x) for x in T]

if len(S) != 26:
    for l in S:
        A.remove(l)
    print(S+A[0])
    exit()

if S == T[::-1]:
    print(-1)
    exit(0)

U = []
for k in range(1,26):
    if S[-k-1] > S[-k]:
        U.append(S[-k-1])
        U.append(S[-k])
    else:
        U.append(S[-k-1])
        U.append(S[-k])
        t = S[-k-1]
        S = S[:-k-1]
        break

U.sort()
for l in U:
    if t < l:
        print(S+l)
        exit(0)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x,price;
  cin>>a>>b>>x;
  if(2*b<=a){
    price=x/500*b;
    if(x%500 ) price+=b;
  }else{
    price=x/1000*a;
    if(x%1000){
      if(x%1000>500) price+=a;
      else price+=min(a,b);
    }
  }
  cout<<price<<endl;
  return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
#include<vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main()
{
    int N;
    scanf("%d", &N);
    vector<int> v(N);
    double sum = 0.0;
    
    rep(i, N){
        scanf("%d", &v[i]);
        sum += (double)1.0/v[i];
    }
    printf("%lf", 1.0/sum);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


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




Measured memory_bytes: 2052
n,k=map(int,input().split())
D=input()
D_str=str(D)
i=0
string=D_str.split()
while True:
    judge=0
    fee=n+i
    fee_str=str(fee)
    for j in range(k):
        index=fee_str.find(string[j])
        judge = judge + index
    if judge == -k :
        break
    i=i+1
print(fee)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int n; cin >> n;
  vector<string> s(n);
  vi t(n);
  rep(i,n) cin >> s[i] >> t[i];
  string x; cin >> x;

  int time = 0;
  rep(i,n) {
    time += t[i];
    if (s[i] == x) break;
  }

  cout << accumulate(ALL(t), 0LL) - time << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    string a;
    int sum = 0;
    cin >> a;
    for (int i = 0; i < 3; i++) {
        if (a[i] == '7') {
            cout << "Yes";
            break;
        }
        else {
            sum++;
        }
    }
    if (sum == 3) {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
void  solve(int , int);
int n , q , a[2000] , m[2000];
int i,j,judge[2000];
int main()
{
  

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

  scanf("%d",&q);
  for(j = 0 ; j < q ; j++)
    scanf("%d",&m[j]);

  for(i = 0 ; i < q ; i++)
    {
      solve(0 , m[i]);
      //printf("i = %d\n",i);
    }

  for(i = 0 ; i < q ; i++)
    {
      if(judge[i] == 1)printf("yes\n");
      else printf("no\n");
    }

  return 0 ; 
}

void  solve( int d,int s)
{
  //  int res;
  if(s == 0)judge[i] = 1;// {printf("loop finish\n");return  1;}
  else if(s > 0 && d < n)
    {
      solve(d+1 , s-a[d]);
      solve(d+1 , s);
      }
  //printf("loop finish\n");



  // if(d >=  n)return 0;
  //res = solve(d + 1,s) || solve( d +1 , s - a[d]);

}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main() {
	int n, m, p;
	while ( cin >> n >> m >> p, n || m || p ) {
		--m;
		int X[100], sum = 0;
		for (int i = 0; i < n; ++i) {
			cin >> X[i];
			sum += X[i];
		}
		sum *= 100-p;
		cout << (X[m] == 0 ? 0 : sum / X[m]) << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
  #pragma GCC target ("avx2")
  #pragma GCC optimization ("O3")
  #pragma GCC optimization ("unroll-loops")
  using ll = long long;

  #define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
  #define br cout<< "\n";
  #define endl "\n"
  #define vi vector<int>
  #define vii vector<ll>
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define rep(i,a,b) for(ll i=a; i<=b;i++)
  #define all(v) begin(v),end(v)
  #define minv(a) *min_element(all(a))
  #define maxv(a) *max_element(all(a))
  #define outputv(a) for(auto i:a) cout<<i<<" ";br;
  #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  #define outputvp(a) for(auto j:a) {cout<<j.first<<" " << j.second << ",",br;}
  using namespace std;

  ll mod = 1e9+7;
  ll inf = 1000000000000000000;

  ll power( ll base, ll power, ll mod);
  ll bc(ll n, ll k);

  void inout(){
      #ifndef ONLINE_JUDGE
          // for getting input from input.txt
          freopen("/home/logan/contest/ongoing/input.txt", "r", stdin);
          // for writing output to output.txt
          freopen("/home/logan/contest/ongoing/output.txt", "w", stdout);
      #endif
  }



 




  int main(){
    FastIO
    //inout();
    ll a,v;cin >> a >> v;
    ll b,w; cin >> b >> w;
    ll t; cin >> t;
    if(a == b) cout << "YES\n";
    else{
      if( b < a) swap(b,a);
      if( w >= v) cout << "NO\n";
      else{
        if(v*t >= w*t +b-a) cout << "YES\n";
        else cout << "NO\n";
      }
    }
    


    
 


    return 0;
  }
 

 ll power( ll base, ll power, ll mod){
      ll res = 1;
      while( power ){
        if(power%2) res= (res*base)%mod, power--;
        else base= (base * base)%mod, power/=2;
      }

      return res;
  }

  ll bc(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
  
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 



Measured memory_bytes: 3636
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<int> G(N), C(N-1);
	rp(i, 0, N-1){
		int p,c; cin>>p>>c; p--,c--;
		G[c] = p;
		C[i] = c;
	}

	vector<int> colors(N), next_colors(N, 1);
	rp(c, 1, N){
		int p = G[c];
		int p_color = colors[p];
		int color = next_colors[p];
		colors[c] = color==p_color? ++color: color;
		next_colors[p] = ++color;
	}

	int K = 1;
	for(int k:next_colors) K = max(K, k-1);
	cout<< K <<endl;
	for(int c:C) cout<< colors[c] <<endl;
}

Measured memory_bytes: 2048
n, k = map(int, input().split())
ans = [0] * (k + 2)
S = 0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        ans[i] = cmb( (k-1), (i-1) , mod ) * cmb( (n - k + 1), (i) , mod ) % mod
        if ans[i] < 0:
            ans[i] + mod
        print(ans[i])

Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    ll A[N+1];
    for (int i=1;i<=N;i++) cin >> A[i];
    ll S[N+1];
    S[0] = 0;
    for(int i=1;i<N;i++){
        S[i] = S[i-1] + (i%2 ? 1:-1)*A[i];
    }

    ll X[N+1];
    X[N] = (A[N] - (S[N-1]))/2;
    for (int i=1;i<N;i++){
        X[i] = (i%2 ? 1:-1)*(S[N-1] - S[i-1]);
        X[i] += (i%2 ? 1:-1)*X[N];
        cout << 2*X[i] << " ";
    }
    cout << 2*X[N] << endl;

}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,t,a,tmpt,tmpa;

main() {
    cin >> n >> tmpt >> tmpa,n--;
    rep(i,n) {
        cin >> t >> a;
        int hoget = (tmpt+t-1)/t,hogea = (tmpa+a-1)/a;
        if (tmpt < t && tmpa < a) tmpt = t ,tmpa = a;
        else {
            if (hoget < hogea) {
                tmpt = hogea*t;
                tmpa = hogea*a;
            } else {
                tmpt = hoget*t;
                tmpa = hoget*a;
            }
        }
    }
    cout << tmpt+tmpa << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	register int n,m,ans;
	cin>>n>>m;
	for(register int i=m/n;i>=1;i--){
		if(m/i>=n&&m%i==0){
			ans=i;
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256