akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }
    
    int size(int x){
        return sizeuf[root(x)];
    }
};
signed main(){
    int n;
    cin>>n;
    int m;
    cin>>m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        uf.merge(x-1, y-1);
    }
    bool used[114514]={};
    int ans=0;
    for(int i=0;i<n;i++){
        if(!used[uf.root(i)]){
            used[uf.root(i)]=true;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,t,k,cnt=0;
    cin>>n;
    t=n;
    while(t!=0)
    {
        k=t%10;
        t=t/10;
        cnt++;
    }
    if(cnt==1)cout<<n<<endl;
    else if(cnt==2)cout<<9;
    else if(cnt==3)cout<<n-100+1+9<<endl;
    else if(cnt==4)cout<<900+9<<endl;
    else if(cnt==5)cout<<n-10000+1+900+9<<endl;
    else if(cnt==6)cout<<90000+900+9;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

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

    deque<int> b;
    for (int i = 0; i < n; ++i) {
        if (n % 2 == i % 2) b.push_back(a[i]);
        else b.push_front(a[i]);
    }

    for (int i = 0; i < n; ++i)
        cout << b[i] << " \n"[i == n - 1];

    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	int n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	vector<vector<ll>>dp(n,vector<ll>(n,0));
	for(int i=0;i<n;i++)
	{
		dp[i][i]=v[i];
	}
	for(int len=2;len<=n;len++)
	{
		for(int i=0;i<=n-len;i++)
		{
			dp[i][i+len-1]=max(v[i+len-1]-dp[i][i+len-2],v[i]-dp[i+1][i+len-1]);
		}
	}
	cout<<dp[0][n-1]<<'\n';
}

int main()
{
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 70656
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

// const int mod=1e9+7;
const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class Combination {
    private:
    vector<int> x, y;
    int mod = (int)1e9 + 7;
    
    void make(int n) {
        x.resize(n+1);
        y.resize(n+1);        
        x[0] = y[0] = 1;
        for (int i = 1; i <= n; i++) {
            x[i] = (x[i-1]*i) % mod;
            y[i] = modpow(x[i],mod-2);
        }
    }
    
    int modpow(int x, int n) {
        int ret = 1;
        while (n > 0) {
            if ((n & 1)) {
                ret = ret * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }
    
    public:
    Combination(int n) {
        make(n);
    }
    
    Combination(int n, int mod) {
        this->mod = mod;
        make(n);
    }
    
    int get(int n, int r) {
        if (n < r) return 0;
        return x[n] * y[n - r] % mod * y[r] % mod;
    }
    
};

int modpow(int x, int n) {
    int ret = 1;
    while (n > 0) {
        if ((n & 1)) {
            ret = ret * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

void run(){
    int n,m,k;
    cin>>n>>m>>k;
    Combination comb(n,mod);
    int ans=0;
    rep(i,k+1){
        ans+=m*comb.get(n-1,i)%mod*modpow(m-1,n-1-i)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

bool comp(const pair<ll, ll> &a, const pair<ll, ll> &b){
    return a.first > b.first;
}

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

    map<ll, ll> len_cnt;
    rep(i, n){
        int a;
        cin >> a;
        len_cnt[a] ++;
    }

    vector<pair<ll, ll>> len_cnt_vec;
    for(auto itr = len_cnt.begin(); itr != len_cnt.end(); itr ++){
        if(itr->second >= 2) len_cnt_vec.push_back(pair<ll, ll>(itr->first, itr->second));
    }

    sort(all(len_cnt_vec), comp);

    if(len_cnt_vec.size() >= 1 && len_cnt_vec[0].second >= 4){
        cout << len_cnt_vec[0].first * len_cnt_vec[0].first << endl;
    }else if(len_cnt_vec.size() >= 2){
        cout << len_cnt_vec[0].first * len_cnt_vec[1].first << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 6528
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        String S = in.next();
        int n = S.length();
        String rev = new StringBuilder(S).reverse().toString();
        String leftRev = new StringBuilder(S.substring(0, (n-1)/2)).reverse().toString();
        String rightRev = new StringBuilder(S.substring((n+1)/2)).reverse().toString();
        if(S.equals(rev) && S.substring(0, (n-1)/2).equals(leftRev) && S.substring((n+1)/2).equals(rightRev)){
            println("Yes");
        }
        else{
            println("No");
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int a, b, c, d;
    int n, m;
    string s;
    vi v;
    vector<string> vs;

    string yes = "Yes", no = "No";
    cin >> s;
    bool f = false;
    REP(i, 1, s.size()) if(s[i] == 'C' && s[i-1] == 'A') f = true;
    cout << (f ? yes : no) << endl;

    return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
int main(){
	int a,b,c,d,e;
	scanf("%d%d%d",&a,&b,&c);
	d=b-a;
	e=c-b;
	if (d==e)
	{
		printf("YES\n");
	}else
	{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <utility>
using namespace std;

int shellSort(int a[], int n);
int insertionSort(int a[], int n, int g);

int main(void)
{	
	int n;
	cin >> n;
	
	int *a = new int[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	
	shellSort(a, n);
	
	delete[] a;
	
	return 0;
}

int shellSort(int a[], int n)
{	
	int *g = new int[n];
	g[0] = 1;
	int m, i = 1;
	while (1) {
		g[i] = g[i-1] * 3 + 1;
		if (g[i] > n) {
			m = i;
			break;
		}
		i++;
	}
	
	cout << m << endl;
	
	int cnt = 0;
	for (int i = m - 1; i >= 0; i--) {
		cout << g[i];
		if (i > 0) cout << " ";
		else cout << endl;
		
		cnt += insertionSort(a, n, g[i]);
	}
	
	delete[] g;
	
	cout << cnt << endl;
	
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	
	return cnt;
}

int insertionSort(int a[], int n, int g)
{
	int cnt = 0;
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v) {
			a[j+g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j+g] = v;
	}
	return cnt;
}

Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A = 0;
  cin >> N;
   for (int i = 0; i < N; i++) {
     int l;
     int r;
     cin >> l >> r;
     A += r - l + 1;
   }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    /**incomplete*/
    list<int>l;
    list<int>::iterator it = l.end();
    int test;
    cin>>test;
    while(test--)
    {
        int cs,num;
        cin>>cs;
        switch(cs)
        {
        case 0:
            cin>>num;
            l.insert(it,num);
            it--;
            break;
        case 1:
            cin>>num;
            advance(it,num);
            break;
        default:
            it = l.erase(it);
            break;
        }
    }
    for(it = l.begin();it!=l.end();it++)
            cout<<*it<<"\n";
    return 0;
}




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

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin >> x[i];
	}
	int ans = x[n-1] - x[0];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n<=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[n-2-i];
	    }
	}
	cout << ans << endl;
    }
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
int a[110];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)
		for(int k=j+1;k<=n;k++){
			int x[3];
			x[0]=a[i],x[1]=a[j],x[2]=a[k];
			sort(x,x+3);
			if(x[0]==x[1]||x[1]==x[2])continue;
			if(x[0]+x[1]>x[2])ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;

int n,m;

int query(int x,int k)
{
	if(x<k)return 0;

	if(x%k==0)return x/k;

	if((ll)k*k<x)return query(x-x/k-1,k);

	int v=x/k+1,lim=(v-1)*k;
	int dis=x-lim,t=(dis/v);
	if(!t)t++;

	return query(x-t*v,k);
}

int main()
{
	scanf("%d",&n);

	m=0;
	for(int x,y;n--;)
	{
		scanf("%d%d",&x,&y);
		m^=query(x,y);
	}

	if(m)printf("Takahashi\n");
	else printf("Aoki\n");
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int turn = 0;
	while (a > 0 && c > 0) {
		if (turn == 0) c -= b;
		else a -= d;
		turn ^= 1;
	}
	if (a > 0) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3640
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	W := nextInt(sc)
	H := nextInt(sc)
	x := nextInt(sc)
	y := nextInt(sc)
	r := nextInt(sc)

	if x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



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

X_Y = []

for _ in range(N):
    x,y = map(int, input().split())
    X_Y.append([x, y])
ans = 0
for i in range(N):
    x,y = X_Y[i][0], X_Y[i][1]
    if (x**2+y**2)**0.5<=D:
        ans = ans + 1

print(ans)

Measured memory_bytes: 39316
import math


def main():
    N, K = list(map(int, input().split(' ')))
    ans = 0
    for k in range(1, N + 1):
        if k < K:
            n = math.ceil(math.log2(K / k))
            ans += 1 / (N * (2**n))
        else:
            # Only for N >= k >= K
            ans += 1 / N
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (modpow(2, n) + MOD - 1) % MOD;
    ll s = 1;
    for(ll i = n; i > n - a; i--){
        s = s * i % MOD;
    }
    for(ll i = 1; i <= a; i++){
        s = s * modpow(i, MOD - 2) % MOD;
    }
    ans = (ans + MOD - s) % MOD;
    s = 1;
    for(ll i = n; i > n - b; i--){
        s = s * i % MOD;
    }
    for(ll i = 1; i <= b; i++){
        s = s * modpow(i, MOD - 2) % MOD;
    }
    ans = (ans + MOD - s) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
typedef complex<int> P;
#define x real()
#define y imag()

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
P D[4];
int main(){
  int n;
  for(int i=0;i<4;++i) D[i]=P(dx[i],dy[i]);
  while(cin>>n,n){
    vector<P> art;
    art.push_back(P(0,0));
    for(int i=0;i<n-1;++i){
      int a,d;
      cin >> a >> d;
      art.push_back(art[a]+D[d]);
    }
    int maxx = 0,minx = n;
    for(int i=0;i<n;++i){
      maxx = max(maxx, art[i].x);
      minx = min(minx, art[i].x);
    }
    int maxy = 0,miny = n;
    for(int i=0;i<n;++i){
      maxy = max(maxy, art[i].y);
      miny = min(miny, art[i].y);
    }
    cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
using namespace std;
int main(){
    string b;
    cin >> b;
    string a = b;
    for(int i = 0;i<b.size();i++){
        if(b.at(i) == 'A')a.at(i) = 'T';
        else if(b.at(i) == 'T')a.at(i) = 'A';
        else if(b.at(i) == 'G')a.at(i) = 'C';
        else a.at(i) = 'G';
    }
    cout << a <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
int main()
{

    double a,b,C;
    std::cin >> a >> b >> C;

    double pi = 3.14159265897932;
    std::cout <<std::setprecision(12);
    std::cout <<std::setiosflags(std::ios::fixed);
    std::cout << a*b*std::sin(C/180*pi)/2 << "\n";
    std::cout << a + b + std::sqrt(a*a+b*b-2*a*b*std::cos(C/180*pi)) << "\n";
    std::cout <<b*std::sin(C/180*pi) << "\n";
    return 0;
}


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

int main(){
    long long N;
    string s;
    map<vector<char>, long long> mp;
    cin >> N;
    for(long long i=0;i<N;i++){
        cin >> s;
        vector<char> vs;
        for(auto as : s){
            vs.push_back(as);
        }
        sort(vs.begin(), vs.end());
        mp[vs] += 1;
    }

    long long ans = 0;
    for(auto m: mp){
        if(m.second > 1){
            ans += (m.second * (m.second - 1)) / 2;
        }
    }

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

Measured memory_bytes: 11136
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

int main() {
  stack<int> st;
  string str;
  while (cin >> str) {
    if (str == "+" || str == "-" || str == "*") {
      int right = st.top();
      st.pop();
      int left = st.top();
      st.pop();
      switch (str[0]) {
        case '+': {
          st.push(left+right);
          break;
        }
        case '-': {
          st.push(left-right);
          break;
        }
        case '*': {
          st.push(left*right);
          break;
        }
      }
      continue;
    } else {
      st.push(atoi(str.c_str()));
    }
  }
  printf("%d\n", st.top());

  return 0;
}

Measured memory_bytes: 3344
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int a = iin(), b = iin();
    iout((a + b) % 24);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


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


int main() {
	
	int n;
	cin >> n;
	set<int> a;
	for(int i=0; i<n; i++) {
		int b;
		cin >> b;
		a.insert(b);
	}
	cout << (a.size()==n ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+1;
const int inf = 0x7ffffff;

int X,k,Q,ans[N];
struct nd{int t,a,id;}q[N];
bool cmp(nd a,nd b){return a.t<b.t;}
int up(int &x){if(x<0)x=0;if(x>X)x=X;}
int main()
{
	scanf("%d%d",&X,&k);
	for(int i=1;i<=k;++i)scanf("%d",&q[i].t);
	scanf("%d",&Q);
	for(int i=1;i<=Q;++i)
	scanf("%d%d",&q[i+k].t,&q[i+k].a),q[i+k].id=i;
	sort(q+1,q+Q+k+1,cmp);
	int a=0,b=X,l=0,r=X,tag=-1,pre=0;
	for(int i=1;i<=Q+k;++i)
	{
		if(q[i].id)
		{
			int ret=0,res=q[i].t-pre;
			if(q[i].a<=l)ret=a;
			else if(q[i].a>=r)ret=b;
			else ret=a-l+q[i].a;
			ret+=res*tag;
			up(ret);
			ans[q[i].id]=ret;
		}
		else
		{
			
			int v=q[i].t-pre;
			if(tag==-1)
			{
				if(v>a)
				{
					b-=v;l+=v-a;
					up(b);up(l);
					if(r<l)r=l;
					a=0;
				}
				else	a-=v,b-=v;
			}
			else
			{
				if(v+b>X)
				{
					a+=v;r-=b+v-X;
					up(a);up(r);
					if(r<l)l=r;
					b=X;
				}
				else	a+=v,b+=v;
			}
			tag*=-1;
			pre=q[i].t;
		}
	}
	for(int i=1;i<=Q;++i)printf("%d\n",ans[i]);
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int gcd(int a, int b){
    if(a%b == 0) return b;
    return gcd(b, a%b);
}
int main(void){
    int n, m;
    vector<int> a;
    cin >> n >> m;
    a.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) a[i] /= 2;
    long long lcm = a[0], ans = 0;
    for(int i=1;i<n;i++){
        long long g = gcd(lcm, a[i]);
        lcm = lcm * a[i] / g;
        if(lcm > m){
            cout << 0 << endl;
            return 0;
        }
    }
    ans = m / lcm - m / (lcm * 2);
    int v;
    for(int i=0;i<n;i++){
        int cnt = 0;
        while(a[i]%2 == 0){
            a[i] /= 2;
            cnt++;
        }
        if(i == 0) v = cnt;
        if(v != cnt){
            ans = 0;
            break;
        }
    }
    cout << ans << endl;
}


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

int main(void){
    
    int N,len;
    cin >> N;
    len = N * 0.9;
    
    for(int i=len;i<=N;i++){
        if((int)(i* 1.08) == N){
            cout << i <<endl;
            break;
        }
       
       if(i == N) cout << ":(" <<endl;
    }
    
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(){
	int n,t,i,j;
	while(cin>>n,n){
		int c[10]={0};
		for(i=0;i<n;i++)cin>>t,c[t]++;
		for(i=0;i<10;i++){if(!c[i])cout<<'-';else for(j=0;j<c[i];j++)cout<<'*';cout<<endl;}
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    string w,t;
    int i, ans = 0;
    cin >> w;
    for(i=0; i<w.size(); i++){
         if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
    }
  cin >> t;
  while(t!="END_OF_TEXT"){
    for(i=0; i<t.size(); i++) {
      if('A' <= t[i] && t[i] <= 'Z') t[i]+='a'-'A';
    }
    if(w == t) ans++;
    cin >> t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x, y;
    x = x2 - x1;
    y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a;
  scanf("%d",&a);
  if (a<=104) printf("%d",0);
  else if (a<=134) printf("%d",1);
  else if (a<=164)  printf("%d",2);
  else if (a<=188) printf ("%d",3);
  else if (a<=194) printf("%d",4);
  else printf("%d",5);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

main(){
  double in;
  while(cin >> in){
    double data=(in*100.0);
    if(data<=4800){
      printf("light fly\n");
    }else if(data<=5100){
      printf("fly\n");
    }else if(data<=5400){
      printf("bantam\n");
    }else if(data<=5700){
      printf("feather\n");
    }else if(data<=6000){
      printf("light\n");
    }else if(data<=6400){
      printf("light welter\n");
    }else if(data<=6900){
      printf("welter\n");
    }else if(data<=7500){
      printf("light middle\n");
    }else if(data<=8100){
      printf("middle\n");
    }else if(data<=9100){
      printf("light heavy\n");
    }else{
      printf("heavy\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	if(A*N > B){
		cout << B << endl;
	} else{
		cout << A*N << endl;
	}
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

def check(A, mod2):
    cur = res = 0
    for i in range(N):
        cur += A[i]
        if i % 2 == mod2:
            # 0以下なら1にする
            if cur <= 0:
                # cur + x = 1 → x = 1 - cur
                A[i] += 1 - cur
                res += 1 - cur
                cur += 1 - cur
        else:
            # 0以上なら-1にする
            if cur >= 0:
                # cur - x = -1 → x = 1 + cur
                A[i] -= 1 + cur
                res += 1 + cur
                cur -= 1 + cur
    return res
    
ans = min(check(A[:], 0), check(A[:], 1))
print(ans)


Measured memory_bytes: 14332
#include <stdio.h>
#include <stdlib.h>

#define N 1000000

struct queue {
	int data[N];
	char name[N][11];
	int head;
	int tail;
	int max;
};

void initialize( struct queue *q, int max ) {
	int i = 0;
	int j = 0;
	
	q -> head = 0;
	q -> tail = 0;
	q -> max = max;
	for( i = 0; i < max; i++ ) {
		q -> data[i] = 0;
		for ( j = 0; j < 11; j++ ) {
			q -> name[i][j] = '\0';
		}
	}
}

void enqueue( struct queue *q, int item, char* name ) {
	int i = 0;
	
	if ( q -> tail >= q -> max ) {
		q -> tail = 0;
	}
	
	q -> data [ q -> tail ] = item;
	for ( i = 0; name[i] != '\0'; i++ ) {
		q -> name [ q -> tail ][i] = name[i];
	}
	q -> name[ q -> tail ][i] = '\0';
	q -> tail++;
	
}

int dequeue( struct queue *q , char* name ) {
	int tmp = 0;
	int i = 0;
	
	if ( q -> head >= q -> max ) {
		q -> head = 0;
	}
	

		tmp = q -> data[ q -> head ];
		for ( i = 0; q -> name [ q -> head ][i] != '\0'; i++ ) {
			name[i] = q -> name [ q -> head ][i];
		}
		name[i] = '\0';
		q -> head++;
		return tmp;
}

int main(void)
{
	int max_order			= 0;
	int quantum				= 0;
	char str[256]			= {};
	int i 					= 0;
	int j					= 0;
	struct queue process	= {};
	int total_time			= 0;
	int flag				= 0;
	int time				= 0;
	int result[N]			= {};
	char result_name[N][11] = {};
	
	fgets( str, 256, stdin );
	for ( i = 0; str[i] != ' '; i++ ) {
	}
	str[i] = '\0';
	max_order = atoi(&str[0]);
	quantum   = atoi(&str[i+1]);
	
	initialize( &process, max_order );
	
	
	for ( j = 0; j < max_order; j++ ) {
		fgets( str, 256, stdin );
		for ( i = 0; str[i] != ' '; i++ ) {
		}
		str[i] = '\0';
		enqueue( &process, atoi(&str[i+1]), &str[0] );
	}
//	enqueue( &process, atoi(&str[i+1]), &str[0] );

	j = 0;
	flag = 0;
	total_time = 0;
	time = 0;
	
	
	while ( 1 ) {
		if ( flag >= max_order ) {
			break;
		}
		
		time = dequeue( &process, str );

		if ( time <= quantum ) {
			total_time += time;
			result[j] = total_time;
			for ( i = 0; str[i] != '\0'; i++ ) {
				result_name[j][i] = str[i];
			}
			result_name[j][i] = '\0';
			j++;
			flag++;
			
		} else {
			time -= quantum;
			total_time += quantum;
			enqueue(&process, time, str);
		}
	}
	
	for ( i = 0; i < max_order; i++ ) {
		printf("%s %d\n", result_name[i], result[i]);
	}
		
	
	
	
	return 0;
}


Measured memory_bytes: 31072
#include<stdio.h>

int main(){
	
	int N,A[210],i,ans=100,k;
	
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		k=0;
		scanf("%d",&A[i]);
		
		while(A[i]%2==0){
			A[i]=A[i]/2;
			k++;
		}
		if(k<ans){
			ans=k;
		}
	}
	
	printf("\n\n%d\n\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
N=int(input())
X=list(map(int,input().split()))
Y=[X[i+1]-X[i] for i in range(N-1)]
m=10**9+7
a,b=0,0
for i,y in enumerate(Y):
    b=(b+pow(i+1,m-2,m))%m
    a=(a+b*y)%m
f=1
for n in range(2,N):
    f=(f*n)%m
print(a*f%m)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll a,b,h,m;
       dd x,y,pi=2*acos(0.0);
       cin>>a>>b>>h>>m;
       x=(dd)(((h*60+m)%720)/720.0);
       x*=12;
       y=(dd)m/60;
       y*=12;
       dd z=abs(x-y);
       //cout<<x<<" "<<y<<" "<<z<<" "<<pi<<"\n";
       z*=pi/6;
       dd ans=sqrtl(a*a+b*b-2*a*b*cos(z));
       cout<<fixed<<setprecision(20)<<ans;
   }
}

Measured memory_bytes: 4176
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using lli = long long int;
using pii = pair<lli, lli>;

int main(){
  lli n, m;
  std::cin >> n >> m;
  vector<pii> drink(n);
  lli x, y;
  for (int i = 0; i < n; i++)
    std::cin >> drink[i].first >> drink[i].second;
  sort(drink.begin(), drink.end());
  lli ans = 0;
  for (int i = 0; i < n and m > 0; i++) {
    if(m <= drink[i].second){
      ans += m*drink[i].first;
      m = 0;
    }else{
      ans += drink[i].second*drink[i].first;
      m -= drink[i].second;
    }
  }
  std::cout << ans << std::endl;    
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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);
	int i,j;
	ll x;
	cin>>x;
	ll d=100;
	int y=0;
	while(1){
		y++;
		d = d + d/100;
		//cout<<d<<endl;
		if(d>=x) {
			cout<<y<<endl;
			return 0;
		}
	}


}

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

int n;
int f[104][10] = {0};
int p[105][15] = {0};

int solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 10; ++j) cin >> f[i][j];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j <= 10; ++j) cin >> p[i][j];
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = -2000000000;
  for(int i = 1; i < (1 << 10); ++i) {
    int now = 0;
    for(int j = 0; j < n; ++j) {
      int cnt = 0;
      for(int k = 0; k < 10; ++k)
        if(f[j][k] & (i >> k)) ++cnt;
      now += p[j][cnt];
    }
    ans = max(now, ans);
  }
  return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int M = N;
  int countS = 0;
  int countT = 0;
  
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'S'){
      countS++;
    }
    if (S.at(i) == 'T' && countS > 0){
      M -= 2;
      countS--;
    }
  }
  cout << M << endl;
}
    
  

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

vector<vector<ll>> rnd(100, vector<ll>(26));
int p, var;

ll sum(string& s);

ll num(string& s)
{
	ll res = 0;
	while (isdigit(s[p]))
	{
		res *= 10;
		res += s[p] - '0';
		p++;
	}
	return res;
}

ll unit(string& s)
{
	ll res;
	while (s[p] == ' ') p++;
	if (s[p] == '(')
	{
		p++;
		res = sum(s);
		p++;
	}
	else if (isdigit(s[p])) res = num(s);
	else if (islower(s[p]))
	{
		res = rnd[var][s[p] - 'a'];
		p++;
	}
	else assert(false);
	return res;
}

ll pow(string& s)
{
	ll lhs = unit(s);
	while (s[p] == '^')
	{
		p++;
		while (s[p] == ' ') p++;
		ll rhs = pow(s);
		ll tmp = 1;
		REP(i, rhs)
		{
			tmp *= lhs;
		}
		lhs = tmp;
	}
	return lhs;
}

ll mul(string& s)
{
	ll lhs = pow(s);
	while (s[p] == '*')
	{
		p++;
		ll rhs;
		rhs = pow(s);
		lhs *= rhs;
	}
	return lhs;
}

ll sum(string& s)
{
	ll lhs = mul(s);
	while (s[p] == '+' || s[p] == '-')
	{
		if (s[p] == '+')
		{
			p++;
			ll rhs = mul(s);
			lhs += rhs;
		}
		else
		{
			p++;
			ll rhs = mul(s);
			lhs -= rhs;
		}
	}
	return lhs;
}

ll parse(string& s)
{
	p = 0;
	return sum(s);
}

bool isMulti(char a, char b, bool flag) {
	if (flag && isdigit(a) && isdigit(b)) return true;
	if (isdigit(a) && islower(b)) return true;
	if (islower(a) && islower(b)) return true;
	if (islower(a) && isdigit(b)) return true;
	if ((a == ')') && (b == '(')) return true;
	if ((a == ')') && (isdigit(b) || islower(b))) return true;
	if ((isdigit(a) || islower(a)) && (b == '(')) return true;
	return false;
}

string make(string s) {
	string tmp, res;
	stringstream ss;
	ss << s;
	vector<string> buf;
	while (!(ss >> s).fail()) buf.push_back(s);
	REP(i, buf.size()) 
	{
		if (i + 1 < buf.size() && isMulti(buf[i].back(), buf[i + 1][0], true)) 
		{
			tmp += (buf[i] + "*");
		}
		else tmp += buf[i];
	}
	REP(i, tmp.size()) {
		if (i + 1 < tmp.size() && isMulti(tmp[i], tmp[i + 1], false)) res += string(1, tmp[i]) + "*";
		else res += string(1, tmp[i]);
	}
	return res;
}

int main()
{
	string s, t;
	REP(i, 100)REP(j, 26) rnd[i][j] = rand() % 20;
	while (getline(cin, s), s != ".")
	{
		string s_ = make(s);
		while (getline(cin, t), t != ".")
		{
			string t_ = make(t);
			bool f = true;
			for (var = 0; var < 100 && f; var++)
			{
				ll lhs = parse(s_);
				ll rhs = parse(t_);
				if (lhs != rhs) f = false;
			}
			puts(f ? "yes" : "no");
		}
		puts(".");
	}
	return 0;
}

Measured memory_bytes: 3144
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, a, b int
	fmt.Fscan(read, &n, &a, &b)
	fmt.Fprintln(write, min(b, a*n))
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

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

    static class DIntegerCards {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            ArrayList<node> b = new ArrayList<>();
            for (int i = 0; i < n; i++) a.add(in.nextInt());
            for (int i = 0; i < m; i++) {
                b.add(new node(in.nextInt(), in.nextInt()));
            }
            Collections.sort(a);
            Collections.sort(b, new Comparator<node>() {

                public int compare(node o1, node o2) {
                    return o2.c - o1.c;
                }
            });
            int j = 0;
            for (int i = 0; i < m; i++) {
                while (j < n && b.get(i).b > 0) {
                    if (a.get(j) < b.get(i).c) {
                        a.set(j, b.get(i).c);
                        b.get(i).b = b.get(i).b - 1;
                    }
                    j++;
                }
            }
            long ans = 0;
            for (int i = 0; i < n; i++) ans += a.get(i);
            out.println(ans);
        }

        class node {
            int b;
            int c;

            node(int b, int c) {
                this.b = b;
                this.c = c;
            }

        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 49376
#include<stdio.h>

int main(){
	int a,b,i,j,cnt,tmp1,tmp2,tmp3,tmp4,tmp5;
	scanf("%d%d",&a,&b);
	for(i=0;i<=b-a;i++){
		j=a+i;
		tmp5=j%10;
		j=j/10;
		tmp4=j%10;
		j=j/10;
		tmp3=j%10;
		j=j/10;
		tmp2=j%10;
		j=j/10;
		tmp1=j%10;
		if(tmp1==tmp5 &&tmp2==tmp4){
			cnt++;
		}
	}

	printf("%d\n",cnt);
	return 0;
	}


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

int main()
{
    int yyyy, mm, dd;
    char _1, _2;
    cin >> yyyy >> _1 >> mm >> _2 >> dd;
    cout << (mm <= 4 ? "Heisei" : "TBD") << endl;
    return 0;
}

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

int main(){
    int n, m, c;
    int total=0;

    cin >> n >> m >> c;

    vector<int> b(m,0);
    vector< vector<int> > a(n,vector<int>(m));
    int x;

    for(int j=0; j<m; j++){
        cin >> b[j];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<n; i++){
        x=0;
        for(int j=0; j<m; j++){
            x+=b[j]*a[i][j];
        }
        x+=c;
      if(x>0){
        total++;
      }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> num(K, 0);
    for(int i=1; i<=N; i++) num[i%K]++;
    ll res = 0;
    for(int a = 0; a < K; a++) {
        int b = (K-a)%K;
        int c = (K-a)%K;
        if((b+c) % K != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    unordered_map<ll, vector<ll>> graph;
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    queue<edge> queue;
    vector<vector<bool>> visited(N, vector<bool>(4, false));
    queue.push({0, {s, 0}});
    visited[s][0] = true;
    ll ans = 0;
    while (!queue.empty()) {
        edge p = queue.front();
        queue.pop();
        for (ll v : graph[p.second.first]) {
            if (visited[v][(p.second.second + 1) % 3]) {
                continue;
            } else {
                visited[v][(p.second.second + 1) % 3] = true;
                if (v == t && p.second.second == 2) {
                    ans = ++p.first;
                    break;
                }
                int tmp = p.first;
                if ((p.second.second + 1) % 3 == 0) {
                    tmp++;
                }
                queue.push({tmp, {v, (p.second.second + 1) % 3}});
            }
        }
    }
    cout << (visited[t][0] ? ans : -1) << endl;
}

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


Measured memory_bytes: 16164
#include <stdio.h>
 
int main(int argc, const char * argv[]) {

    int count[4][3][10]={0};
    int n, b, f, r, v, i, j, k;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i<3){
            printf("####################\n");
        }
    }
     
     
     
    return 0;
}

Measured memory_bytes: 612