akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, K, C;
  string S;
  cin >> N >> K >> C >> S;
  vector<i64> w;
  for (i64 i = N - 1; 0 <= i; i--)
    if (w.size() < K && S[i] == 'o')
    {
      w.push_back(i);
      i -= C;
    }
  i64 cnt = 0;
  for (i64 i = 0; i < N; i++)
    if (cnt < K && S[i] == 'o')
    {
      if (w[K - cnt - 1] == i)
        cout << i + 1 << endl;
      cnt++;
      i += C;
    }
  return 0;
}


Measured memory_bytes: 3444
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.range;
void main()
{
    auto count = readln().strip.to!int;
    auto m = new int[(count + 1) * (count + 1)].chunks(count + 1);
    auto p = new int[count + 1];
    foreach (i; iota(count))
    {
        int x, y;
        scanf("%d %d", &x, &y);
        p[i] = x;
        p[i + 1] = y;
    }
    for (int l = 2; l <= count; l++)
    {
        for (int i = 1; i <= count - l + 1; i++)
        {
            auto j = i + l - 1;
            m[i][j] = int.max;
            for (int k = i; k <= j - 1; k++)
            {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    writeln(m[1][count]);

}


Measured memory_bytes: 2488
import java.util.*;
class Main{
  static final long mmod = 1000000007;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),k=sc.nextInt();
    long count = 0;
    if(k==1){count+=n+1;}
    long min = 0,max=n-1;
    for(int i=2;i<=n+1;i++){
      min+=i-1;
      max+=n;
      if(i>=k){
        count=get(count+get(max-min+1));
      }
      max-=i;
    }
    pl(count+"");
  }


  public static long get(long a){
    return a%mmod;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 39048
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll n;
    cin>>n;
    map<ll,ll> e;
    map<ll,ll> o;
    rep(i,n){
        ll a;
        cin>>a;
        if(i%2==0){
            e[a]++;
        }else{
            o[a]++;
        }
    }
    ll keye,keyo;
    ll emax=0;
    ll e2m=0;
    ll omax=0;
    ll o2m=0;
    for(auto p:e){
        ll value=p.second;
        if(value>emax){
            e2m=emax;
            emax=value;
            keye=p.first;
        }else if(value>e2m){
            e2m=value;
        }
    }
    for(auto p:o){
        ll value=p.second;
        if(value>omax){
            o2m=omax;
            omax=value;
            keyo=p.first;
        }else if(value>o2m){
            o2m=value;
        }
    }
    if(keye!=keyo){
        cout<<n-emax-omax<<endl;
    }else{
        if(omax+e2m>emax+o2m){
            cout<<n-omax-e2m<<endl;
        }else{
            cout<<n-emax-o2m<<endl;
        }
    }
}

Measured memory_bytes: 6528
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
 
public class Main{
 
	static PrintWriter out;
	static InputReader ir;
 
	static void solve(){
		int n=ir.nextInt();
		int[] a=ir.nextIntArray(n);
		int cnt=0;
		int i;
		for(i=0;i<n-1;){
			int t=i;
			while(i<n-1&&(long)(a[t]-a[i])*(a[i]-a[i+1])>=0)
				i++;
			i++;
			cnt++;
		}
		if(i==n-1) cnt++;
		out.println(cnt);
	}
 
	public static void main(String[] args) throws Exception{
		ir=new InputReader(System.in);
		out=new PrintWriter(System.out);
		solve();
		out.flush();
	}
 
	static class InputReader {
 
		private InputStream in;
		private byte[] buffer=new byte[1024];
		private int curbuf;
		private int lenbuf;
 
		public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
		public boolean hasNextByte() {
			if(curbuf>=lenbuf){
				curbuf= 0;
				try{
					lenbuf=in.read(buffer);
				}catch(IOException e) {
					throw new InputMismatchException();
				}
				if(lenbuf<=0) return false;
			}
			return true;
		}
 
		private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
		private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
		private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
		public boolean hasNext(){skip(); return hasNextByte();}
 
		public String next(){
			if(!hasNext()) throw new NoSuchElementException();
			StringBuilder sb=new StringBuilder();
			int b=readByte();
			while(!isSpaceChar(b)){
				sb.appendCodePoint(b);
				b=readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			int res=0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}
 
		public long nextLong() {
			if(!hasNext()) throw new NoSuchElementException();
			int c=readByte();
			while (isSpaceChar(c)) c=readByte();
			boolean minus=false;
			if (c=='-') {
				minus=true;
				c=readByte();
			}
			long res = 0;
			do{
				if(c<'0'||c>'9') throw new InputMismatchException();
				res=res*10+c-'0';
				c=readByte();
			}while(!isSpaceChar(c));
			return (minus)?-res:res;
		}
 
		public double nextDouble(){return Double.parseDouble(next());}
 
		public int[] nextIntArray(int n){
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n){
			long[] a=new long[n];
			for(int i=0;i<n;i++) a[i]=nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n,int m){
			char[][] map=new char[n][m];
			for(int i=0;i<n;i++) map[i]=next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 999999797
#define N 100001

int n, ar[100001], dp[100001];

int solve(int idx) {
        if (idx == n - 1) {
                return 0;
        }
        int &ret = dp[idx];
        if (ret != -1) return ret;
        ret = 1e9;
        if (idx + 1 < n)
                ret = min(solve(idx + 1) + abs(ar[idx] - ar[idx + 1]), ret);
        if (idx + 2 < n)
                ret = min(solve(idx + 2) + abs(ar[idx] - ar[idx + 2]), ret);
        return ret;
}
int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> ar[i];
        }
        memset(dp, -1, sizeof dp);
        cout << solve(0);
return 0;
}


Measured memory_bytes: 4224
def main():
    n = int(input())
    vals = []
    scores_a = []
    scores_b = []

    for i in range(n):
        a, b = [int(strn) for strn in input().split()]
        vals.append([a, b, True])
        scores_a.append((a + b, i))
        scores_b.append((a + b, i))

    scores_a.sort(key=lambda x: x[0])
    scores_b.sort(key=lambda x: x[0])

    # print(scores_a)
    # print(scores_b)

    total = 0
    count = 0
    while True:
        # Turn A
        candidate = scores_a[-1][1]
        candidate_live = vals[candidate][2]
        # print(candidate, candidate_live)
        while not candidate_live:
            # print("####1{}".format(scores_a))
            del scores_a[-1]
            # print("####2{}".format(scores_a))
            candidate = scores_a[-1][1]
            candidate_live = vals[candidate][2]

        total += vals[candidate][0]
        count += 1
        vals[candidate][2] = False
        del scores_a[-1]

        if count == len(vals):
            break

        # Turn B
        candidate = scores_b[-1][1]
        candidate_live = vals[candidate][2]
        while not candidate_live:
            # print("####3{}".format(scores_b))
            del scores_b[-1]
            # print("####4{}".format(scores_b))
            candidate = scores_b[-1][1]
            candidate_live = vals[candidate][2]

        total -= vals[candidate][1]
        count += 1
        vals[candidate][2] = False

        if count == len(vals):
            break

    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45096
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int a,b;
int main() {

    cin >> a >> b;

    int unused = 1;
    int cnt = 0;
    while(1) {
        if(unused >= b) break;
        unused = unused - 1 + a;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

class Main{

    public static void main(String args[]){
    	Scanner scan = new Scanner(System.in);
    	HashMap<String,Integer> map = new HashMap<String,Integer>();
    	//String^ÌL[ÉÎ·éAIntegerÌl
    	int mc = 0;				//}bv³êÄ¢élÌÅål
    	String mcWord = "";
    	String max = "";
    	
    	while(scan.hasNext()){		//ÐÆÂ¸Â©Ä¢­
    		String str = scan.next();
    		if(max.length()<str.length()) max = str;
    		if(map.containsKey(str)){		//mapÉstr(æØçê½âÂ)ª êÎA
    			int count = map.get(str);		//strÉ}bv³êÄ¢élðæèo·(±Ìêñ)
    			map.put(str,++count);			//ñðXV·éBiúlÍ«Ìelse¶Éæè1)
    			if(mc < count){
    				mc = count;
    				mcWord = str;
      			}
      		} else {
      			if(mc < 1){		//v·éÉêÔÅÌPêðÅå(î)Æ·éÁÄ±ÆB
      				mc = 1;				//while[vàÅÏðè`·éÆA
      				mcWord = str;		//»ÌubNàÅÌ[JÏÉÈÁÄµÜ¤©çB
      			}
      			map.put(str, 1);
      		}
    	}
    	System.out.println(mcWord + " " + max);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
int mo = 998244353;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	vector<int> a(N);
	rep(i, 0, N) cin >> a[i];
	vector<int> b(M);
	rep(i, 0, M) cin >> b[i];
	auto c = convolution(a, b);
	rep(i, 0, N + M - 1) {
		if(i) printf(" ");
		printf("%d", c[i]);
	}
	printf("\n");
}







Measured memory_bytes: 19076
N,K=map(int,input().split())
A=[bin(int(i))[2:][::-1] for i in input().split()]
Kd=K&((1<<20)-1)
Ku=K-Kd
L=[0]*41
for a in A:
    for i in range(len(a)):
        if a[i]=='1':
            L[i]+=1
#print(L)
#print(K2,K1,K)
downans=0
otherans=0
for i in range(1<<20):
    t=0
    for j in range(20):
        if i & (1<<j):
            t+=(N-L[j])*(1<<j)
        else:
            t+=(L[j])*(1<<j)
    otherans=max(otherans,t)
    if i<=Kd:
        downans=max(downans,t)
upans=0
Kdown=0
for i in range(1<<20):
    t=0
    if i>(Ku>>20):
        continue
    for j in range(20):
        if i & (1<<j):
            t+=(N-L[j+20])*(1<<(j+20))
        else:
            t+=(L[j+20])*(1<<(j+20))
    if i<(Ku>>20):
        upans=max(upans,t)
    else:
        Kdown=max(Kdown,t)
#print(K1up,K1down,K1ans,otherans)
if Ku==0:
    print(Kdown+downans)
else:
    print(max(Kdown+downans,upans+otherans))

Measured memory_bytes: 94312
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_V 1001
#define MAX_N 100
#define MAX_M 100
 
struct P{
    int u,v;
    double cost;
    P(int u,int v,double cost) :
	u(u),v(v),cost(cost) {}
 
    bool operator < (const P &p)const{
	return cost < p.cost;
    }
};
 
int V,match[MAX_V],M;
vector<int> G[MAX_V];
vector<P> vec;
bool used[MAX_V];
 
void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}
 
bool dfs(int v){
    used[v] = true;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	int u = G[v][i],w = match[u];
	if(w < 0 || (!used[w] && dfs(w))){
	    match[v] = u;
	    match[u] = v;
	    return true;
	}
    }
    return false;
}
 
int bipartite_matching(){
    int res = 0;
    memset(match,-1,sizeof(match));
    for(int v = 0 ; v < V ; v++){
	if(match[v] < 0){
	    memset(used,false,sizeof(used));
	    if(dfs(v)){ res++; }
	}
    }
    return res;
}
 
double getDist(double x1,double y1,double x2,double y2){
    return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}
 
bool c(int x){
    for(int i = 0 ; i < MAX_V ; i++){ G[i].clear(); }
    for(int i = 0 ; i < x ; i++){
	add_edge(vec[i].u,vec[i].v);
    }
    return (bipartite_matching() == M);
}
 
void solve(){
    int l = 0, r = vec.size();
    while(r - l > 0){
	int mid = (l + r) / 2;
	if(c(mid)){
	    r = mid;
	}else{
	    l = mid+1;
	}
    }
    printf("%.10f\n",vec[r-1].cost);
}
 
int main(){
    int N;
    double x[MAX_N],y[MAX_N],v[MAX_N];
    while(cin >> N >> M, N){
	for(int i = 0 ; i < N ; i++){
	    cin >> x[i] >> y[i] >> v[i];
	}
	vec.clear();
	for(int i = 0 ; i < M ; i++){
	    int X,Y;
	    cin >> X >> Y;
	    for(int j = 0 ; j < N ; j++){
		vec.push_back(P(j,i+N,getDist(x[j],y[j],X,Y)/v[j]));
	    }
	}
	V = N + M;
	sort(vec.begin(),vec.end());
	solve();
    }
    return 0;
}

Measured memory_bytes: 3464
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25

int main()
{
	int n;
	cin >> n;
	int p[n];
	rep(i, n) cin >> p[i];
	sort(p, p + n);
	p[n - 1] /= 2;
	int cost = 0;
	rep(i, n) {
		cost += p[i];
	}
	cout << cost << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
#define MOD 1000000007 //10^9 + 7

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

    vector<ll> nums(n);
    for (int i = 0; i < n; i ++) cin >> nums[i];

    ll res = 0;
    ll two_factor = 1;
    for (int d = 0; d < 60; d++) {
        ll even = 0, odd = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] & (1LL << d)) odd++;
            else even++;
        }
        ll add = (even * odd) % MOD * two_factor % MOD;
        res = (res + add) % MOD;
        two_factor = (two_factor * 2) % MOD;
    }

    cout  << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  if(S[0]==S[S.size()-1]) {
    if(S.size()%2==0) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
  else {
    if(S.size()%2!=0) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
}



Measured memory_bytes: 3736
import sys
sys.setrecursionlimit(5010)

def solve(s): 
    if len(s) ==3:
        if s[0]=='A' and s[1]=='B' and s[2]=='C':
            return True
        else:
            return False
    i=0
    a = 0
    b = 0
    c = 0
    lis =[]
    while i < len(s):
        if i+2<len(s) and s[i] =='A' and s[i+1] == 'B' and s[i+2] == 'C':
            lis.append('X')
            i += 3
        else:
            lis.append(s[i])
            if s[i] == 'A':
                a = 1
            if s[i] == 'B':
                b = 1
            if s[i] == 'C':
                c = 1
            i += 1

    if not(a+b+c == 2):
        return False
    if a==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='A'
    if b==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='B'
    if c==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='C'
    if len(s) == len(lis):
        return False

    return solve(lis)


if solve(input()):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 60092
#include<stdio.h>

int main(void)
{
  int N;
  scanf("%d",&N);
  switch(N%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
    printf("hon");
    break;
  }
  
  switch(N%10){
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon");
      break;
  }
  
  switch(N%10){
    case 3:
      printf("bon");
      break;
  }
  
  return 0;
}

Measured memory_bytes: 1692
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int k3,k2,k1;
	k3 = n / 100;
	k2 = (n -k3 * 100) / 10;
	k1 = n -k3 * 100 -k2 * 10;
	if(k1 == 7 || k2 == 7 || k3 == 7){
		cout << "Yes";
		return 0;
	}
	cout << "No";

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    vector<int> v;
    int pre = -1;
    int i = 0;
    while(i < n){
        if(s1[i] == s2[i]){
            pre = 1;
            i++;
            v.push_back(1);
        }else{
            v.push_back(2);
            pre = 2;
            i += 2;
        }
    }
    ll ans = 0;
    rep(i,v.size()){
        if(i == 0){
            if(v[i] == 1) ans = 3;
            else ans = 6;
        }else{
            if(v[i] == 1){
                if(v[i-1] == 1) ans *= 2;
                else ans *= 1;
            }else{
                if(v[i-1] == 1) ans *= 2;
                else ans *= 3;
            }
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

int main() {
  int max_len;
  string str;

  cin >> max_len;
  cin >> str;

  for (int i = 0; i < str.size(); i++) {
    if (i >= max_len) {
      cout << "...";
      break;
    }
    cout << str[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <queue>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  queue<pair<string, int> > queue;
  for(int i=0;i < n;i++){
    string name; int time;
    cin >> name >> time;
    queue.push(make_pair(name,time));
  }
  int now = 0;
  while(!queue.empty()){
    pair<string, int> que = queue.front(); queue.pop();
    if(que.second <= q){
      now += que.second;
      cout << que.first << " " << now << endl;
    }else{
      queue.push(make_pair(que.first, que.second-q));
      now += q;
    }
  }
	return 0;
}

Measured memory_bytes: 6204
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define pa pair<int,int>
using namespace std;
const int MAX=3001;
ll dp[3005][3005];
// dp[i][j] - the highest difference i using j elements
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W
int main()
{
    int n;
    scanf("%d",&n);
    ll tab[n];
    for (int i=1;i<=n;i++)
    {
        scanf("%lld",&tab[i]);
    }

    for (int l=n;l>=1;l--)
    {
        for (int r=l;r<=n;r++)
        {
            dp[l][r]=max(tab[l]-dp[l+1][r],tab[r]-dp[l][r-1]);
        }
    }

    printf("%lld",dp[1][n]);
    return 0;
}



Measured memory_bytes: 70016
import java.util.Scanner;


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

		int weight;
		int[] num = new int[10];

		while(sc.hasNext()){
			weight = sc.nextInt();

			for(int i = 0; i < 10; i++){
				num[9 - i] = weight / (int)Math.pow(2, 9 - i);
				if(num[9 - i] == 1){
					weight %= (int)Math.pow(2, 9 - i);
				}
			}

			boolean fnum = true;
			for(int i = 0; i < 10; i++){
				if(num[i] == 1){
					if(fnum ==true){
						System.out.print((int)Math.pow(2, i));
						fnum = false;
					}else{
						System.out.print(" " + (int)Math.pow(2, i));
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long N, std::vector<long long> A){
  map<ll,ll> m{};
  for (ll i = 1; i <= N; i++)
  {
    m.emplace(A[i], i);
  }
  for (ll i = 1; i <= N; i++)
  {
    if (i==N)
    {
      cout << m[i]+1 << "\n";
    }else{
      cout << m[i]+1 << " ";
    }
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 7808
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s = "!" + s + "!";
	int cnt = 0;
	for(int i = 1; i <= n; ++i){
		if(s[i] == 'L'){
			if(s[i-1] == s[i]) ++cnt;
		}
		else{
			if(s[i+1] == s[i]) ++cnt;
		}
	}
	int ans = cnt + 2*k;
	chmin(ans, n-1);
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int N;
  int a[100001];
  int x[100001];
  int res=0;
  cin >> N;
  rep(i,N) cin >> a[i];

  //x(0)+x(1)+...+x(N-1) = a(0)+a(1)+...+a(N-1) = S
  //x(i)/2+x(i+1)/2 = a(i) 
  //x(i)+x(i+1) = 2*a(i)
  //x(0) = S - (x(1)+x(2) + x(3) + ... + x(N-1))
  //     = S - 2*(a(1) + a(3) + ... + a(N-2))
  //x(1) = 2a(0)-x(0)
  //x(2) = 2a(1)-x(1)
  //...

  long long S = 0;
  long long A = 0;
  rep(i,N) S+= a[i];
  A = S;
  rep(i,(N-1)/2) {
    A -= 2*a[i*2+1];
  }
  x[0] = A;
  
  for(int i=1;i<N;i++){
    x[i] = 2*a[i-1]-x[i-1];
  }
  rep(i,N) cout << x[i] << " ";
  cout << endl;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair < int , int >
#define mp make_pair
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
  }
  ll last1  = 0 , last2 = 0;
  sort(a,a+n);
  map < int , int > my;
  for(int i=n-1;i>=0;i--)
  {
      my[a[i]]++;
      if(my[a[i]] == 2 ||my[a[i]] == 4 )
      {
          if(!last1)
          last1 = a[i];
          else if(!last2)
            last2 = a[i];
      }

  }
  cout<<last1*last2;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
vector<int> color[505];
map<vector<int>, int> has;
int jiao[8];
int use[4][4]={
  {0, 3, 6, 5},
  {0, 5, 4, 1},
  {1, 4, 7, 2},
  {2, 7, 6, 3}
};

void add(vector<int> color)
{
  for (int i=0; i<4; i++)
  {
      has[color]++;
      rotate(color.begin(),color.begin()+1,color.end());
  }
}

void reduce(vector<int> color)
{

    for (int i=0; i<4; i++)
    {
        has[color]--;
        rotate(color.begin(),color.begin()+1,color.end());
  }
}

void dfs(int dep,long long& ans,long long res=1)
{
    if (dep==4) ans+=res;
    else
    {
        vector<int> tmp(4);
        for (int i=0; i<4; i++)
            tmp[i]=jiao[use[dep][i]];
        if (has.count(tmp))
        {
            int cnt=has[tmp];
            reduce(tmp);
            dfs(dep+1,ans,res*cnt);
            add(tmp);
        }
    }
}

long long solve(int a,int b)
{
    for (int i=0; i<4; i++)
    {
        jiao[i]=color[a][i];
        jiao[i+4]=color[b][i];
    }
    long long ans=0;
    for (int i=0; i<4; i++)
    {
        dfs(0,ans);
        rotate(jiao+4,jiao+5,jiao+8);
    }
    return ans;
}

int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++)
    {
        color[i].resize(4);
        for (int j=0; j<4; j++)
        {
            scanf("%d",&color[i][j]);
        }
        add(color[i]);
    }
    long long ans1=0;
    for (int i=0; i<n; i++)
    {
      for (int j=i+1; j<n; j++)
      {
          reduce(color[i]);
          reduce(color[j]);
          ans1+=solve(i,j);
          add(color[i]);
          add(color[j]);
      }
      reduce(color[i]);
    }
    printf("%lld\n",ans1);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* UnionFind */

struct UnionFind{
  vector<int> data;
  UnionFind(int s):data(s, -1) {}
  
  int root(int x){
    if(data[x] < 0) return x;
    return data[x] = root(data[x]);
  }
  
  bool set(int x,int y){
    x = root(x); y = root(y);
    if(x == y) return false;
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  
  bool check(int x, int y){
    return root(x) == root(y);
  }
  
  int size(int x){
    return -data[root(x)];
  }
};

const int MAX_P = 1000;
bool prime[MAX_P+1];

void Eratosthenes(){
  for(int i=2; i<=MAX_P; i++)
    prime[i] = true;
  
  for(int i=2; i*i<=MAX_P; i++)
    if(prime[i])
      for(int j=i; i*j<=MAX_P; j++)
        prime[i*j] = false;
}



int main(){
  int n, a[SIZE], id[SIZE];
  pair<int,int> p[SIZE];
  
  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", a+i);
    p[i] = {a[i], i};
  }

  sort(p, p+n);

  for(int i=0;i<n;i++) id[p[i].second] = i;
  
  Eratosthenes();

  UnionFind uf(n);
  
  for(int i=0;i<=400;i++){
    int r = -1;
    if(prime[i]){
      for(int j=0;j<n;j++){
        if(a[j]%i == 0){
          if (r >= 0) uf.set(r, j);
          r = j;
        }
      }
    }
  }

  vector<int> vec[SIZE], vec2[SIZE];
  
  for(int i=0;i<n;i++){
    vec[uf.root(i)].push_back(i);
    vec2[uf.root(i)].push_back(id[i]);
  }

  for(int i=0;i<n;i++){
    sort(vec[i].begin(), vec[i].end());
    sort(vec2[i].begin(), vec2[i].end());

    for(int j=0;j<vec[i].size();j++){
      if(vec[i][j] != vec2[i][j]){
        puts("0");
        return 0;
      }
    }
  }

  puts("1");
  
  
  return 0;
}




Measured memory_bytes: 15820
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
vector<pair<ll,ll> > prime_fac(ll n){
	vector<pair<ll,ll> >ret;
	for(ll p = 2; p * p <= n; ++p){
		if (n % p != 0) continue;
		ll divc = 0;
		while(n % p == 0){
			++divc;
			n /= p;
		}
		ret.PB(MP(p,divc));
	}
	if (n != 1) ret.PB(MP(n,1));

	return ret;
}

int main(){
    ll N,P; SCLLD2(N,P);
    ll ans = 1;
    vector<pair<ll,ll> >f =  prime_fac(P);
    
    for(pair<ll, ll> p:f){
		ll index = p.second;
        ll a = p.first;
        REP(i,(index / N)){
            ans = ans * a;
        }
	}

    PRINTLLD(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

struct Sushi {
    int topping, deli;
    Sushi(int topping = 0, int deli = 0) : topping(topping), deli(deli) {}
};

bool operator< (Sushi a, Sushi b) {
    return a.deli > b.deli;
}

Sushi a[MAXN];
int n, k;
set<int> s;
priority_queue<int, vector<int>, greater<int> > h;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i].topping >> a[i].deli;
    sort(a+1, a+n+1);
    ll res = 0, tmp = 0;
    FOR(i,1,n) {
        if (i <= k) {
            if (!s.count(a[i].topping)) s.insert(a[i].topping);
            else h.push(a[i].deli);
            tmp += a[i].deli;
        }
        else if (!s.count(a[i].topping) && !h.empty()) {
            s.insert(a[i].topping);
            tmp += a[i].deli;
            tmp -= h.top();
            h.pop();
        }
        res = max(res, tmp + (ll) SZ(s) * SZ(s));
    }
    cout << res;
    return 0;
}

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

int main(){
  int N, M, count = 0;
  cin>>N>>M;
  int A[M];
  for(int i = 0 ; i<M; i++)cin>>A[i];
  for(int i = 0; i<M; i++){
    count += A[i];
  }
  if(N - count >= 0){cout<<N - count;}
  else{ cout<<-1; }
}


Measured memory_bytes: 3628
import Data.List
import Data.Maybe
main = do
  getLine
  [t,a] <- map read . words <$> getLine :: IO [Float]
  x <- map read . words <$> getLine :: IO [Float]
  print $ fromJust (elemIndex (minimum (xs x t a)) (xs x t a)) + 1
    where xs x m t = map (\a ->  abs (t - (m - (a*0.006)))) x

Measured memory_bytes: 1404
#include <cstdio>
char s[200005];
int n;

int main(){
    scanf("%d%s\n", &n, s);
    int ans = 0, cnt = 0;
    for (int i = 0; i < n; i++) if (s[i] == 'R') cnt++;
    for (int i = 0; i < cnt; i++) if (s[i] == 'W') ans++;
    printf("%d\n", ans);
    return 0;
}

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

int main(void){
  int r, g, b;
  std::cin >> r >> g >> b;
  if((100*r + 10*g + b) % 4 == 0){
    std::cout << "YES" << std::endl;
  }
  else {std::cout << "NO" << std::endl;}
  return 0;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 081
// C - Make a Rectangle

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

int N;
priority_queue<ll> q;

int main() {

    int edges;
    ll a;
    ll ans;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        q.push(a);
    }

    edges = 0;
    ans = 0;
    while(q.size() > 1) {
        a = q.top(); q.pop();
        if (a == q.top()) {
            if (edges == 0) {
                ans = a;
            } else if (edges == 1) {
                ans *= a;
                break;
            }
            edges++;
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;

}





Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  int n; cin >> n;
  if (n/10==9 || n%10==9) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5;
typedef long long LL;
 
int main(void)
{
	LL a,b,c,k;cin>>a>>b>>c>>k;
	if(k>=a+b+c)
	{
		cout<<a*1+b*0+c*(-1)<<endl;
	}
	else 
	{
		LL sum=0;
		if(k<a)
		{
			cout<<k*1<<endl;
		}
		else 
		{
			if(k>=a)
			{
			sum+=a*1;k-=a;
			}
			if(k>=b)
			{
			k-=b;
			}
			if(k)
			{
			sum+=k*(-1);
			}
			cout<<sum<<endl;
		}	
	}
 
return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;

bool ok = true;

ll f(int u, int p, vector<vector<int> >& G, vector<int>& a) {
	vector<int> vs;
	for (int v: G[u]) if (v != p) vs.pb(v);
	if (vs.empty()) return a[u];
	ll sum = 0, ma = 0;
	for (int v: vs) {
		ll x = f(v, u, G, a);
		sum += x;
		ma = max(ma, x);
	}
	ll ub = min(sum / 2, sum - ma);
	if (sum < a[u]) {
		ok = false;
		return 0;
	}
	ll unko = sum - a[u];
	if (unko > ub) {
		ok = false;
		return 0;
	}
	return sum - unko * 2;
}

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(u, N) scanf("%d", &a[u]);
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		G[u].pb(v); G[v].pb(u);
	}
	if (N == 2) {
		cout << (a[0] == a[1] ? "YES" : "NO") << endl;
		return 0;
	}
	// 葉以外からスタート
	int r;
	rep(u, N) if (G[u].size() >= 2) r = u;
	ll x = f(r, -1, G, a);
	cout << (ok && x == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 20352
"use strict";

function Main(input) {
    input = input.split("\n");
    let temp = input[0].split(" ").map(x => parseInt(x));
    let N = temp[0];
    let K = temp[1];
    
    let h = input.slice(1, N+1).map(x => parseInt(x));
    h.sort((n,m)=> n-m);

    let min = Math.pow(10, 10);
    
    for( let  i=0; i<(N-K)+1 ; i++) {
        let tempMin = h[i+(K-1)] - h[i];
        min = Math.min(min, tempMin);
    }
    
    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

	int n, q; cin >> n >> q;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> weight(n, 0);
    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x;
        p--;
        weight[p] += x;
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int new_v : G[v]) {
            if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
            dist[new_v] = dist[v] + 1;            
            que.push(new_v);
            weight[new_v] += weight[v];
        }
    }
    for (int i = 0; i < n; i++) {
        cout << weight[i] << " ";
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 17440
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,ans;
string op;
while(1){
cin >> a>>op>>b;
ans=0;
if(op=="?") break;
if(op=="+") ans=a+b;
if(op=="-") ans=a-b;
if(op=="/") ans=a/b;
if(op=="*") ans=a*b;
cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 3148
import sys
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
 
for i in range(10**N):
    if len(str(i))<N:
        continue
    lst=list(str(i))
    for s,c in sc:
        if int(lst[s-1])==c:
            continue
        else:
            break
    else:
        print(i)
        sys.exit()
print(-1)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

def func(l,b):
	if len(l) == 1:
		if(b):
			return 3
		else:
			return 1 + (l[0] % 2)
	if(b):
		return 3 * func(l[1:], b)
	else:
		if l[0] % 2 == 0:
			return 2*func(l[1:], False) + func(l[1:], True)
		else:
			return 2*func(l[1:], True) + func(l[1:], False)
print(func(A,False))

Measured memory_bytes: 3064
#include<stdio.h>

int main() {
   int a,b,c,k;
   scanf("%d %d %d %d", &a, &b, &c, &k);
   if (a >= k) {
      printf("%d", k);
   }else if (a+b >= k) {
      printf("%d",a);
   }else if (a+b < k) {
      printf("%d", 2*a+b-k);
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
    int x = a+b+c+d;
    int y = e+f+g+h;
    if(x>y){
        cout << x << endl;
    }
    else {
        cout << y << endl;
    }
}

    


Measured memory_bytes: 3084
#include <stdio.h>
int main(void){
  int H1,M1,H2,M2,K,ans;
  scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
  ans = (H2*60 + M2) - (H1*60 + M1) - K;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
#include <set>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
  
 
int32_t  main() {

	IOS;

	int N;

	cin >> N;

	int ans = 0;
	for (int i = 2; i <= sqrt(N); i++) {

		if (N%i == 0) {
			 
			int cnt = 0;
			int tot = 1;

			while (N%i == 0) {

				N /= i;
				cnt++;
			
				if (cnt == tot) {
					ans++;
					tot++;
					cnt = 0;
				}

			}

		}

	}
	if (N > 1) {
		ans++;
	 }
	cout << ans << endl;

}


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

int n;

bool valid(vector<vector<int>> &table){
    for(int i=0;i<n;i++){
        int psum=0;
        int nsum=0;
        for(int j=0;j<n;j++){
            if(i==j) continue;
            if(table[i][j]>0) psum++;
            if(table[i][j]<0) nsum++;
        }
        if(psum>(n-1)/2 || nsum>(n-1)/2) return false;
    }
    return true;
}
int dfs(int i,int j,vector<vector<int>>& table){
    if(!valid(table)) return 0;
    if(i==n) return 1;
    if(j==n) return dfs(i+1,0,table);
    if(i==j || table[i][j]!=0) return dfs(i,j+1,table);
    table[i][j]=1;
    table[j][i]=-1;
    int resw=dfs(i,j+1,table);
    table[i][j]=-1;
    table[j][i]=1;
    int resl=dfs(i,j+1,table);
    table[i][j]=table[j][i]=0;
    return resw+resl;
}
int solve(){
    vector<vector<int>> table(n,vector<int>(n,0));
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int x,y; cin>>x>>y;
        x--,y--;
        table[x][y]=1;
        table[y][x]=-1;
    }
    return dfs(0,0,table);
}
int main(){
    while(cin>>n,n){
        cout<<solve()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
N=int(input())
A = [int(input()) for _ in range(N)]

A_sort = sorted(A)
A_sort = A_sort[::-1]

maxim = A_sort[0]
maxim2 = A_sort[1]

flag = False
if maxim == maxim2:
    flag = True

for i in range(N):
    if flag:
        print(maxim)
    else:
        if A[i] == maxim:
            print(maxim2)
        else:
            print(maxim)
        
        
            

Measured memory_bytes: 14160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int   
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,q;
    int c;
    int e,f,w=0;
    cin>>a>>b;
  for(int i=0;i<a.size();i++){
    q=a[0];
    for(int j=0;j<a.size();j++){
      a[j]=a[j+1];
    }
        a[a.size()-1]=q[0];
    //cout<<a<<" "<<b<<"\n";
        if(a==b) w=1;
  }
     if(w) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";}


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

using namespace std;

typedef long long lli;

const int N = 200000 + 10;

int h[N];

int main()
{
	lli res;
	int n, k, i;
	cin>>n>>k;
	for (i=0; i<n; i++) cin>>h[i];
	if (n <= k) cout<<0<<endl;
	else
	{
		sort(h, h + n);
		res = 0;
		for (i=0; i<n-k; i++) res += h[i];
		cout<<res<<endl;
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

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

    string a, b, c;
    cin >> a >> b >> c;

    (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) ? cout << "YES\n" : cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    if yoko>0:
        a='R'
        c='L'
        f='L'
        h='R'
    else:
        yoko=-yoko
        a='L'
        c='R'
        f='R'
        h='L'
    if tate>0:
        b='U'
        d='D'
        e='D'
        g='U'
    else:
        tate=-tate
        b='D'
        d='U'
        e='U'
        g='D'
    l.append(a*yoko+b*tate+c*yoko+d*tate)
    l.append(e+a*(yoko+1)+b*(tate+1)+f)
    l.append(g+c*(yoko+1)+d*(tate+1)+h)
    print(''.join(l))
resolve()

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

int main(){
    string s;
    cin >> s;
    if(s=="hi" || s=="hihi" || s=="hihihi" || s=="hihihihi" || s=="hihihihihi"){
        printf("Yes\n");
        return 0;
    }
    
    printf("No\n");
}

Measured memory_bytes: 384
H,W = map(int, input().split())
from collections import defaultdict
cnt = defaultdict(int)
for _ in range(H):
    A = list(input())
    for a in A:
        cnt[a] += 1
cnt = [c for c in cnt.values()]
cnt.sort()

for i in range((H + 2 - 1) // 2):
    for j in range((W + 2 - 1) // 2):
        need = set([(i,j),(H-i-1,j),(i,W-j-1),(H-i-1,W-j-1)])
        flag = False
        for k in range(len(cnt)):
            if len(need) <= cnt[k]:
                flag = True
                cnt[k] -= len(need)
                if cnt[k] == 0:
                    cnt.pop(k)
                break
        
        if not flag:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();

		int count = 0;
		for(int i = 0; i < in.length; i++) {
			if(in[i] == '1') {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<math.h>

using namespace std;

int main(){

	int n,k;
	cin >> n >> k;
	cout << int(k * pow((k-1),(n-1))) << endl;


	return 0;
}

Measured memory_bytes: 384