akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		for(int i=1;i<N-1;i++){
			if(P[i] < P[i+1] && P[i-1] < P[i]) cnt++;
			if(P[i] > P[i+1] && P[i-1] > P[i]) cnt++;
		}
		Console.WriteLine(cnt);
		
	}
	int N;
	int[] P;
	public Sol(){
		N = ri();
		P = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr ll mod = 1000000007;

int N;
std::string S1, S2;
std::vector<bool> xy;
ll ret = 1;

int main()
{
  std::cin >> N >> S1 >> S2;

  int p = 0;

  while( p < N )
  {
    if( S1[p] != S2[p] )
      xy.push_back( false ), p += 2; // y
    else
      xy.push_back( true ), ++p; // x
  }

  ret = xy[0]?3:6;

  rep( i, xy.size()-1 )
  {
    if( xy[i] && xy[i+1] )
      ret = (ret*2) % mod;
    else if( xy[i] && !xy[i+1] )
      ret = (ret*2) % mod;
    else if( !xy[i] && !xy[i+1] )
      ret = (ret*3) % mod;
  }

  printf( "%lld\n", ret );

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ret = min(A, K);
  ret -= max(0LL, K-A-B);
  cout << ret << endl;
}

Measured memory_bytes: 3644
#include <iostream>


using namespace std;

int main()	{
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if (a + b == c || b + c == a || c + a == b)	{
  	cout << "Yes\n";
  }
  else	{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  string s; cin >> s;
  if ((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int LL;
LL base[25];

LL check(LL a,int n,int k){
	if(n==0){
		if(a==0)return 10;
		else return 0;
	}
	if(n<0){
		if(a==0)return 1;
		else return 0;
	}
	LL b,c,d;
	LL t;
	t=base[n];
	for(int i=0;i<k;i++)t*=10;
	b=(a+t*15)/t-15;
	c=0;
	if(-9<=b && b<=9){
		d=10-abs(b);
		if(k==0 && b>=0)d--;
		c=check(a-b*t,n-2,k+1)*d;
	}
	if(-9<=b+1 && b+1<=9){
		d=10-abs(b+1);
		if(k==0 && b+1>=0)d--;
		c+=check(a-(b+1)*t,n-2,k+1)*d;
	}
	return c;
}

int main(){
	LL a,b,c;
	LL s=0;
	int i,j,k;
	for(i=1,a=1;i<=20;i++){
		a*=10;
		base[i]=a-1;
	}
	cin>>a;
	for(i=20;i>0;i--){
		s+=check(a,i,0);
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int hole[] = new int[m+2];
    hole[0] =-1;
    hole[m+1] = n+1;
    long L = 1000000007;
    for(int i=1;i<=m;i++){
      hole[i]=sc.nextInt();
    }
    long fib[] = new long[n+2];
    fib[0]=0;
    fib[1]=1;
    fib[2]=1;
    for(int i=3;i<n+2;i++){
      fib[i]=(fib[i-1]+fib[i-2])%L;
    }
    long answer =1;
    
    for(int i=0;i<=m;i++){
      answer = (answer*fib[hole[i+1]-hole[i]-1])%L;
    }
    System.out.println(answer);
    
    
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

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

int main(){
  string S;
  cin >> S;
  
  int L = S.size();
  string answer = "Yes";
  
  if (L % 2 == 0){
    for (int i = 0; i < L / 2; i++){
      if (S.at(2 * i) != 'h' || S.at(2 * i + 1) != 'i'){
        answer = "No";
        break;
      }
    }
  }
  else{
    answer = "No";
  }
  
    
  cout << answer << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, cnt, ite, ans = 0, k;
    cin >> n;
    k = sqrt(n);
    for( ll i=2;i<=k;i++){
        cnt = 0;
        ite = 1;
        while( n%i == 0){
            n /= i;
            cnt++;
        }

        while(cnt>=ite){
            ans++;
            cnt -= ite;
            ite++;
        }

    }

    if( n>1) ans++;
    cout << ans;

    return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int            long long int



int dp[3001][3001];
int f(int i, int j, int a[]) {
	if (dp[i][j] != -1)
		return dp[i][j];
	if (i == j)
		return a[i];
	int taro = INT_MIN;
	int jiro = INT_MAX;
	taro = max(a[i] + f(i + 1, j, a) - jiro, a[j] + f(i, j - 1, a) - jiro);

	jiro = min(taro - a[i] + f(i + 1, j, a), taro - a[j] + f(i, j - 1, a));
	return dp[i][j] = taro - jiro;

}

int32_t main() {
	//c_p_c();
	memset(dp, -1, sizeof(dp));
	int t;
	cin >> t;
	int a[t];
	for (int i = 0; i < t; i++) {

		cin >> a[i];

	}
	cout << f(0, t - 1, a);
}



Measured memory_bytes: 74256
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int n;	scanf("%d ",&n);
	while(n--){
		int a[8];
		for(int i=0;i<8;i++)	a[i]=getchar()-'0';
		getchar();
		sort(a,a+8);
		int vmin=0,vmax=0;
		for(int i=0;i<8;i++){
			vmin=vmin*10+a[i];
			vmax=vmax*10+a[7-i];
		}
		printf("%d\n",vmax-vmin);
	}

	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import numpy as np
N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
diff = np.diff(X)
ans = 0
for d in diff:
    if d * A <= B:
        ans += d * A
    else:
        ans += B
print(ans)

Measured memory_bytes: 23120
#include<stdio.h>
int main()
{
    char b;
    scanf("%c", &b);
    if(b=='A'){
        printf("T\n");
    }
    else if(b=='T'){
        printf("A\n");
    }
    else if(b=='C'){
        printf("G\n");
    }
    else if(b=='G'){
        printf("C\n");
    }
    return 0;
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int h, w, k;
    cin >> h >> w >> k;
    if (w == 1) {
        dump(1);
        return 0;
    }
    vector<Int> d(w, 0);
    d[0] = 1;
    for (Int i = 0; i < h; i++) {
        vector<Int> e(w, 0);
        for (Int bit = 0; bit < (1<<(w - 1)); bit++) {
            bool check = true;
            for (Int j = 0; j < w - 2; j++) {
                if ((bit>>j) & (bit>>(j + 1))) {
                    check = false;
                }
            }
            if (not check) continue;
            if (bit & 1) {
                e[1] += d[0];
                e[1] %= mod;
            }
            else {
                e[0] += d[0];
                e[0] %= mod;
            }
            if (bit & (1<<(w - 2))) {
                e[w - 2] += d[w - 1];
                e[w - 2] %= mod;
            }
            else {
                e[w - 1] += d[w- 1];
                e[w - 1] %= mod;
            }
            for (Int j = 1; j <= w - 2; j++) {
                if (bit & (1<<(j - 1))) {
                    e[j - 1] += d[j];
                    e[j - 1] %= mod;
                }
                else if (bit & (1<<j)) {
                    e[j + 1] += d[j];
                    e[j + 1] %= mod;
                }
                else {
                    e[j] += d[j];
                    e[j] %= mod;
                }
            }
            // for (Int j = 0; j < w; j++) {
            //     cout << e[j] << " ";
            // }
            // cout << endl;
        }
        for (Int j = 0; j < w; j++) {
                d[j] = e[j];
        }
    }
    dump(d[k - 1]);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int minb = 0;
		for(int b=0; b<=200000; b+=2) {
			int a=Math.max(X-b/2, 0);
			int c = Math.max(Y-b/2, 0);
			if(X<=a+b/2&&Y<=b/2+c) {
				min = Math.min(min, A*a+C*b+B*c);
			}
		}
		System.out.println(min);
//		System.out.println(minb);
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int n,m;
        cin>>n>>m;

        ll height[n+1];
        height[0]=-1;

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

        int ans=0;

        bool chk[n+1];

        for( int i=0 ; i<=n ; i++ )
            chk[i]=1;

        for( int i=0 ; i<m ; i++ )
        {
            int a,b;

            cin>>a>>b;

            if( height[a]>height[b] )
                chk[b]=0;
            else if( height[b]>height[a] )
                chk[a]=0;
            else
                chk[a]=chk[b]=0;
        }



        for( int i=1 ; i<=n ; i++ )
        {
            if(chk[i])
                ans++;
        }

        cout<<ans;
    }
    return 0;
}












Measured memory_bytes: 4500
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int A, B, T;
  cin >> A >> B >> T;

  int ans = 0;
  for(int i = A; i < T+1; i+=A){
    ans += B;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long V = sc.nextLong();
        long B = sc.nextLong();
        long W = sc.nextLong();
        long T = sc.nextLong();
        
        long sa = V-W;
        long kyori = Math.abs(A-B);
        
        if(sa*T>=kyori){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 35540
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
const int INF=2147483647;
const ll mod=1e9+7;
inline int read()
{
	int x=0,k=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*k;
}
ll dp[42][(1<<19)+3],ans;
int N,X,Y,Z;
int main()
{
	N=read(),X=read(),Y=read(),Z=read();
	int st=((1<<(X+Y+Z-1))|(1<<(Y+Z-1))|(1<<(Z-1)));
	dp[0][0]=1;
	ans=1ll;
	rep(i,1,N)
	{
		ans=ans*10%mod;
		rep(S,0,(1<<(X+Y+Z))-1)
		{
			if(dp[i-1][S])
			rep(c,1,10)
			{
				int now=((S<<c)|(1<<(c-1)));
				now&=((1<<(X+Y+Z))-1);
				if((now&st)!=st)dp[i][now]=(dp[i][now]+dp[i-1][S])%mod;
			}
		}
	}
	rep(S,0,(1<<(X+Y+Z))-1)
	ans=(ans-dp[N][S]+mod)%mod;
	printf("%lld",ans);
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char c;
	cin >> c;
	if(c == 'A') {
		cout << 'T' << endl;
	} else if (c == 'T') {
		cout << 'A' << endl;
	} else if (c == 'G') {
		cout << 'C' << endl;
	} else {
		cout << 'G' << endl;
	}
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    for(ll h = 1; h <= 3500; h++ ){
    for(ll n = 1; n <= 3500; n++ ){
        ll denom_w = 4*h*n - N*n - N*h;
        ll numer_w = N*h*n;
        if( denom_w <= 0 ){
            continue;
        }
        if( numer_w % denom_w != 0 ){
            continue;
        }

        //DEBUG("numer=%lld denom=%lld", numer_w, denom_w);

        cout << h << " " << n << " " << (numer_w/denom_w) << endl;
        return 0;
    }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll l[87];
	l[0] = 2LL;
	l[1] = 1LL;
	for (int i = 2; i <= n; i++) l[i] = l[i - 2] + l[i - 1];
	cout << l[n] << endl;
	return 0;
}

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

const int MOD = 1e9 + 7;

void add(int &a, int b)
{
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string k;
	cin >> k;
	int d;
	cin >> d;

	vector<vector<int>> dp(d, vector<int>(2));
	dp[0][0] = 1;
	for (int digit = 0; digit < k.size(); digit++)
	{
		vector<vector<int>> new_dp(d, vector<int>(2));
		for (int sum = 0; sum < d; sum++)
		{
			for (bool smaller_already : {true, false})
			{
				for (int new_digit = 0; new_digit < 10; new_digit++)
				{
					if (new_digit > k[digit] - '0' && !smaller_already)
						break;
					add(new_dp[(sum + new_digit) % d][smaller_already || new_digit < k[digit] - '0'], dp[sum][smaller_already]);
				}
			}
		}
		dp = new_dp;
	}
	cout << (dp[0][true] + dp[0][false] + MOD - 1) % MOD << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string toString(int n)
{
	string str;
	stringstream ss;
	ss << n;
	ss >> str;
	return str;
}
string toNegativeBase(int n, int negBase)
{
	if (n == 0)
		return "0";

	string converted = "";
	while (n != 0)
	{
		int remainder = n % negBase;
		n /= negBase;
		if (remainder < 0)
		{
			remainder += (-negBase);
			n += 1;
		}
		converted = toString(remainder) + converted;
	}

	return converted;
}
int main()
{
    int n;
	cin>>n;
	int negBase = -2;
    cout << toNegativeBase(n, negBase);
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0") break;
            var q1 = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var c1 = int.Parse(line[2]);
            var c2 = int.Parse(line[3]);
            var q2 = int.Parse(line[4]);
            var ac = 0; var nc = 0;
            var maxac = Math.Min(b / c1, q2);
            for (int i = maxac; i >= 1; i--)
            {
                var t = b - c1 * i;
                nc = t / c2;
                if (t >= 0 && i + nc >= q1) { ac = i; break; }
            }
            if (ac == 0) Console.WriteLine("NA");
            else Console.WriteLine("{0} {1}", ac, nc);
        }
    }
}

Measured memory_bytes: 9044
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
    int num;
    int num_;
    int score;
    string s;
}x[110];
int cmp(node a,node b)
{
    if(a.s==b.s) return a.score>b.score;
    return a.s<b.s;
}
int cmp_(node a,node b)
{
    return a.num<b.num;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>x[i].s>>x[i].score;
        x[i].num=i+1;
    }
    sort(x,x+n,cmp);
    for(int i=0;i<n;i++)
    {
        x[i].num_=i+1;
    }
//    sort(x,x+n,cmp_);
    for(int i=0;i<n;i++)
    {
        printf("%d\n",x[i].num);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, k, l[50];
	cin >> n >> k;
	REP(i, n) cin >> l[i];

	sort(l, l+n);

	int sum = 0;
	for(int i = 1;i <= k;i++) sum += l[n-i];
	cout << sum << endl;
	rtn 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

struct vec {
	ll x, y;
	vec(ll x, ll y) :x(x), y(y) {}
	vec() :x(0), y(0) {}
	ll prod(vec v) const {
		return x * v.x + y * v.y;
	}
	long double abs() const {
		return sqrtl( x * x + y * y);
	}
	vec operator+(const vec v) const {
		return vec(x + v.x, y + v.y);
	}
	ll operator*(const vec v) const {
		return prod(v);
	}
	vec& operator+=(const vec v) {
		(*this) = (*this) + v;
		return *this;
	}
	double rad() const {
		return atan2<double>(y, x);
	}
	bool operator<(const vec& v) const {
		return rad() < v.rad();
	}
};

int main() {
	IOS;
	int n;
	cin >> n;
	vector<ll> x(n), y(n);
	vector<vec> p(n);
	REP(i, n) {
		cin >> x[i] >> y[i];
		p[i] = vec(x[i], y[i]);
	}
	sort(all(p));
	long double res = 0;
	REP(i, n) {
		vec tmp = p[i];
		REP(j, n) {
			if (i != j) {
				ll t1 = p[i] * p[j];
				if (t1 >= 0) {
					tmp += p[j];
				}
			}
		}
		chmax(res, tmp.abs());
	}
	random_device seed_gen;
	mt19937 engine(seed_gen());
	REP(k, 1000000) {
		ll x = 0, y = 0;
		while (x == 0 && y == 0) {
			x = engine() % 2000000 - 1000000;
			y = engine() % 2000000 - 1000000;
		}
		vec tmp, t2(x, y);
		REP(i, n) {
			ll t1 = p[i] * t2;
			if (t1 >= 0) {
				tmp += p[i];
			}
		}
		chmax(res, tmp.abs());
	}
	cout << setprecision(30) << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;  // no of  players
  cin>>n;
 
  int k;    // intial score
  int q;  //no of questions
  cin>>k>>q;
    vector<int> scores(n,k-q);
  for(int i=0;i<q;i++)
  {
    int a;
    cin>>a;
    scores[a-1]+=1;
  }
  for(int i=0;i<n;i++)
  {
    if(scores[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
def signature(word)
  word.chars.sort.join.intern
end

n = gets.chomp.to_i

res = 0
graph = {}
(1..n).each do
  s = gets.chomp
  sig = signature s
  if graph[sig].nil?
    graph[sig] = 0
  else
    res += graph[sig]
  end
  graph[sig] += 1
end

puts res


Measured memory_bytes: 36476
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  int N, X;
  cin >> N >> X;
  int m[100];
  int ans = N;
  rep(i, N){
    cin >> m[i];
    X -= m[i];
  }
  sort(m, m + N);
  ans += X / m[0];
  cout << (ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n;
  cin>>n;
  vin a(n);
  rep(i,n) cin>>a[i];
  ////gcdやろ
  int g=__gcd(a[0],a[1]);
  rep(i,n-1){
    g=__gcd(g,a[i+1]);
  }
  cout<<g<<endl;
}

Measured memory_bytes: 640
//基本的に a_i が高い刀で"振る"
//投げつけ合計 >= 残りH の場合に投げつけ でOK


import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int   N = sc.nextInt();
		int   H = sc.nextInt();

		int[] a = new int[N];
		int[] b = new int[N];
		
		for(int i = 0 ; i < N ; i ++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		int attackCount = 0;
		int RemainderH = H;
		
		//"振る"威力が最大である刀の威力を検索
		
		IntStream  streamA = Arrays.stream(a);
		IntStream  streamB = Arrays.stream(b);
		
		int MaxA = streamA.max().getAsInt();
		
		int SumB = streamB.filter(n -> n >= MaxA ).reduce(0,(x,y) -> x+y);
		Arrays.sort(b);  //【注意】 配列b が昇順に変更になる
		int thrownCount = 0;
		
		while(RemainderH > 0){
			if(RemainderH <= SumB){
				RemainderH = RemainderH - b[ N - 1 -thrownCount];
				thrownCount++;
				attackCount++;
			}else{
				RemainderH = RemainderH - MaxA ;
				attackCount++;
			}
		}
		
		System.out.println(attackCount);
	}
}


Measured memory_bytes: 86388
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll n,l;
  	cin>>n>>l;
  	if((l>=n*2&&l<=n*4)&&(l%2==0)){
      cout<<"Yes";
    }
	else{
      cout<<"No";
    }
}

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

int n;
int a[10], b[10];

int dfs(int p)
{
	if (p == n) return 0;
	int d = (b[p] - a[p] + 10) % 10;
	if (d == 0) return dfs(p + 1);
	int res = 1e9;
	for (int i = p; i < n; i++){
		for (int j = p; j <= i; j++){
			a[j] = (a[j] + d) % 10;
		}
		res = min(res, 1 + dfs(p + 1));
		for (int j = p; j <= i; j++){
			a[j] = (a[j] - d + 10) % 10;
		}
	}
	return res;
}

int main()
{
	while (cin >> n, n){
		string s, t;
		cin >> s >> t;
		for (int i = 0; i < n; i++){
			a[i] = s[i] - '0';
			b[i] = t[i] - '0';
		}
		cout << dfs(0) << endl;
	}
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    
    
    int H, W;
    cin >> H >> W;
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    
    int c[H][W];
    
    pii cnt = {0, 0};
    pii now = {0, 0};
    int key = 0;
    rep(i, H * W) {
        c[now.F][now.S] = cnt.F + 1;
        cnt.S++;
        if (cnt.S == a[cnt.F]) {
            cnt.F++;
            cnt.S = 0;
        }
        
        if (key == 0) now.F++;
        else now.F--;
        
        if (now.F < 0 || now.F >= H) {
            if (now.F < 0) now.F = 0;
            else if (now.F == H) now.F = H - 1;
            now.S++;
            key ^= 1;
        }
        
        // out(now.F << " " << now.S);
    }
    
    rep(i, H) { rep(j, W) { if (j) cout << " "; cout << c[i][j]; } cout << endl; }
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);
 
int main(){
    ll a,b1,b2,b100;
    scanf("%lld %lld.%lld",&a,&b1,&b2);
    b100=b1*100+b2;
    cout<<(ll)a*b100/100<<endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  rep(i, n-1) {
    if ((abs(x[i])+abs(y[i]))%2 != (abs(x[i+1])+abs(y[i+1]))%2) {
      cout << -1 << endl;
      return 0;
    }
  }
  int mx = 0;
  rep(i, n) chmax(mx, abs(x[i])+abs(y[i]));
  vector<int> arms;
  ll p = 1;
  while (p <= mx) {
    arms.push_back(p);
    p <<= 1;
  }
  reverse(arms.begin(), arms.end());
  if (!((abs(x[0])+abs(y[0]))%2))
    arms.push_back(1);
  cout << arms.size() << endl;
  rep(i, arms.size())
    cout << arms[i] << (i+1<arms.size()?' ':'\n');
  rep(i, n) {
    ll cx = 0, cy = 0;
    rep(j, arms.size()) {
      ll mn = 1e18, d;
      rep(k, 4) { //(0, 1, 2, 3) == (U, R, D, L)
        ll nx = cx, ny = cy;
        switch (k) {
          case 0 : ny += arms[j]; break;
          case 1 : nx += arms[j]; break;
          case 2 : ny -= arms[j]; break;
          case 3 : nx -= arms[j]; break;
        }
        ll dist = abs(x[i]-nx)+abs(y[i]-ny);
        if (chmin(mn, dist))
          d = k;
      }
      switch (d) {
        case 0 : cy += arms[j]; cout << 'U'; break;
        case 1 : cx += arms[j]; cout << 'R'; break;
        case 2 : cy -= arms[j]; cout << 'D'; break;
        case 3 : cx -= arms[j]; cout << 'L'; break;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    for (int i = A; i < T + 1; i += A)
    {
        ans += B;
    }

    cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m;
struct node{
    int a,b;
}e[N];
bool cmp(node x,node y){
    return x.a<y.a;
}
bool operator < (node x,node y){
    return x.b<y.b;
}
priority_queue<node>q;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&e[i].a,&e[i].b);
    }
    sort(e+1,e+1+n,cmp);
    int ans=0;
    int p=1;
    for(int i=m;i>=1;i--){
        while(p<=n&&e[p].a+i-1<=m)q.push(e[p]),p++;
        if(!q.empty())ans+=q.top().b,q.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2168
loop do
    n = gets.to_i
    break if n == 0
    data = Hash.new(Array.new)
    n.times do
        s = gets.chomp.split
        time = s[1].split(/:/)
        data[s[0]] += [[time[0].to_i * 60 + time[1].to_i, s[2],s[3]]]
    end
    ret = Hash.new(0)
    data.each do |k,v|
        gd_presence = Array.new
        v.select{|vs| vs[2] == "000"}.each_slice(2) do |gd|
            gd_presence.push([gd[0][0],gd[1][0]])
        end
        io = Hash.new(Array.new)
        v.select{|vs| vs[2] != "000"}.each do |pg|
            io[pg[2]] += [pg[0]]
        end
        io.each do |pg|
            total = 0
            pg[1].each_slice(2) do |time|
                gd_presence.each do |gdp|
                    ret[pg[0]] += [0,[time[1],gdp[1]].min-[time[0],gdp[0]].max].max
                end
            end
        end
    end
    output = ret.map{|a| a[1]}.max
    p output ? output : 0
end

Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int n,flag=0,min;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    min=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[min])min=j;
      if(j==n-1&&i!=min){
	swap(a[i],a[min]);
	flag++;
      }
    }
    if(i==n-1)cout<<a[i]<<endl;
    else cout<<a[i]<<" ";
  }
  cout<<flag<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll k;
vector<int> f;
long long dp[5000][8];
vector<long long> grand;

signed main()
{
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for (int i = 0; i < 650; i++)
    {
        f.push_back(0);
        f.push_back(1);
        f.push_back(2);
        f.push_back(3);
        f.push_back(4);
        f.push_back(5);
        f.push_back(6);
    }
    dp[0][0] = 1;
    for (int i = 1; i < f.size(); i++)
    {
        for (int j = 0; j < 8; j++)
        {
            dp[i][j] = dp[i - 1][j];
        }
        if (f[i] == 0) dp[i][0]++;
        else dp[i][f[i]] += dp[i - 1][f[i] - 1];
    }
    /*for (int i = 6; i < f.size(); i += 7)
    {
        cout << dp[i][6] << endl;
    }
    cout << f.size() << endl;
    cout << (ll)(1e18) / dp[f.size() - 1][6] << endl;*/
    long long k;
    cin >> k;
    for (int i = f.size() - 1; i >= 6; i-= 7)
    {
        grand.push_back(k / dp[i][6]);
        k %= dp[i][6];
    }
    reverse(all(grand));
    int t = 0;
    for (int i = 6; i < f.size(); i += 7)
    {
        cout << "FESTIVA";
        for (int j = 0; j < grand[t]; j++)
        {
            cout << "L";
        }
        t++;
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<sstream>
#include<utility>
using namespace std;
pair<int,string> f(string s){
stringstream ss(s);
int n;string res;
ss>>n>>res;
return make_pair(n,res);
}
int main(){
string s;
int ans = 0;
while(cin>>s){
while(true){
while((s[0]<'0'||'9'<s[0]) && s.size()!=0)s=s.substr(1);
if(s.size()==0)break;
pair<int,string> tmp;
tmp= f(s);
ans += tmp.first;
s = tmp.second;
}
}
cout<<ans<<endl;
}

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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick ()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int diva (int n)
{
    int counter = 0;
    for (int i = 1 ; i <= n ; i++)
    {
        if (n%i==0)
            counter++;
    }
    return counter;
}

void readFromText()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    string s ; cin >> s; string out = "";
    for (int i =0 ; i < s.length () ; i++){
        if (s[i]!='B'){
            out+=s[i];
        }else if (out.length()>0){
            out = out.substr(0,out.length()-1);
        }
//        cout << out << endl ;
    }
    cout << out << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[])
{
    int n;
    cin>>n;
    if(n==7||n==3||n==5)
        cout<<"YES"<<endl;
    else 
        cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	vector<string> s(n); VI t(n);
	REP(i, n)cin >> s[i] >> t[i];
	string x; cin >> x;
	ll ans = 0; bool flag = false;
	REP(i, n) {
		if (flag)
			ans += t[i];
		if (s[i] == x)
			flag = 1;
	}
	cout << ans;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

int N, K;

int main() {
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    ll cnt = 0;
    REP(i, N) {
        if ((A[i] + cnt) % B[i])
            cnt += B[i] * ((A[i] + cnt) / B[i] + 1) - (A[i] + cnt);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
//#include "stdafx.h"
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
//
int main() {
    while (1) {
        ll N, M;
        cin >> N;
        if (N == 0) {
            break;
        }
        cin >> M;
        string S;
        cin >> S;
        ll now = 0;
        ll ans = 0;
        ll cnt = 1;
        while (now < M) {
            if (S[now] == 'I'&&S[now + 1] == 'O'&&S[now + 2] == 'I') {
                cnt+=2;
                now += 2;
            }
            else {
                if (cnt >= N*2+1) {
                    ans += (cnt-1)/2 - N + 1;
                }
                cnt = 1;
                now++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3892
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
int main(){
	int n , m;
	cin>>n>>m;
	int cnt=0;
	int d=0;
	while(d<n){
		cnt++;
		d=d+2*m+1;
	}
	cout<<cnt;

}

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

bool data[31];

int main(){
	for(int i=0;i<31;i++)data[i]=true;
	for(int i=0;i<28;i++){
		int x;
		cin>>x;
		data[x]=false;
	}
	for(int i=1;i<31;i++)if(data[i])cout<<i<<endl;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){
  long long a,b,c,k;
  long long a_k, b_k, c_k;
  long long x, y, z;
  cin >> a>>b>>c>>k;
  if (a-b > 1000000000000000000 || a-b < -1000000000000000000) {
    cout << "Unfair" << endl;
    return(0);
  }
  if (k%2==0) {
      cout << a-b<< endl;
  } else {
    cout << b-a << endl;
  }
  return(0);
}


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

int main() {
	int n, i = 1;
  	long long power = 1;
	cin >> n;
	while (i <= n) {
	    power = power * i;
	    if (power >= 1000000007) power = power % 1000000007;
	    i++;
	}
	cout << power;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i,n){ cin >> v[i]; }
  sort(v.rbegin(),v.rend());

  ld ans=0;
  rep(i,a){ ans+=v[i]; }
  ans/=a;
  cout << fixed << setprecision(10) << ans << endl;
  
  int cntin=0,cntout=0;
  rep(i,n){
    if(v[i]==v[a-1]){
      if(i<a){cntin++;}else{cntout++;}
    }
  }
  ll ansc=1;
  if(cntin!=a){
    rep(i,cntin){ ansc=ansc*(cntin+cntout-i)/(i+1); }
  }else{
    ll tmp=1;
    n=cntin+cntout;
    rep(i,a){ tmp=tmp*(n-i)/(i+1); }
    ansc=tmp;
    for(int i=a+1; i<=min(b,n); i++){
      tmp = tmp*(n-i+1)/i;
      ansc+=tmp;
    }
  }
  cout << ansc << endl;
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int N = 0;
    cin >> N;
    string t = s;
    bool flip = false;
    deque<char> q;
    for (char c : s) { q.push_back(c); }
    rep(i, N)
    {
        int ty = 0;
        cin >> ty;
        if (ty == 1)
        {
            flip = !flip;
        }
        else if (ty == 2)
        {
            int f;
            char c;
            cin >> f >> c;
            if (flip) { f = 3 - f; }
            if (f == 1) { q.push_front(c); }
            else if (f == 2) { q.push_back(c); }
        }
    }
    if (flip) { reverse(q.begin(), q.end()); }
    string ans;
    for (char c : q) { ans += c; }
    cout << ans << endl;
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];

  ll x = 0, y = 0;
  for (ll i = 0; i < n; i++) x += a[i];

  vll ans(0);
  for (ll i = 0; i < n - 1; i++) {
    x -= a[n - 1 - i];
    y += a[n - 1 - i];
    ans.push_back(max(x - y, y - x));
  }
  sort(all(ans));
  cout << ans[0] << endl;
}

Measured memory_bytes: 3956
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

a, b, x = na()
s = x/a
tri = a*b/2
if tri <= s:
    si = a * b - s
    print(math.degrees(math.atan(2 * si/a**2)))
else:
    print(90.0 - math.degrees(math.atan(2 * s/b**2)))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
H_new = {int(input()):1} # 体力:匹数
ans = 0

while True:
    X = H_new
    H_new = {}
    for k, v in X.items():
        if k == 1:
            ans += v
        else:
            ans += v
            h = int(k//2)
            if h in H_new:
                H_new[h] = H_new[h]+v*2
            else:
                H_new[h] = v*2
    if len(H_new) == 0:
        break
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>


int main(void){
    int i,j,c = 0;
    char str[30];
    
    scanf("%s",str);
    
    int length = strlen(str);
    
    for( i = 0; i < length; i++ ){
        for(j = i + 1; j < length; j++){
            if(str[i] == str[j]){
                c = 1;
                break;
            }
        }
    }
    
    if( c == 0 ){
        printf("yes");
    }
    else printf("no");
    
    
     return 0;
}

Measured memory_bytes: 128