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

int N,K; string s;

int dist(char c){
    return 26-(c-'a');
}

int main(){
    cin >> s;
    cin >> K;

    N=s.length();
    int i;

    for (i=0; i<N; i++)
        if (dist(s[i])<=K && s[i]!='a') K-=dist(s[i]),s[i]='a';

    K%=26;
    int cr=s[N-1]-'a';
    cr=(cr+K)%26;
    s[N-1]='a'+(char)(cr);

    cout << s << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);

int main(){
	ll n,m;
	cin>>n>>m;
	std::vector<ll> a(n);
	fo(i,n) cin>>a[i];
	ll suum=0;
	sort(all(a));
	reverse(all(a));
	fo(i,n) suum+=a[i];
	ll cnt=0;
	ll tmp=suum/(4*m);
	fo(i,n){
		if(a[i]*(4*m)<suum) ;
		else cnt++;

	}
	
	if(cnt>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;

  int p_count = 0;

  REP(i, s.length()) {
    if(s[i] == 'p') p_count++;
  }

  cout << ((s.length() / 2) - p_count) << endl;
}


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

//using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;


int main() {

int n,x;
while(1){

int cnt=0;
cin >> n >> x;
if(n==0&&x==0)break;
for (int i = 1; i <= n-2; ++i)
{
   for (int j = i+1; j <= n-1; ++j)
   {
       for (int k = j+1; k <=n ; ++k)
       {
           if(i+j+k==x)cnt++;
       }
   }
}
cout << cnt << endl;

}
return 0;
}





Measured memory_bytes: 3112
#include<stdio.h>
int main()
{
	int sum,i,n;
	sum=0;
	n=0;
	while(n<1 || n>100)
	{
	scanf("%d",&n);
	}
	for(i=1 ; i<=n ; i++)
	{
		sum=sum+i;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef int _int;
#define int long long
struct ele{
	int a,b,p;
	inline bool operator<(const ele&x)const{
		return p>x.p;
	}
}o[N];
int n,ans;
_int main(){
	cin>>n;for(int i=1;i<=n;++i)cin>>o[i].a>>o[i].b,o[i].p=o[i].b+o[i].a;
	sort(o+1,o+1+n);
	for(int i=1;i<=n;++i)ans+=(i&1?o[i].a:-o[i].b);
	cout<<ans<<endl;return 0;
}


Measured memory_bytes: 2560
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
a,b,k = readInts()
cnt = 0
while cnt < k:
    if cnt%2 == 0:
        a //= 2
        b += a
    else:
        b //= 2
        a += b
    cnt += 1
print(a,b)


Measured memory_bytes: 10336
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll=long long int;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
constexpr int INF=1<<30;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

#define EVAL 1

#ifdef EVAL
#define LOG(i) 0
#else
#define LOG(i) cerr<<#i<<": "<<i<<endl
#endif
vi dp=vi(30000,INF); //damage -> min_cost
void solve(){
	int H,N,A,B,ans=INF;
	cin>>H>>N;
	dp[0]=0;
	REP(i,N){
		scanf("%d%d",&A,&B);
		REP(j,30000-A)dp[j+A]=min(dp[j+A],dp[j]+B);
	}
	FOR(i,H,30000)ans=min(ans,dp[i]);
	REP(i,50)LOG(dp[i]);
	cout<<ans<<endl;
	//cout<<(H<=0?"Yes":"No")<<endl;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
        int max=a,min=b;
        if(max<=c)
        {
            max=c;
        }
        if(min>=d)
        {
            min=d;
        }
        int res=min-max;
        if(res<0)
        {
            res=0;
        }
        printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;


int main() {
    

    int n;
    cin  >> n;
    int card[4][13] = {{}};
    for (int i=0;i<n;i++){
        char s;
        int k;
        cin >> s >> k;
        if(s == 'S'){
            card[0][k-1] = 1;
        }else if(s == 'H'){
            card[1][k-1] = 1;
        }else if (s == 'C'){
            card[2][k-1] = 1;
        }else{
            card[3][k-1] = 1;
        }
    }
    char soot[4] = {'S','H','C','D'};
    for (int i=0;i<4;i++){
        for (int j=0;j<13;j++)
            if(card[i][j] == 0){
                cout << soot[i] << " " << j+1 << endl;
            }
    }
}


Measured memory_bytes: 3096
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n,d,a,b,ans=0;
	cin>>n>>d;
	d*=d;
	for (int i = 0; i < n; ++i)
	{
		cin>>a>>b;
		if((a*a+b*b)<=d)ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

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

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main(){
  cin >> k;
  cout << a[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input){
tmp = input.split("\n");

var N = parseInt(tmp[0]);
var K = parseInt(tmp[1]); 
var ans = 1;
  
for(var i = 0 ; i<N ; i++){
  ans = Math.min(2*ans,ans+K);
}
console.log(ans);
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
// Given an array of integers of size ‘n’.
// Our aim is to calculate the maximum sum of ‘k’
// consecutive elements in the array.

/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define in insert
#define cn count
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef set<int> si;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/

const int SIZE = 1e6 + 10;

void solve() {
	string s;
	R(s);
	int i = 0, j = sz(s) - 1;
	int cnt = 0;
	while (i <= j) {
		if (s[i] != s[j])
			cnt++;
		i++;
		j--;
	}
	W(cnt);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) co("Possible");
  else co("Impossible");
                                      
  
  
  return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  map<int,int> m;
  for(int i = 1; i <= N; i++){
    int tmp;
    cin >> tmp;
    m[i] = tmp;
  }

  int now = 1;
  bool flg = false;
  int i;
  for(i = 1; i <= N; i++){
    int next = m[now];
    if(next == 2){
      flg = true;
      break;
    } else { 
      now = next;
    }
  }
  cout << (flg ? i : -1) << endl;

}


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

typedef long long ll;

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

    ll N;
    cin >> N;

    ll count = 2;

    if(N == 2) count--;

    for(ll i = 2; i * i <= N - 1; i++) {
        if((N - 1) % i) continue;

        count += 2LL;

        if((N - 1) / i == i) count--;
    }

    for(ll i = 2; i * i <= N; i++) {
        if(N % i) continue;

        ll x = N;
        while(x % i == 0)
            x /= i;

        if(x % i == 1) count++;

        if(N / i == i) continue;

        x = N;
        while(x % (N / i) == 0)
            x /= N / i;
        
        if(x % (N / i) == 1) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		scanner.close();
		
		String res = "No";
		if(input.charAt(2) == input.charAt(3) && input.charAt(4) == input.charAt(5)) {
			res = "Yes";
		}
		
		System.out.println(res);
	}
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

//O(log(max(a,b)))
ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

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

ll extgcd(ll a,ll b,ll &x,ll &y){
    ll d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    } else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    if(extgcd(a,m,x,y)==1) return (x+m)%m;
    return 0;
}

vector<ll> fact;

void init_fact(ll n,ll m){
    fact.resize(n+1);
    fact[1]=1;
    for(ll i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}

//O(log_p(n))
ll mod_fact(ll n,ll p,ll &e){
    e=0;
    if(n==0) return 1;

    ll res=mod_fact(n/p,p,e);
    e+=n/p;

    if(n/p%2!=0) return res*(p-fact[n%p])%p;
    return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
    if(n<0||k<0||n<k) return 0;
    ll e1,e2,e3;
    ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
    if(e1>e2+e3) return 0;
    return a1*mod_inverse(a2*a3%p,p)%p;
}

void solve(){
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    ll mod=1000000007,ans=0;
    init_fact(10000000,mod);
    rep(y,0,h-a) ans=(ans+mod_comb(y+b-1,y,mod)*mod_comb((h-y-1)+(w-b-1),h-y-1,mod)%mod)%mod;
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    rep(i,100) {
        char temp = s.back();
        s.pop_back();
        s.insert(0, 1, temp);
        if(s==t){ cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 32

struct cells {
  int x;
  int y;
  int d;
  int cost;

  bool operator<(const cells& a) const {
    return a.cost < cost;
  }
  // cells(int p, int q, int r, int s) {x(p), y(q), d(r), cost(s);}
};


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

int main(){
  cin.sync_with_stdio(false);

  int w, h;
  while(cin >> w >> h, w) {
    priority_queue<cells> q;
    rep(i, MAX_N)rep(j, MAX_N)rep(k, 4) mp[i][j][k] = 5;
    repl(i, 1, h + 1)repl(j, 1, w + 1) {
      cin >> mp[i][j][0];
      mp[i][j][1] = mp[i][j][2] = mp[i][j][3] = mp[i][j][0];
    }
    int c[4] = {};
    rep(i, 4) cin >> c[i];

    q.push(cells{1, 1, 0, 0});
    int ans = 0;
    while(!q.empty()) {
      cells p = q.top(); q.pop();
      if(p.x == w && p.y == h) {
        ans = p.cost;
        break;
      } else if (mp[p.y][p.x][p.d] < 5) {
        rep(i, 4) {
          if (mp[p.y + dy[i]][p.x + dx[i]][i] != 5) {
            if ((i + 4 - p.d) % 4 == mp[p.y][p.x][p.d]) {
              q.push(cells{p.x + dx[i], p.y + dy[i], i, p.cost});
            } else {
              q.push(cells{p.x + dx[i], p.y + dy[i], i, p.cost + c[(i + 4 - p.d) % 4]});
            }
          }
        }
        mp[p.y][p.x][p.d] = 5;
      }
    }

    print(ans);
  }


  return 0;
}

Measured memory_bytes: 3228
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicInteger;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

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

    private static void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] h = in.nextIntArray(n);
        int ans = 0;
        for (int i : h) {
            if (i >= k)
                ans++;
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 31580
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

int n;
vector<int> adj[100005];
int a[100005];

bool solve(int node, int fa)
{
	if(adj[node].size()==1) return true;
	int ttake=0;
	int mmax=0;
	for(auto i:adj[node])
	{
		if(i==fa) continue;
		if(!solve(i, node)) return false;
		ttake+=a[i];
		mmax=max(mmax, a[i]);
	}
	if(ttake<a[node]) return false;
	if(ttake>2*a[node]) return false;
	if(mmax>a[node]) return false;
	a[node]-=(ttake-a[node]);
	if(node==fa)
		if(a[node]==0) return true;
		else return false;
	else return true;
}

signed main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	if(n==2)
	{
		if(a[1]!=a[2]) cout<<"NO";
		else cout<<"YES";
		return 0;
	}
	for(int i=1; i<n; i++)
	{
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for(int i=1; i<=n; i++)
	{
		if(adj[i].size()>1)
		{
			if(solve(i,i)) cout<<"YES";
			else cout<<"NO";
			return 0;
		}
	}
}

Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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


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

 	rep(i, 1000000) {
 		if (i * 8  / 100 == a && i  * 10 / 100 == b) {
 			cout << i << endl;
 			return 0;
 		}
 	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long[] c = new long[4];
            for (int i = 0; i < 4; ++i) c[i] = in.nextLong();
            for (int i = 0; i < 3; ++i) c[i + 1] = Math.min(c[i + 1], 2 * c[i]);
            long n = in.nextLong();
            out.println(c[3] * (n / 2) + c[2] * (n % 2));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23252
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int red = 0;
    for (char c : s) red += c == 'R';

    int ans = 0;
    for (int i = 0; i < red; i++) ans += s[i] == 'W';

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

Measured memory_bytes: 3752
# -*- coding: utf-8 -*-

# 普通のリストじゃなくてこれ使えば、左への挿入も速いとのこと
from collections import deque

N = int(input())
aN = list(map(int, input().split()))

bN = deque()
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            bN.append(str(aN[i]))
        else:
            bN.appendleft(str(aN[i]))
else:
    for i in range(N):
        if i % 2 == 1:
            bN.append(str(aN[i]))
        else:
            bN.appendleft(str(aN[i]))

print(" ".join(bN))

Measured memory_bytes: 32964
import sys
a, b, c = map(int, input().split())
var = 0
for i in range(1000):
    if a%2 != 0 or b%2 != 0 or c%2 != 0:
        print(var)
        sys.exit()
    a, b, c = b/2 + c/2, a/2 + c/2, a/2 + b/2
    var += 1
print(-1)

Measured memory_bytes: 9112
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

plus = 0

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

firstdigit = []

if a != 0:
    plus += 1
    firstdigit.append(a)
if b != 0:
    plus += 1
    firstdigit.append(b)
if c != 0:
    plus += 1
    firstdigit.append(c)
if d != 0:
    plus += 1
    firstdigit.append(d)
if e != 0:
    plus += 1
    firstdigit.append(e)
if plus > 0:
    plus -= 1

lastorder = 0
if firstdigit:
    lastorder = min(firstdigit)

sum = (A // 10) * 10 + (B // 10) * 10 + (C // 10) * 10 + (D // 10) * 10 + (E // 10) * 10 + plus * 10 + lastorder

print(int(sum))


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

using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    int counter = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                counter++;
            }
        }
    }
    if(counter == h + w - 1) {
        puts("Possible");
    } else {
        puts("Impossible");
    }
    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func input() int {
	sc.Scan()
	s := sc.Text()
	a, _ := strconv.Atoi(s)
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, k int
	n = input()
	k = input()
	arr := []int{}
	for i := 0; i < k+1; i++ {
		arr = append(arr, 0)
	}
	for i := 0; i < n; i++ {
		var s int
		s = input()
		for j := 0; j < s; j++ {
			var a int
			a = input()
			arr[a] = arr[a] + 1
		}
	}
	sum := 0
	for i := 1; i < k+1; i++ {
		if arr[i] == n {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <stdio.h>

#define MAX_PRIME	(123456 * 2)


int prime[MAX_PRIME + 1];

void make_prime(void)
{
    int i;
    int j;
    int n;
    int c;
    
    for (i = 2; i * i <= MAX_PRIME; i++){
        if (prime[i] == 0){
            for (j = i * 2; j <= MAX_PRIME; j += i){
				prime[j] = 1;
            }
        }
    }
}
	


int main(void)
{
	int n;
    int i;
	int count;
	
	make_prime();

    while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		count = 0;
		for (i = n + 1; i <= n * 2; i++){
			if (prime[i] == 0){
				count++;
			}
		}
		printf("%d\n", count);
    }
    
    return (0);
}

Measured memory_bytes: 1564
#include <bits/stdc++.h>
using namespace std;
static const int INF = 2000000000;
static const int NIL = -1;
typedef long long ll;

int main(){
    int a,b,c,d,s,e,f,g,h,t;
    scanf("%d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h);
    s = a + b + c + d;
    t = e + f + g + h;
    printf("%d\n",max(s,t));
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q);
    vector<int> r(Q);

    for(int i = 0; i < Q; i++){
        cin >> l.at(i) >> r.at(i);
    }

    vector<int> dp(N+1, 0);

    for(int i = 2; i <= N; i++)
    {
        if(S.at(i-2) == 'A' && S.at(i-1) == 'C'){
            dp.at(i) = dp.at(i-1) +1;
        }
        else dp.at(i) = dp.at(i-1);
    }
    
    int ans ;

    for(int i = 0; i < Q; i++)
    {
        ans = dp.at(r.at(i)) - dp.at(l.at(i) - 1);
        if(l.at(i) > 1 && S.at(l.at(i) - 2) == 'A' && S.at(l.at(i)-1) == 'C')ans--;

        cout << ans << endl;
    }
    
    
}

Measured memory_bytes: 2176
import math
def squared(x):
    return x**2

def theta(h, m):
    mr = 6 * m
    hr = 30 * h + m / 2
    r = abs(float(hr) - float(mr))
    return r

def length(a, b, h, m):
    return math.sqrt(squared(a) + squared(b) - 2 * a * b * math.cos(math.radians(theta(h, m))))


a, b, h, m = [x for x in map(int, input().split())]

print(length(a, b, h, m))

Measured memory_bytes: 9328
a = []
for i in range(5):
    a.append(int(input()))

b = []
c = []
for j in range(5):
    if a[j] % 10 == 0:
        c.append(10)
        b.append(a[j]-10)
    else:
        num = a[j] % 10
        c.append(num)
        b.append(a[j] - c[j])
        

b_sum = sum(b)
c_min = min(c)
c_sum = c_min + 4*10

print(b_sum + c_sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t; cin>>t;
    int ac=0, tle = 0, wa = 0, re =0;
    while(t--){
	    string s;
	    cin>>s;
	    if(s.compare("AC") == 0)
		    ac++;
            else if(s.compare("WA") == 0)
		    wa++;
	    else if(s.compare("TLE") == 0)
		    tle++;
	    else if(s.compare("RE") == 0)
		    re++;
    
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
} 


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<int, char> P;
#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N, M;
    cin >> N >> M;
    vector<P> r(M);
    int a;
    char b;
    REP(i, M){
        cin >> a;
        cin >> b;
        a--;
        r[i].first = a;
        r[i].second = b;
    }
    int s, t;
    if (N == 1){
        s = 0;
        t = 10;
    }else if (N == 2){
        s = 10;
        t = 100;
    }else{
        s = 100;
        t = 1000;
    }
    bool f = false;
    rep(i, s, t){
        f = false;
        string s = to_string(i);
        REP(j, M) if (s[r[j].first] != r[j].second) {
            f = true;
            break;
        }
        if (f) continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n % i == 0){
      ret.push_back(i);
      if(n/i != i)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
map<int, int> prime_factor(int n){
  map<int, int> ret;
  for(int i = 2;i*i <= n;i++){
    while(n % i == 0){
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1){
    ret[n] = 1;
  }
  return ret;
}
////////////////////////////////////////////////////////////////////


int n;set<int> st;
signed main(){
  cin>>n;
  vector<int> div = divisor(n-1);
  rep(i,div.size())if(div[i] != 1)st.insert(div[i]);
  div = divisor(n);
  rep(i,div.size()){
    if(div[i] == 1)continue;
    int m = n;
    while((m % div[i]) == 0){
      m /= div[i];
    }
    if(m % div[i] == 1)st.insert(div[i]);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,k;
    while(scanf("%d%d%d",&a,&b,&k)==3)
    {
        if(2*k>=(b-a+1))
        {
            for(i=a;i<=b;i++)
                printf("%d\n",i);
        }
        else
        {
            for(i=a;i<a+k;i++)
                printf("%d\n",i);
            for(i=b-k+1;i<=b;i++)
                printf("%d\n",i);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;
string s;

int main(){
  int N;
  long int ans = 0;
  cin >> N;

  char march[] = {'M','A','R','C','H'};
  long int cnt[5] ={0};

  for (int i = 0 ;i <N;i++){
    cin >> s;
    for (int j = 0;j < 5;j++){
      if(s[0] == march[j]){
        cnt[j]++;
      }
    }
  }


  for(int i = 0; i < 3;i++){
    for(int j = i+1;j < 4 ;j++){
      for(int k = j +1;k<5;k++){
        ans += cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(k<x/d) cout<<x-d*k;
    else{
        ll r=x/d,l=x/d+1;  //回数
        if(r%2==k%2) cout<<abs(x-d*r);
        else cout<<abs(x-d*l);
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
 using namespace std;
 
int main(){
     int N;
     string ans="No";
     cin>>N;
     for(int i=0;i<4 and N-7*i>=0;i++){
       ans=((N-7*i)%4==0 or ans=="Yes")?"Yes":"No";
     }
     cout << ans << endl;
 }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S;
  cin>>S;
  
  if(S.length()==1)
  {
      if(S[0]=='?')
      {
          S[0]='D';
      }
  }
  else
  {
  for(int i=0;i<S.size();++i)
  { 
      if(i==0)
      {
      if(S[i]=='?'&&i==0)
      { 
          if(S[i+1]=='P')
          {
          S[i]='D';
          }
          else
          {
              S[i]='P';
          }
      }
      }
      else
      { 
          if(S[i]=='?')
          {
          if(S[i+1]=='P')
          {
              S[i]='D';
          }
          else
          {
              S[i]='D';
          }
          }
      }
  }
  }
  
  cout<<S<<endl;
   
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main( )
{
	int k;
	cin>>k;
	char s[101];
	cin>>s;
	int l=strlen(s);
	//cout<<k<<" "<<l;
	if(l <= k){
		cout<<s<<'\n';
		return 0;
	}
	else{
		for(int i=0;i<k;i++)
	    cout<<s[i];
	}
	cout<<"..."<<"\n";
	return 0;
}

Measured memory_bytes: 3572
N,K=map(int,input().split())
x=list(map(int,input().split()))
index = 0
ans = 10**9
while index + K - 1 < N:
    start = x[index]
    end = x[index + K - 1]
    if start < 0:
        ans = min(ans,abs(end-start)+abs(start))
        ans = min(ans,abs(end-start)+abs(end))
    else:
        ans = min(ans,end)
    index += 1
print(ans)

Measured memory_bytes: 14224
def main():
    
    n,k = map(int, input().split())
    
    p_list = list(map(int, input().split()))
 
    #p_list.sort(reverse=True)
    #print(p_list)
 
    ans = 0
    if k == 1:
        p_list.sort(reverse=True)
        ans = (p_list[0]+1)*0.5
    else:
        for j in range(n-(k-1)):
            if j == 0:
                ans_tmp = 0
                for i in range(k):
                    ans_tmp += (p_list[i+j]+1)*0.5
            else:
                ans_tmp -= (p_list[(j-1)]+1)*0.5
                ans_tmp += (p_list[k+(j-1)]+1)*0.5
            
            
            if ans_tmp >= ans:
                ans = ans_tmp
 
    print(ans)
 
    
 
if __name__ == '__main__':
    main()
 

Measured memory_bytes: 25060
N,K,Q=map(int,input().split())
A = [int(input()) for i in range(Q)]

import collections
c = collections.Counter(A)
c_i=c.items()

m=[K-Q]*N
for i in c_i:
    m[i[0]-1]=m[i[0]-1]+i[1]
o=[]

for i in m:
    if i<=0:
        o.append('No')
    else:
        o.append('Yes')
print('\n'.join(o))

Measured memory_bytes: 15072
function main(input) {
    input = input.split(" ");
    console.log(Math.pow(input[0], 3));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
N, M = map(int, input().split())
a = []

for i in range(N):
    a_i = list(map(int, input().split()))
    a.append(a_i)

max_min_num = N
for _ in range(M):
    selected = {}
    for i in range(N):
        if a[i][0] in selected:
            selected[a[i][0]] += 1
        else:
            selected[a[i][0]] = 1
    max_value = 0
    target_key = 0
    for key, value in selected.items():
        if value > max_value:
            max_value = value
            target_key = key
    if max_min_num > max_value:
        max_min_num = max_value

    for i in range(N):
        a[i].remove(target_key)

print(max_min_num)

Measured memory_bytes: 4212
import java.util.*;

public class Main {
	int N;
	List<Long> a;
	long gcd;

	Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		a = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			a.add(in.nextLong());
		}
		in.close();
		gcd = a.get(0);
	}

	void calc() {
		for (int i = 1; i < a.size(); ++i) {
			gcd = gcd(a.get(i), gcd);
		}
	}

	long gcd(long x, long y) {
		if (y == 0) {
			return 0L;
		}
		if (x < y) {
			return gcd(y, x);
		}
		if (x == y) {
			return x;
		}
		long c = x % y;
		if (c == 0) {
			return y;
		}
		return gcd(y, c);
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		if (ins.gcd % 2 == 1L) {
			System.out.println("first");
		} else {
			System.out.println("second");
		}
	}
}

Measured memory_bytes: 62576
X = int(input())

import random


def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


def main(x):
    while True:
        if is_prime3(x):
            return x
        x += 1

print(main(X))


Measured memory_bytes: 4208
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let mut input = String::new();
    stdin.read_line(&mut input).ok();
    let mut ans = 0;
    for e in input.as_str().chars() {
        if e == '1' {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    using P = pair<string, int>;
    vector<P> v(n);
    rep(i,n){
        string s; int t; cin>>s>>t;
        v[i].fi = s;
        v[i].se = t;
    }
    string x; cin>>x;
    bool flg=false;
    ll ans=0;
    rep(i,n){
        if (flg) ans+=v[i].se;
        if (x==v[i].fi){
            flg = true;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int num[30];

int gcd(int a, int b){ return a?gcd(b%a,a):b; }

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

  for(int i=0;i<s.size();i++){
    num[s[i]-'a']++;
  }

  int cnt = 0, sum = 0;;
  for(int i=0;i<26;i++){
    if(num[i] & 1)cnt++;
    num[i] /= 2;
    sum += num[i];
  }

  if(cnt>1){
    cout << 0 << endl;
  }else{
    vector<int> up;
    for(int i=2;i<=sum;i++)up.push_back(i);
    
    for(int i=0;i<26;i++){
      for(int j=2;j<=num[i];j++){
	int tmp = j;
	for(int k=0;k<up.size() && tmp!=1;k++){
	  int g = gcd(tmp,up[k]);
	  tmp /= g; up[k] /= g;
	}
      }
    }
    
    long long ans = 1;
    for(int i=0;i<up.size();i++)ans *= up[i];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1208
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
s = int(input())
print(K[s-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    string s;
    cin >> s;
    if(s=="Sunny")
    {
        cout << "Cloudy" << endl;
        return 0;
    }
    else if(s=="Cloudy")
    {
        cout << "Rainy" << endl;
        return 0;
    }
    else if(s=="Rainy")
    {
        cout << "Sunny" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const int INF = INT_MAX/10;

int main()
{
	int n;
	while(cin >> n, n) {
		vi p(n+1), t(n+1);
		int ans = INF;
		FOR(i, 1, n+1) {
			cin >> p[i] >> t[i];
		}

		vvi dp(n+1, vi(3+1, INF));
		if(p[1] <= t[1]) {
			dp[1][1] = p[1];
		} else {
			cout << "NG 1" << endl;
			goto next;
		}		

		FOR(i, 2, n+1) {
			bool update = false;
			FOR(s, 1, 3+1) {
				if(dp[i-1][s] == INF) {
					continue;
				}
				int tt = t[i]-t[i-1];
				int rt = p[i-1]*(s+1) + p[i];
				if(tt < rt) {
					continue;
				} else {
					dp[i][1] = min(dp[i][1], dp[i-1][s] + p[i-1] + p[i]);
					update = true;
				}
			}

			FOR(s, 1, 2+1) {
				if(dp[i-1][s] == INF) {
					continue;
				}
				int tt = t[i] - t[i-1];
				int rt = abs(p[i]-p[i-1])*(s+1);
				if(tt < rt) {
					continue;
				} else {
					dp[i][s+1] = min(dp[i][s+1], dp[i-1][s] + abs(p[i]-p[i-1]));
					update = true;
				}
			}

			if(!update) {
				cout << "NG " << i << endl;
				goto next;
			}
		}

		FOR(i, 1, 3+1) {
			ans = min(ans, dp[n][i]);
		}
		cout << "OK " << ans+p[n] << endl;

		next:;
	}
}

Measured memory_bytes: 1220
#include<stdio.h>
#define MAX 100000
#define INFTY 1000000000
int M[100][100],d[100], Q[MAX];
int tt, n, tail=0, head=0;

int isEmpty() {
    return (head==tail);
}

int isFull() {
    return (head==(tail + 1) % MAX);
}

void enqueue(x) {
   Q[tail]=x;
   tail=(tail+1)%MAX;
}

int dequeue() {
   int x;
   head=(head+1)%MAX;
  return x;
}

void dfs(int s) {
  int i, v;
  enqueue(s);
  for(i=0; i<n; i++)
    d[i]=INFTY;
  d[s]=0;
  int u;
  while (! isEmpty()) {
    u=Q[head]; dequeue();
    for (v=0; v<n; v++) {
      if (M[u][v]==0) continue;
      if (d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      enqueue(v);
    }
  }
  for (i=0; i<n; i++) {
    printf("%d %d\n", i+1, ((d[i]==INFTY)?(-1):d[i]));
  }
}

int main() {

  int  u, k, i, j, v;

  scanf("%d", &n);

  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      M[i][j]=0;

  for (i=0; i<n; i++) {
    scanf("%d %d", &u, &k);
    u=u-1;
    for (j=0; j<k; j++) {
      scanf("%d", &v);
      v=v-1;
      M[u][v]=1;
    }
  }

  dfs(0);

  return 0;

}

Measured memory_bytes: 636
#include<cstdio>
#include<vector>
#include<algorithm>
using ll=long long;
using pii=std::pair<ll,ll>;
int main(){
    int n;
    scanf("%d",&n);
    std::vector<pii> vp;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        vp.push_back({a,b});
    }
    std::sort(vp.begin(),vp.end(),[](pii a,pii b)->bool{return a.second<b.second;});
    ll asum=0;
    for(int i=0;i<n;i++){
        ll a=vp[i].first, b=vp[i].second;
        asum+=a;
        if(asum>b){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

int n, a[100000], color, chain[100000], cnt, maxn, recently;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	color = a[0]; cnt = 0; chain[0] = 1;
	for (int i = 1; i < n; i++) {
		if (color == a[i]) {
			cnt++;
			recently = i;
		}
		color = a[i];
		chain[cnt]++;
	}
	cnt++;
	if (cnt == 1) { maxn = n; }
	if (cnt == 2) { maxn = n; }
	for (int i = 0; i < cnt - 2; i++) {
		maxn = max(maxn, chain[i] + chain[i + 1] + chain[i + 2]);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 1748
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int k = 0;

        for(int i =0;i<s.length;i++) {
        	if(s[i] == t[i]) {
        		k++;
        	}
        }
        System.out.println(k);

    }

	private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 22736