akhauriyash/Code-Regression huggingface dataset:
n = int(input())
t = list(map(int,input().split()))
t_tm = t
m = int(input())

for i in range(m):
    p,x = map(int,input().split())
    tmp = t[p-1]
    t[p-1] = x
    print(sum(t))
    t[p-1] = tmp

Measured memory_bytes: 9144
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "math/modulo.h"

template<class T, T M>
struct modulo {
	T n;
	modulo(T n): n(n<0? n%M+M: n%M)   { }
	operator T() const                { return n;             }
	modulo operator-() const          { return modulo(-n);    }
	modulo operator+(const modulo &o) const { return modulo(n+o.n); }
	modulo operator-(const modulo &o) const { return modulo(n-o.n); }
	modulo operator*(const modulo &o) const { return modulo(n*o.n); }
	bool  operator< (const modulo &o) const { return n< o.n; }
	bool  operator<=(const modulo &o) const { return n<=o.n; }
	bool  operator> (const modulo &o) const { return n> o.n; }
	bool  operator>=(const modulo &o) const { return n>=o.n; }
	bool  operator==(const modulo &o) const { return n==o.n; }
	bool  operator!=(const modulo &o) const { return n!=o.n; }

	modulo pow(T n) const {
		modulo y = 1, x = *this;
		while (n) {
			if (n%2) y = y * x;
			n /= 2;
			x = x * x;
		}
		/*
		if (n==0) return 1;
		modulo y = pow(n/2);
		y = y*y;
		if (n%2) y = y * (*this);
		*/
		return y;
	}
	modulo inv() const {
		return pow(M-2);
	}
	modulo operator/(const modulo &o) const {
		return (*this) * o.inv();
	}

	T gcd_ext(T a, T b, T *x, T *y) {
		if (a == 0) {
			*x = 0;
			*y = 1;
			return b;
		}
		T x1, y1;
		T gcd = gcd_ext(b%a, a, &x1, &y1);
		*x = y1 - (b/a) * x1;
		*y = x1;
		return gcd;
	}
	modulo div(const modulo &o) const {
		T x, y;
		T g = gcd_ext(o.n, M, &x, &y);
		if (g != 1) return 0;
		else return modulo(n * (x % M));
	}

	friend ostream &operator<<(ostream &os, const modulo &x) {
		return os << x.n;
	}
};

typedef modulo<long,998244353> T;
//#include "math/comb.h"

void comb_inc_k(T &r, int n, int &k) {
        //C(n,k+1) = C(n,k) * (n-k) / (k+1)
	r = r * T(n-k) / T(k+1);
	k++;
}

void comb_dec_k(T &r, int n, int &k) {
        //C(n,k-1) = C(n,k) * k / (n-k+1)
	r = r * T(k) / T(n-k+1);
	k--;
}

void comb_inc_n(T &r, int &n, int k) {
        //C(n+1,k) = C(n,k) * (n+1) / (n+1-k)
	r = r * T(n+1) / T(n+1-k);
	n++;
}

void comb_dec_n(T &r, int &n, int k) {
        //C(n-1,k) = C(n,k) * (n-k) / n
	r = r * T(n-k) / T(n);
	n--;
}

T comb(int n, int k) {
    if (k*2 > n) k = n-k;
    if (n==0) return 0;
    T r = 1; //C(n,0)
    int i = 0;
    while (i<k) comb_inc_k(r, n, i);
    return r;
}


#define MAXN 100000

int n;


int input() {
	if (scanf("%d", &n) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	T r = T(3).pow(n);
	int k = n/2;
	T e = comb(n, k);
	while (k+1<=n) {
		comb_inc_k(e, n, k);
		r = r - e*T(2).pow(n-k+1);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];

int main() {
	ll n;
	cin>>n;
	ll r=n-1;
	for(ll i=2;i<1000001;++i){
		if(n%i==0){
			r=min(r,i+(n/i)-2);
		}
	}
	cout<<r<<endl;
	return 0;
}


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

#define int ll

const int mod = 1e9 + 7;

template <int Modulus>
struct modint {
    ll x;  // typedef long long ll;
    modint(ll x = 0) : x((x % mod + mod) % mod) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint pow(ll t) const {
        if (!t) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    modint inv() const { return pow(mod - 2); }
    modint& operator/=(const modint a) { return *this *= a.inv(); }
    modint operator/(const modint a) const { return modint(*this) /= a; }
};
template <int Modulus>
istream& operator>>(istream& is, modint<Modulus>& a) {
    return is >> a.x;
}
template <int Modulus>
ostream& operator<<(ostream& os, const modint<Modulus>& a) {
    return os << a.x;
}

using mint = modint<mod>;

signed main() {
    ll n, k;
    bool an = true;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll& i : a) {
        cin >> i;
        if (i >= 0) an = false;
    }
    if (an && k % 2 || n == k) {
        sort(a.begin(), a.end(), greater<>());
        mint r = 1;
        for (int i = 0; i < k; ++i) r *= a[i];
        cout << r;
        return 0;
    }
    sort(a.begin(), a.end(), [](ll l, ll r) { return abs(l) > abs(r); });
    vector<ll> pos, neg;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= 0)
            pos.push_back(a[i]);
        else
            neg.push_back(-a[i]);
    }
    int sp = 0, sn = 0, tk = k;
    mint r = 1;
    for (int i = 0; i < n && tk > 0; ++i) {
        if (tk <= 1) {
            if (pos.size() - sp >= 1)
                r *= pos[sp++], --tk;
            else
                break;
        }
        else if (neg.size() - sn <= 1)
            r *= pos[sp++], --tk;
        else if (pos.size() - sp == 0) {
            r *= neg[sn++];
            --tk;
            r *= neg[sn++];
            --tk;
        }
        else {
            if (pos[sp] * pos[sp + 1] >= neg[sn] * neg[sn + 1])
                r *= pos[sp++], --tk;
            else {
                r *= neg[sn++];
                --tk;
                r *= neg[sn++];
                --tk;
            }
        }
    }
    assert(tk <= 1);
    cout << r;
}


Measured memory_bytes: 6944
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	n = Number(input[0]);
	//文字列から10進数に変換するときはparseIntを使います
  array=[];
  for (var i = 1; i < input.length; i++) {
    tmp = input[i].split("").sort().join('');
    array[i-1] = tmp;
  }

  array = array.sort();

  var count = 1;
  var compstr = array[0];
  var pattern = [];
  for (var i = 1; i < array.length; i++) {
    if(compstr == array[i]) count++;
    else{
      if(count >= 2) pattern.push(count);
      compstr = array[i];
      count = 1;
    }

    if(i == array.length-1){
      if(count >= 2) pattern.push(count);
    }
  }

  var sum = 0;
  for (var i = 0; i < pattern.length; i++) {
    var num = pattern[i];
    var tmp = (num*(num-1))/2;
    sum += tmp;
  }
	//出力
	console.log('%d',sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 51340
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define edge pair<int,int>

const int N=2e5+5;
vector<edge> g[N];
int col[N],a[N],p[N],ans[N],m,n;

void color(int x){
	if(col[x]) return ;
	for(auto [y,i]:g[x]) if(!col[y]&&a[x]==a[y]){
		col[x]=1;col[y]=2;
		ans[i]=a[x];
		return ;
	}
	for(auto [y,i]:g[x]) if(col[y]){
		col[x]=3-col[y];
		ans[i]=a[x];
		return ;
	}
	write(-1);exit(0);
}

signed main(){
	read(n,m);
	for(int i=1;i<=n;i++) read(a[i]),p[i]=i;
	for(int i=1,x,y;i<=m;i++){
		read(x,y);
		g[x].emplace_back(y,i);
		g[y].emplace_back(x,i);
	}
	sort(p+1,p+1+n,[](const int &x,const int &y){return a[x]<a[y];});
	for(int i=1;i<=n;i++) color(p[i]);
	for(int i=1;i<=n;i++) putchar(col[i]==1?'B':'W');puts("");
	for(int i=1;i<=m;i++) write(ans[i]?ans[i]:1000000000),puts("");
}

Measured memory_bytes: 15868
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 105;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int k,t;
int val[maxn];

void solve()
{
	sa(k),sa(t);

	int maxx=0;
	repp(i,1,t)
	{
		sa(val[i]);
		maxx = max(val[i],maxx);
	}
	int x=maxx-(k-maxx)-1;
	if(x<=0)
	{
		puts("0");
	}
	else
	{
		printf("%d\n",x);
	}
}

int main()
{
    solve();
    return 0;
}

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

int main(){
  int i,k,loopNum,ans[2]={0};
  
  scanf("%d",&loopNum);

  for(i=0;i<loopNum;++i){
    char input[2][101];

    scanf("%s %s",input[0],input[1]);

    int work = (strlen(input[0]) > strlen(input[1])) ? strlen(input[1]) : strlen(input[0]);
    for(k=0; k < work; ++k){
      if(input[0][k] > input[1][k]){
	ans[0] += 3;
	break;
      }else if(input[0][k] < input[1][k]){
	ans[1] += 3;
	break;
      }

      if(k == work - 1){
	if(strlen(input[0]) == strlen(input[1])){
	  ++ans[0];
	  ++ans[1];
	}else if(strlen(input[0]) > strlen(input[1])){
	  ans[0] += 3;
	}else if(strlen(input[0]) < strlen(input[1])){
	  ans[1] += 3;
	}
      }
    }
  }

  printf("%d %d\n",ans[0], ans[1]);
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

const int N=100005;


int32_t main()
{
	IOS;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2)
		swap(a,b);
	if(a-b>1e18)
		cout<<"unfair";
	else cout<<a-b;
	
 	return 0;
} 

Measured memory_bytes: 256
import java.util.*;

class Main{


    private static int solver(int[] w, int[] v, int n, int max){
        
        int[][] dp = new int[n + 1][max + 1];
        for(int[] row: dp) Arrays.fill(row, 0);


        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= max; j++){

                if(w[i-1] <= j) { 
                    int emptyCapacity = j - w[i-1]; 
                    dp[i][j] = Math.max(dp[i-1][j], v[i-1] + dp[i-1][emptyCapacity]);
                     
                } else { 
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        return dp[n][max];
    }  


    // space optimized version, weight is the dimension to dp   
    private static long solverOneDimension(int[] w, int[] v, int n, int max){
        
        long[] dp = new long[max + 1];
        dp[0] = 0;

        for(int i = 1; i <= n ;i++){

            int value = v[i - 1];
            int weight = w[i - 1];

            for(int weight_already = max - weight; weight_already >= 0; --weight_already) {
                
                    dp[weight_already+weight] = Math.max(dp[weight_already+weight], dp[weight_already] + value);
                }
        }

        long answer = 0;
        for(int i = 0; i <= max; i++) {
            answer = Math.max(answer, dp[i]);
        }        


        return answer;
    }



    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solverOneDimension(w, v, n, max));
        
    }
}


Measured memory_bytes: 24020
N, L = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
P = "Possible"
for i in range(N-1):
  if a[i] + a[i+1] >= L:
    start = i
    break  
else:
  P = "Impossible"
print(P)

if P == "Possible":
  ans = [start]
  if start > 0:
    ans += reversed(list(range(start)))
  if start != N-2:
    ans += list(range(start+1, N-1))
  ans.reverse()
  for a in ans:
    print(a+1)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s,t;
    cin>>s>>t;
    ll n=s.size(),m=t.size();
    //s[j]について、j以降の(i+'a')の個数
    //0-indexed
    vector<vector<int>> ccnt(26,vector<int>(n+1,0));
    for(int j=0; j<26; j++){
        for(int i=n-1; i>=0; i--){
            ccnt[j][i]=ccnt[j][i+1];
            if(s[i]==(char)(j+'a')) ccnt[j][i]--;
        }
    }
    map<char,int> cmap;
    for(int i=0; i<n; i++) cmap[s[i]]++;
    for(int i=0; i<m; i++){
        if(cmap[t[i]]==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    /*
    for(int i=0; i<26; i++){
        cout<<(char)(i+'a')<<" ";
        for(int j=0; j<n+1; j++) cout<<ccnt[i][j]<<" ";
        cout<<endl;
    }
    */

    ll itr=0;
    ll roop=0;
    for(int i=0; i<m; i++){
        //roop目でitr以降のsにt[i]が出現するならその位置をitrに格納
        //しないならroop++してsで最初に出現するt[i]の位置をitrに格納
        if(ccnt[t[i]-'a'][itr]<0){
            //jtrには次の出現位置が入るはず
            auto jtr=lower_bound(ccnt[t[i]-'a'].begin()+itr,ccnt[t[i]-'a'].end(),ccnt[t[i]-'a'][itr]+1);
            //cout<<*jtr<<endl;
            itr=jtr-ccnt[t[i]-'a'].begin();
            
            //indexedを合わせるためのデクリメント
            //cout<<roop<<" "<<itr<<endl;
        }else{
            roop++;
            itr=0;
            auto jtr=lower_bound(ccnt[t[i]-'a'].begin()+itr,ccnt[t[i]-'a'].end(),ccnt[t[i]-'a'][itr]+1);
            itr=jtr-ccnt[t[i]-'a'].begin();
            
            //cout<<i<<" "<<itr<<endl;
        }
    }
    ll ans=roop*n;
    ans+=itr;
    cout<<ans<<endl;
}

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-10;
const int mod =  1000000007;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define vvpii vector<vector<pair<int,int>>>
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define forr(i,a,b) for(i=a;i<=b;i++)
#define umii unordered_map<int,int>
#define vpii vector<pair<int,int>>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define int long long
#define nl cout<<"\n"
#define pb push_back
#define sp <<" "<<
#define ss second
#define ff first
inline void read(int &x)
{
      int c = getchar();
      x = 0;
      int neg = 0;
      for(; ((c<48 || c>57) && c != '-'); c = getchar());
      if(c=='-')
      {
            neg = 1;
            c = getchar();
      }
      for(; c>47 && c<58 ; c = getchar())
      {
            x = (x<<1) + (x<<3) + c - 48;
      }
      if(neg)
      {
            x = -x;
      }
}
int fpow(int x, int n)
{
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b)
{
    if(b == 0)
    {
          return a;
    }
    return gcd(b,a % b);
}
void sieve(int n)
{
      bool prime[1000006];
      memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
      for (int p = 2; p <= rootn; p++)
      {
            if (prime[p] == true)
            {
                  for (int i = p*p; i <= n; i += p)
                  {
                        prime[i] = false;
                  }
            }
      }
      prime[1] = 0;
}
const int N = 100050;
int cnt, sum, mid, mx, mn, ans, a[N], b[N];
int n, m, d, i, j, k, l, p, q, r, t, w, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************
vi g[N];
int dp[N][2];

void dfs(int i,int par)
{

      dp[i][1] = dp[i][0] = 1;
      for(auto j:g[i])
      {
            if(j!=par)
            {
                  dfs(j,i);
                  dp[i][1] *= (dp[j][1]+dp[j][0]);
                  dp[i][0] *= dp[j][1];
                  dp[i][1]%=mod;
                  dp[i][0]%=mod;
            }
      }
      //cout<<i sp dp[i][1] sp dp[i][0];nl;
}

int32_t main()
{     fio;
      cin>>n;
      forr(i,1,n-1)
      {
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
      }
      dfs(1,0);
      cout<<(dp[1][0]+dp[1][1])%mod;
}


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

int Rand(int x) {return rand() * rand() % x + 1;}

#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
const int INF = 0x3f3f3f3f, N = 1000005, M = 2000005, MOD = 1e9 + 7;

LL f(LL n, LL b)
{
	if (b == 1)
		return -1;
	if (n < b)
		return n;
	return f(n / b, b) + n % b;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	LL n, m;
	while (cin >> n >> m)
	{
		if(n == m) return cout << n + 1 << endl, 0;
		else if(n < m) return cout << -1 << endl, 0;

		LL sn = sqrt(n), ans = -1;
		for (int i = 1; i <= sn; i++)
		{
			if (f(n, i) == m)
			{
				ans = i;
				break;
			}
		}
		sn = sqrt(n - m);
		for (int i = 1; i <= sn; i++)
			if ((n - m) % i == 0)
			{
				LL bb = (n - m) / i + 1;
				if (f(n, bb) == m)
				{
					if(ans == -1) ans = bb;
					ans = min(ans, bb);
				}
			}
		cout << ans << endl;
		return 0;
	}
	return 0;
}

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

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

   for(int i=0;i<n;i++){
      cout << s[i] << t[i];
   }
   cout << endl;
   return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    double l, t;
    cin >> l;
    t = l / 3;
    cout << fixed << setprecision(10);
    cout << t * t * t << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <string>
#include <stack>

using namespace std;

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

    stack<int> intStack;
    int a, b;
    string s;
    
    while (cin >> s) {
	if (s[0] == '+') {
	    b = intStack.top(); intStack.pop();
	    a = intStack.top(); intStack.pop();
	    intStack.push(a + b);
	}
	else if (s[0] == '-') {
	    b = intStack.top(); intStack.pop();
	    a = intStack.top(); intStack.pop();
	    intStack.push(a - b);
	}
	else if (s[0] == '*') {
	    b = intStack.top(); intStack.pop();
	    a = intStack.top(); intStack.pop();
	    intStack.push(a*b);
	}
	else {
	    intStack.push(atoi(s.c_str()));
	}
    }

    cout << intStack.top() << "\n";

    return 0;
}

Measured memory_bytes: 3200
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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(nullptr);

    string s;
    string t;
    cin >> s >> t;

    int NS = s.size();
    int NT = t.size();

    vvll dp(NS + 1, vll(NT + 1));

    //もらうDP
    rep(i, NS)
    {
        rep(j, NT)
        {
            //LCSが定まっている場合、片方の文字位置を移動させてもLCSは伸びない
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);

            //両方の位置を移動させて一致したときだけ長さを1増やす
            if(s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }


    string ans = "";
    ll length = dp[NS][NT];

    revrep(i, NS)
    {
        rep(j, NT)
        {
            if (dp[i + 1][j + 1] == length && s[i] == t[j])
            {
                ans += s[i];
                length--;
            }
        }
    }

    reverse(all(ans));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 73564
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define mod 998244353
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(8);
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  string s,t;
  rep(i,0,a){
    s += '1';
  }
  rep(i,a,w){
    s += '0';
  }
  
  rep(i,0,w){
    if(s[i]=='1') t+= '0';
    else t+= '1';
  }
  //cout << s << ' ' << t << endl;
  
  rep(i,0,b){
    cout << s << endl;
  }
  rep(i,b,h){
    cout << t << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1280
import heapq as hq
X,Y,A,B,C=map(int,input().split(' '))
P,Q,R=[sorted(list(map(int,input().split(' '))),reverse=True) for i in range(3)]
P=P[:X]
Q=Q[:Y]
hq.heapify(P)
hq.heapify(Q)
R=R[::-1]
while len(R)>0:
    p=hq.heappop(P)
    q=hq.heappop(Q)
    r=R.pop()
    if r<=min(p,q):
        hq.heappush(P,p)
        hq.heappush(Q,q)
        break
    if p<=q and p<r:
        hq.heappush(P,r)
        hq.heappush(Q,q)
    elif p>q and q<r:
        hq.heappush(P,p)
        hq.heappush(Q,r)
print(sum(P)+sum(Q))

Measured memory_bytes: 23456
#include <stdio.h>

int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}
int main(){
  // get input
  int N;
  int M;
  scanf("%d",&N);
  scanf("%d",&M);
  char S[1000000];
  char T[1000000];
  
  scanf("%s", S);
  scanf("%s", T);
  
  //puts(S);
  //puts(T);
  
  // get gcd of N,M
  int C = gcd(N, M);
  int n = N/C;
  int m = M/C;
  // test
  int test = 1;
  for(int i = 0; i < C; i++){
    if(S[n*i] != T[m*i]){
      test = 0;
      break;
    }
  }
  // print result
  if(test == 1){
    printf("%ld", (long)N*(long)M/(long)C);
  }
  else printf("-1");
  
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  cin >> N;
  vector<long> V(N);
  vector<long> C(N);
  rep(i, N) cin >> V[i];
  rep(i, N) cin >> C[i];
  long result = 0;
  rep(i, N) if (V[i] > C[i]) result += V[i] - C[i];
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int score[50][4];
	int i,j,m,f,r;

	for(i=0;i<50;i++){
		for(j=0;j<4;j++){
			score[i][j] = 0;
		}
	}

	i = 0;
	for(;;){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1)break;

		if(m == -1 || f == -1){
			score[i][3] = 5;
			i++;
			continue;
		}

		if(m == -1) m = 0;
		if(f == -1) f = 0;
		if(r == -1) r = 0;
		score[i][0] = m;
		score[i][1] = f;
		score[i][2] = r;
		if(m+f >= 80) score[i][3] = 1;
		else if(m+f >= 65) score[i][3] = 2;
		else if(m+f >= 50) score[i][3] = 3;
		else if(m+f >= 30){
			if(r >= 50) score[i][3] = 3;
			else score[i][3] = 4;
		}
		else score[i][3] = 5;
		i++;
	}

	for(j=0;j<i;j++){
		if(score[j][3] == 1)cout << "A";
		else if(score[j][3] == 2)cout << "B";
		else if(score[j][3] == 3)cout << "C";
		else if(score[j][3] == 4)cout << "D";
		else cout << "F";
		cout << endl;
	}
	

	return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

signed main()
{
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    int ans = 2 * N;
    int cand = ans;

    int s_ind = N-1;
    for(int length = 1; length <= N; ++length) {
        cand--;
        if(s.substr(s_ind, length) == t.substr(0, length)) {
            ans = min(ans, cand);
        }
        s_ind--;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;cin>>s;
  	vector<int> nwse(4,0);
  	for(int i=0;i<s.size();i++){
    	if(s.at(i)=='N') nwse[0]=1;
      	if(s.at(i)=='W') nwse[1]=1;
      	if(s.at(i)=='S') nwse[2]=1;
      	if(s.at(i)=='E') nwse[3]=1;
    }
  	if(nwse[0]==nwse[2] && nwse[1]==nwse[3]){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import std;

void main() {
    int h1, m1, h2, m2, k; scan(h1, m1, h2, m2, k);

    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;
    writeln(max(0, b - a - k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 3636
# coding:UTF-8
import sys
from math import factorial

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

# ユニオンファインド木
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.rank = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
        else:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = list(map(int, input().split()))     # スペース区切り連続数字
AB = [list(map(int, input().split())) for _ in range(M)]     # スペース区切り連続数字(行列)

un = UnionFind(N)
for a, b in AB:
    un.union(a-1, b-1)

g = len(un.roots())

print("{}".format(g-1))


Measured memory_bytes: 91488
import heapq
K=int(input())
if K<10:
  print(K)
  exit()
  
nums=[1, 2, 3, 4, 5, 6, 7, 8, 9]
heapq.heapify(nums)
for i in range(K):
  value=heapq.heappop(nums)
  tmp=str(value)
  if tmp[-1]=='0':
    cand=[int(tmp+'0'), int(tmp+'1')]
  elif tmp[-1]=='9':
    cand=[int(tmp+'8'), int(tmp+'9')]
  else:
    h=int(tmp[-1])
    cand=[int(tmp+str(h-1)), int(tmp+str(h)), int(tmp+str(h+1))]
  for c in cand:
    heapq.heappush(nums, c)
print(value)

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

const int maxn = 2e3 + 3;

int h, w, K;
char s[20][maxn];

int n, bd[20], cur[20], tmp[20];

bool check(int i) {
    for(int j = 0; j < n; ++j)
        tmp[j] = cur[j];
    for(int j = 0, k = 0; j < h; ++j) {
        if(bd[k] == j)
            k += 1;
        if(s[j][i] == '1') {
            tmp[k] += 1;
            if(tmp[k] > K)
                return true;
        }
    }
    return false;
}

int solve(int c) {
    int ans = 0;
    n = 0;
    for(int i = 0; i < h - 1; ++i) {
        if(c & (1 << i)) {
            bd[n++] = i + 1;
            ans += 1;
        }
    }
    bd[n++] = h;
    for(int i = 0; i < n; ++i)
        cur[i] = 0;
    for(int i = 0; i < w; ++i) {
        if(check(i)) {
            ans += 1;
            for(int j = 0; j < n; ++j)
                cur[j] = 0;
        }
        for(int j = 0, k = 0; j < h; ++j) {
            if(bd[k] == j)
                k += 1;
            if(s[j][i] == '1') {
                cur[k] += 1;
            }
        }
        for(int j = 0; j < n; ++j)
        if(cur[j] > K)
            return h + w;
    }
    return ans;
}

int main() {
    scanf("%d%d%d", &h, &w, &K);
    for(int i = 0; i < h; ++i)
        scanf("%s", s[i]);
    int ans = h + w;
    for(int i = 0; i < (1 << h); ++i)
        ans = std::min(ans, solve(i));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
class ABC135:
    def __init__(self):
        pass

    def solve(self, N):
        ans = 0
        p = list(map(int, input().split()))
        ps = sorted(p)
        for i in range(N):
            if(p[i] != ps[i]):
                ans += 1
        if(ans == 0 or ans == 2):
            print("YES")
        else:
            print("NO")

if __name__ == '__main__':
    N = int(input())
    problem = ABC135()
    problem.solve(N)


Measured memory_bytes: 2940
m = int(input())
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
    
while is_prime(m) is False:
    m += 1
    
print(m)

Measured memory_bytes: 9164
n = gets.to_i

nums = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp = []
dp[0] = 0

(1..100000).each do |i|
  dp[i] = Float::INFINITY
  nums.each do |num|
    next if i-num < 0
    next if dp[i-num] == nil
    dp[i] = [dp[i], 1 + dp[i-num]].min
  end
end

puts dp[n]

Measured memory_bytes: 2632
#include <iostream>
#include <vector>
#include <queue>
#define INF 1e9
#define f first
#define s second
using namespace std;
typedef pair <int,int> P;
typedef pair <double,P> PP;
int n,m,p,s,g,T[10];
vector <P> x[32];

double dijkstra(){
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  double D[1<<8][31];
  for(int i=0;i<(1<<n);i++)for(int j=0;j<=m;j++) D[i][j]=INF;
  Q.push(PP(0,P(s,0)));
  D[0][s]=0;
  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    double dis=t.f;
    int pos=t.s.f,bit=t.s.s;
    if(pos==g) return dis;  
    if(D[bit][pos]<dis)continue;
    for(int i=0;i<x[pos].size();i++)
      for(int j=0;j<n;j++){
	int nbit=(bit|(1<<j)),npos=x[pos][i].f;
	double ndis=dis+(1.0*x[pos][i].s/T[j]);
	if(bit!=nbit&&D[nbit][npos]>ndis)Q.push(PP(ndis,P(npos,nbit))),D[nbit][npos]=ndis;
    }
  }
  return 0;
}

int main(){
  while(1){
    cin>>n>>m>>p>>s>>g;
    if(!n&&!m&&!p&&!s&&!g) break;
    for(int i=0;i<=m;i++) x[i].clear();
    for(int i=0;i<n;i++)cin>>T[i];
    for(int i=0,a,b,c;i<p;i++)cin>>a>>b>>c,x[a].push_back(P(b,c)),x[b].push_back(P(a,c));
    double ans=dijkstra();
    if(ans==0)cout<<"Impossible"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2700
#------------------------template--------------------------#
import os
import sys
# from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()


n=Int()

tot=pow(10,n,M)
no9no0=pow(8,n,M)
no9but0=(pow(9,n,M)-pow(8,n,M)+M)%M
no0but9=no9but0

ans=(tot-no9but0-no9no0-no0but9)%M
print(ans)




    
    
    



    
        

   



































    

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n;cin>>n;
  int ans = 0;
  repi(i,n) {
    if (i < 105) continue;
    if (i%2 == 0) continue;
    int cnt = 0;
    repi(j,n) if (i%j==0) cnt++;
    if (cnt==8) ans++;
  }
  cout << ans << endl;
}


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

signed main(void)
{
	int n, m, c, sum, ans;
	cin >> n >> m >> c;
	int b[m];
	int a[n][m];

	rep(i, m) cin >> b[i];
	rep(i, n) rep(j, m) cin >> a[i][j];
	ans = 0;
	rep(i, n)
	{
		sum = 0;
		rep(j, m)
		{
			sum += a[i][j] * b[j];
		}
		if (sum  + c > 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

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

    cin >> ans;
    rep(i, n-1) {
        ll tmp;
        cin >> tmp;
        ans = my_gcd(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
n = int(input())
s = [int(input()) for i in range(n)]
dp = [0] * 10001
dp[0] = 1
for i in s:
  for j in range(10000,-1,-1):
    if dp[j] == 1:
      dp[j+i] = 1
m = 0
for i in range(10001):
  if i % 10 != 0 and dp[i] == 1:
    m = i
print(m)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        long d=nl();
        d=d*d;
        int ans=0;
        for (int i=0;i<n;i++) {
            long u=nl(),v=nl();
            u=u*u;
            v=v*v;
            if (u+v<=d) ans++;
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 54872
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    int H[N];
    for(int i=0;i<N;i++){
        cin>>H[i];
    }

    sort(H,H+N);
    long int term=0;
    for(int i=N-1;i>=0;i--){
        if(K>0){
            K--;
            H[i]=0;
            continue;
        }
        term+=H[i];
    }
    cout<<term<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
    string s, t;
    cin >> s;
    cin >> t;
    if(s==t){
        cout << "Yes\n";
    }
    else{
        int len = s.size();
        int i;
        bool ok = false;
        for(i=0; i<len; i++){
            s = s.back() + s.substr(0, len-1);
            if(s==t){
                ok = true;
                break;
            }
        }
        if(ok) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3632
#-*-ccoding:utf-8-*-
k = int(input())
a, b = map(int, input().split())
is_ok = False
 
for i in range(a,b+1):
  if i % k == 0:
    is_ok = True
    
if is_ok:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9180
arr="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"
list=arr.split(", ")

k=int(input())
print(list[k-1])

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

using namespace std;

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()å
#define rall(i) (i).begin(),(i).end(),greater<int>()


#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

 
signed main(){
  
    int N,K;
    string S;

    cin >> N >>S>>K;

    char c = S[K-1];

    rep(i,N){
        if(S[i]!=c){
            S[i]='*';
        }

    }
   
    cout <<S<<endl;

    return 0;
 
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
// x以上の最小のnの倍数がnの何倍かを返す関数
inline long long min_mult(long long x, long long n){
  if (x % n == 0) return x / n;
  else return x / n + 1;
}
// x以下の最大のnの倍数がnの何倍かを返す関数
inline long long max_mult(long long x, long long n){
  return x / n;
}
// x以上y以下のnの倍数の個数を返す関数
inline long long num_mult(long long x, long long y, long long n){
  return max_mult(y, n) - min_mult(x, n) + 1;
}
// nとmの最小公倍数
inline long long lcm(long long n, long long m){
  return (n / __gcd(n, m)) * m;
}

int main(){
  // input
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  
  // A以上B以下の整数の個数
  long long ans = B - A + 1;

  // A以上B以下のCの倍数の個数を引く
  ans -= num_mult(A, B, C);

  // A以上B以下のDの倍数の個数を引く
  ans -= num_mult(A, B, D);

  // A以上B以下の最小公倍数(C, D)の倍数の個数を足す
  ans += num_mult(A, B, lcm(C, D));
  
  // output
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
        int line = sc.nextInt();
        
        long power = 1;
        double pow = Math.pow(10, 9);
        int pow2 = (int)pow;
        
        for(int i = 1; i <= line; i++){
        	
        	power *= i;
        	power = power%(pow2+7);
        	
        }
        
        System.out.println(power);
        
        
        
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <iterator>
using namespace std;

vector<int> parse(string s) {
    istringstream iss(s);
    vector<int> res;
    for(int n; iss >> n; ) {
        if(n > 10) n = 10;
        res.push_back(n);
    }
    return res;
}

int main() {
    for(string line; getline(cin, line), line != "0"; ) {
        vector<int> cards = parse(line);
        int one = 0;
        for(int c : cards) if(c == 1) one++;
        int s = accumulate(begin(cards), end(cards), 0);
        for(int i = 0; i < one; i++) {
            if(s + 10 <= 21) s += 10;
        }
        if(s > 21) s = 0;
        cout << s << endl;
    }
}

Measured memory_bytes: 1244
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		System.out.println(Math.PI * 2 * r);
	}

}


Measured memory_bytes: 35992
N = int(input())
A_l = [x-1 for x in list(map(int, input().split()))]
B_l = list(map(int, input().split()))
C_l = list(map(int, input().split()))

ans = 0

for idx in range(len(A_l)):
    ans += B_l[A_l[idx]]
    if idx >= 1:
        if A_l[idx] - A_l[idx-1] == 1:
            ans += C_l[A_l[idx-1]]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll X, Y; cin >> X >> Y;
  if (X % Y == 0) {
    cout << "-1\n";
  }else  {
    cout << X << endl;
  }
  return 0;
}



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

string a;
string r = "keyence";

int main(){
    cin>>a;
    for(int i=0;i<=7;i++){
        string b = a.substr(0,i);
        string c = a.substr(a.size()-(7-i),7-i);
        string d = b+c;
       //cout<<b<<endl<<c<<endl<<d<<endl;
        if(r==d){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

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

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

    ll sum = 0;
    rep(i,s.size()){
        sum += s[i] - '0';
    }

    sum%9==0 ? cout << "Yes": cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin>>p[i],p[i]--;
  
  vector<int> q(n);
  for(int i=0;i<n;i++) q[p[i]]=i;
  
  auto NG=[&](){cout<<":("<<endl;exit(0);};
  string ans;
  stack<int> st;
  for(int i=0,k=0;i<n;i++){
    ans+='(';
    st.emplace(q[i]);
    while(!st.empty()&&st.top()==k){
      ans+=')';
      st.pop();
      k++;
    }    
  }
  
  if(!st.empty()) NG();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4368