akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;



int main(){
	int N;
	cin>>N;
	double ans = 0;
	for(int i=0;i<N;i++){
		double x;
		string s;
		cin>>x>>s;
		if(s=="JPY")ans+=(double)x;
		else{
			ans+=(double)380000.0*x;
		}
	}
	
	cout<<fixed<<setprecision(12)<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#define _DEBUG 1

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

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

void solve(ll A, ll P) {
  cout << (3* A + P) / 2  << endl;  
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll A;
  scanf("%lld", &A);
  ll P;
  scanf("%lld", &P);
  solve(A, P);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      int c = int.Parse(input[2]);
      int[] d = {a,b,c};
      Array.Sort(d);
      
      Console.WriteLine(d[0]+d[1]);
    }
}


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

const int MAXN = 5005;
const int MOD = 1000000007;

long long modpow(long long r, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return r * modpow(r, p - 1) % MOD;
	
	long long x = modpow(r, p / 2);
	return x * x % MOD;
}

int n, p[MAXN];
vector <int> g[MAXN];
bool vis[MAXN];

long long dp[MAXN][2 * MAXN], fact[MAXN];

int sz, col;
void dfs(int u){
	sz++;
	col += (p[u] == -1);
	vis[u] = true;
	
	for(int v : g[u]){
		if(vis[v])continue;
		dfs(v);
	}
}

int main(){
	scanf("%d", &n);
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &p[i]);
		
		if(p[i] != -1){
			g[i].push_back(p[i] - 1);
			g[p[i] - 1].push_back(i);
		}else{
			cnt++;
		}
	}
	
	long long res = 0;
	
	vector <int> z, w;
	
	for(int i = 0; i < n; i++){
		if(vis[i])continue;
		
		sz = 0;
		col = 0;
		dfs(i);
		
		if(col == 0){
			w.push_back(sz);
		}else{
			z.push_back(sz);
		}
	}
	int a = w.size(), b = z.size();
	
	for(int i = 0; i <= n; i++){
		if(i == 0)fact[i] = 1;
		else fact[i] = i * fact[i - 1] % MOD;
	}
	
	for(int i = b; i >= 0; i--)
	for(int cnt = 0; cnt <= n; cnt++){
		if(i == b){
			if(cnt >= 2){
				dp[i][cnt] = fact[cnt - 1];
			}
		}else{
			dp[i][cnt] = ((n - 1) * dp[i + 1][cnt] + z[i] * dp[i + 1][cnt + 1]) % MOD;
		}
	}
	res = (res + dp[0][0]) % MOD;

	for(int i = 0; i < b; i++)
		res = (res + (z[i] - 1) * modpow(n - 1, b - 1)) % MOD;
	
	res = ((n - a) * modpow(n - 1, cnt) - res + MOD) % MOD;
	printf("%lld\n", res);
	
	return 0;
}


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

int main(){
	int N;
	string A,B,C;
	cin>>N>>A>>B>>C;
	int ans=0;
	int a=0;
	rep(i,N){
		if(A.at(i)==B.at(i)){
			a++;
		}
		if(B.at(i)==C.at(i)){
			a++;
		}
		if(C.at(i)==A.at(i)){
			a++;
		}
		if(a==0){
			ans++;
			ans++;
		}else if(a==1){
			ans++;
		}else if(a==3){

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

/*compile
g++ code.cpp
./a.out
run*/

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using vpi=vector<pii>;
using tpi=tuple<int, int, int>;

int main() {
    int N, Q;
    cin >> N >> Q;
    map<int, vi> m;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        m[a].emplace_back(b);
        m[b].emplace_back(a);
    }

    vl xx(N + 1);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        xx[p] += x;
    }

    vi parent(N + 1);
    parent[1] = 1;

    queue<int> q;
    q.push(1);
    while (!q.empty()) {
        int i = q.front();
        q.pop();
        for (auto item:m[i]) {
            if (item != parent[i]) {
                xx[item]+=xx[i];
                parent[item] = i;
                q.push(item);
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        cout << xx[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 28020
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c;cin>>a>>b>>c;
	cout<<max({a,b,c})-min({a,b,c});
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

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

# N = int(input())
# L = [int(x) for x in input().split()]
# N, M = map(int, input().split())
S = input()

flag = False
for i in range(3):
    if S[i] == S[i + 1]:
        flag = True

print("Bad" if flag else "Good")


Measured memory_bytes: 38384
n, m, k = map(int, input().split())

MOD = 998244353
ans, N, K = 0, 1, 1

for i in range(k+1):
    ans += N * pow(K, MOD-2, MOD) * pow(m-1, n-1-i, MOD)
    ans %= MOD
    N *= n-1-i
    N %= MOD
    K *= i+1
    K %= MOD
ans *= m
ans %= MOD
print(ans)

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

using namespace std;

inline void scanint(int *x) 
{ 
	register char c = getchar_unlocked(); 
	*x = 0; 
	for(; (c<48)||(c>57);c = getchar_unlocked()); 
	for(; (c>47)&&(c<58);c = getchar_unlocked()) 
		*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48); 
} 

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    constexpr int A_MAX = 1000000;

    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }

    int N;
    scanint(&N);
    vector<int> a(A_MAX + 1);
    for (int i = 0; i < N; ++i) {
        int A;
        scanint(&A);
        ++a[A];
    }

    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            if (a[n] == N) {
                cout << "not coprime" << endl;
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 15524
import sys
sys.setrecursionlimit(10 ** 9)

h,w = map(int,input().split())
maze = [list(input().rstrip()) for _ in range(h)]
#print(maze)

from collections import deque
b = 0
INF = float("inf")
checked = [[INF]*w for i in range(h)]

q = deque([])
q.append((0,0))
checked[0][0] = 1
while len(q)>0:
    pos = q.popleft()
    if pos == (h-1,w-1):
        b = (checked[h-1][w-1])
        break
    if pos[0] > 0:
        if not maze[pos[0] - 1][pos[1]] == '#' and checked[pos[0] - 1][pos[1]] == INF:
            checked[pos[0] - 1][pos[1]] = checked[pos[0]][pos[1]] + 1
            q.append((pos[0] - 1, pos[1]))

    if pos[0] < h - 1:
        if not maze[pos[0] + 1][pos[1]] == '#' and checked[pos[0] + 1][pos[1]] == INF:
            checked[pos[0] + 1][pos[1]] = checked[pos[0]][pos[1]] + 1
            q.append((pos[0] + 1, pos[1]))

    if pos[1] > 0:
        if not maze[pos[0]][pos[1] - 1] == '#' and checked[pos[0]][pos[1] - 1] == INF:
            checked[pos[0]][pos[1] - 1] = checked[pos[0]][pos[1]] + 1
            q.append((pos[0], pos[1] - 1))

    if pos[1] < w - 1:
        if not maze[pos[0]][pos[1] + 1] == '#' and checked[pos[0]][pos[1] + 1] == INF:
            checked[pos[0]][pos[1] + 1] = checked[pos[0]][pos[1]] + 1
            q.append((pos[0], pos[1] + 1))
a = []
for i in range(h):
    a.append(maze[i].count("."))
if not b == 0:
    print(sum(a)-b)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
vector<int> enum_div(int n){
vector<int> ret;
for(int i = 1 ; i*i <= n ; ++i){
if(n%i == 0){
ret.push_back(i);
if(i != 1 && i*i != n){
ret.push_back(n/i);
}
}
}
return ret;
}

int main(){
    int n;
    int count=0;
    cin >> n;
    for(int i=1; i <=n; i+=2){
       if(enum_div(i).size() ==7)count+=1;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
r,g,b,n = map(int,input().split())
ans = 0
x=n//r+1
y=n//g+1
for i in range(x):
    for j in range(y):
        if r*i+g*j > n:
            break
        if (n-r*i-g*j)%b == 0:
            ans+=1
print(ans)

Measured memory_bytes: 40812
<?php
fscanf(STDIN, "%d %d %d", $w, $h, $n);

for($xi = 1; $xi <= $w; $xi++) {
	for($yi = 1; $yi <= $h; $yi++) {
		$map[$xi][$yi] = 1;
    }
}

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d %d", $x, $y, $a);
    switch($a) {
    	case 1:
    		for($xi = 1; $xi <= $x; $xi++) {
    			for($yi = 1; $yi <= $h; $yi++) {
    			$map[$xi][$yi] = 0; 
    			}
    		}
    		break;
    	case 2:
    		for($xi = $x + 1; $xi <= $w; $xi++) {
    			for($yi = 1; $yi <= $h; $yi++) {
    			$map[$xi][$yi] = 0; 
    			}
    		}
    		break;
    	case 3:
    		for($xi = 1; $xi <= $w; $xi++) {
    			for($yi = 1; $yi <= $y; $yi++) {
    			$map[$xi][$yi] = 0; 
    			}
    		}
    		break;
    	case 4:
    		for($xi = 1; $xi <= $w; $xi++) {
    			for($yi = $y + 1; $yi <= $h; $yi++) {
    			$map[$xi][$yi] = 0; 
    			}
    		}
    		break;
    }
}

$sum = 0;
foreach($map as $array) {
    foreach($array as $value) {
        $sum += $value;
    }
}
echo $sum."\n";

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  ll sum(0);
  for(int i(0);i<N;i++){
    cin>>A[i];
    if(i != 0) {
      sum += A[i];
      sum %= MOD;
    }
  }
  ll ans(0);
  for(int i(0);i<N-1;i++){
    ans += A[i]*sum;
    ans %= MOD;
    sum -= A[i+1];
    if(sum < 0) sum += MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4852
N = [int(i) for i in input()]
n = N[::-1]+[0]
for i in range(len(n)-1):
    if n[i] >= 6 or (n[i] == 5 and n[i+1] >= 5):
        n[i] = 10 - n[i]
        n[i+1] += 1
print(sum(n))

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

int main() {
    long long int N, K, mod = 998244353, ans = 0;
    cin >> N >> K;

    vector<long long int> L, R, DP(N+1), pSum(N+1);
    
    rep(i, K){
        long long int l, r;
        cin >> l >> r;
        L.push_back(l);
        R.push_back(r);
    }
   
    DP[1] = 1;
    pSum[1] = 1;

    for(int i=2; i<=N; i++){
        rep(k, K){
            if(i >= R[k]+1){
                DP[i] -= pSum[i-R[k]-1];
            }
            if(i >= L[k]){
                DP[i] += pSum[i-L[k]];
            }
        }
        
        DP[i] = (DP[i]%mod + mod)%mod;
        pSum[i] = (pSum[i-1] + DP[i])%mod;
    }
    

    cout << DP[N];

    return 0;
}

Measured memory_bytes: 6344
import java.util.*;
import java.io.*;
class Main {
    static class Triplet implements Comparable<Triplet> {
        int weight;
        int strength;
        long value;
        Triplet(int weight, int strength, long value) {
            this.weight = weight;
            this.strength = strength;
            this.value = value;
        }
        public int compareTo(Triplet other) {
            return this.weight+this.strength-other.weight-other.strength;
        }
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weights = new int[n];
        int[] strengths = new int[n];
        long[] values = new long[n];
        Triplet[] triplets = new Triplet[n];
        int maxWeight = 0;
        for(int i = 0; i<n; i++) {
            weights[i] = sc.nextInt();
            strengths[i] = sc.nextInt();
            values[i] = sc.nextLong();
            triplets[i] = new Triplet(weights[i], strengths[i], values[i]);
            maxWeight = Math.max(maxWeight, weights[i]);
        }
        Arrays.sort(triplets);
        long[] dp = new long[n*maxWeight+1];
        for(int i = 0; i<n; i++) {
            for(int j = triplets[i].strength; j>=0; j--) {
                int newWeight = j+triplets[i].weight;
                if(newWeight<dp.length)
                    dp[newWeight] = Math.max(dp[newWeight], dp[j]+triplets[i].value);
            }
        }
        long max = 0;
        for(long i: dp)
            max = Math.max(max, i);
        System.out.println(max);
    }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] A = new int[N];
        int one_position = 0;
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
            if (A[i] == 1) {
                one_position = i;
            }
        }
        System.out.println(solve(N, K, A, one_position));
    }
    public static int solve(int N, int K, int[] A, int one_position) {
        if (N == K) {
            return 1;
        }
        int answer = both(N, K, one_position);
        answer = Math.min(answer, left(N, K));
        answer = Math.min(answer, right(N, K));
        return answer;
    }
    public static int both(int N, int K, int one_position) {
        int answer = 0;
        int current = one_position;
        while (0 < current) {
            answer += 1;
            current -= (K-1);
        }
        current = one_position;
        while (current < N - 1) {
            answer += 1;
            current += (K-1);
        }
        return answer;
    }
    public static int left(int N, int K) {
        int answer = 0;
        int current = 0;
        while (current < N - 1) {
            answer += 1;
            current += (K - 1);
        }
        return answer;
    }
    public static int right(int N, int K) {
        int answer = 0;
        int current = N - 1;
        while (0 < current) {
            answer += 1;
            current -= (K - 1);
        }
        return answer;
    }
}


Measured memory_bytes: 50264
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int n,i;
	while(scanf("%d",&n)!=EOF){
		i=1;
		while(n>1){
			if(n%2==1)
				printf("%d ",i);
			i*=2;
			n/=2;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 596
H, W = map(int, input().split())
A = [None]*H
for i in range(H):
    A[i] = list(map(int, input().split()))
B = [None]*H
for i in range(H):
    B[i] = list(map(int, input().split()))

# C: A-Bの絶対値を持つ
C = [[None]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])

K = 80*(H+W-1)//2 + 1# 80*(H+W-1)の半分を超えるのは無駄
dp = [[[0]*(K+1) for _ in range(W)] for _ in range(H)]# 答えから80*(H+W-1)を引く
dp[0][0][C[0][0]] = 1

for i in range(H):
    for j in range(W):
        for k in range(K+1):
            if i and dp[i-1][j][k]:
                if k+C[i][j] < K:
                    dp[i][j][k+C[i][j]] = 1
                dp[i][j][abs(k-C[i][j])] = 1
            if j and dp[i][j-1][k]:
                if k+C[i][j] < K:
                    dp[i][j][k+C[i][j]] = 1
                dp[i][j][abs(k-C[i][j])] = 1

for k in range(K+1):
    res = dp[H-1][W-1][k]
    if res:
        print(k)
        break

Measured memory_bytes: 393984
// #include<bits/stdc++.h>
// using namespace std;
// #define int long long
// #define pii pair<int,int>
// const int mod=1e9+7;
 
// int dx[]={-1, 0, 1, 0};
// int dy[]={0, -1, 0, 1};

// int mn;
// void call(int d,int x,vector<int>&v)
// {
//     int in=-1;
//     for(int i=0;i<5;i++)
//     {
      
//       if(v[i]==0)continue;
      
//       else if(v[i]<x)
//       {
//         int p=v[i];
//         v[i]=0; 
//         call(d+1,p*2,v);
//         v[i]=p; in=i;
//       }
//       else{
//         int p=v[i];
//         v[i]-=x;
//         v[i]=min((p-x)*2,p);
//         call(d+1,x*2,v);
//         v[i]=p; in=i;
//       }

//     }
//     if(in==-1)
//     {
//       mn=min(mn,d);
//     }
    
// }


// void solve(vector<int>&v,int x)
// {
//   int n=5;
//   int z=x;
//   int ans=0;
//   multiset<int>ms;
//   for(int i=0;i<n;i++)
//   {
    
//     ms.insert(v[i]);
//   }
  
//   sort(v.begin(),v.end());
//   int i=n-1;
//   while(i>=1)
//   {
//     if(v[i-1]*2>=v[i])
//     {
//       i--;
//     }
//     else break;
//   }

//   int p=v[i];
//   int cnt=0;
 
//   while(x<p)
//   {
//     auto z=ms.lower_bound(x);
//     if(*z==x)
//     {
//       ms.erase(z); x=x*2; cnt++; continue;
//     }
//     if(z==ms.begin())
//     {
//       x=2*x; cnt++; continue;
//     }
//     z--;
//     int a,b;
    
//     a=ceil(log2((1.0*p)/x));
//     b=ceil(log2((1.0*p)/(*z)));
    
//     if(a==b-1)
//     {
//       x=2*(*z); cnt++; ms.erase(z);
//     }
//     else{
//       x=x*2; cnt++;
//     }
    
     
//   }
//   ans=cnt+ms.size();
 


//  mn=1e18;
//  call(0,z,v);
//  if(ans==mn)return;
//  else{
  
//   cout<<ans<<" "<<mn<<"\n";
//    for(auto i : v)cout<<i<<" ";
//    cout<<"\n"<<p<<"\n"; exit(0);
//  }

// }

// int32_t main()
// {

// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","rt",stdin);
// freopen("output.txt","wt",stdout);
// #endif 

// srand(time(0));
// int cnt=0;
// while(1)
// {
  

//   vector<int>v(5);

//   for(int i=0;i<5;i++)
//   {
//     v[i]=rand()%100 +1;
//   }
//   int x=rand()%100 +1;
//   cnt++;
//   solve(v,x);
//   cnt++;
//   if(cnt==100)break;
  
// }




// }




#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

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


int n;
cin>>n;
int ac=0,tle=0,re=0,wa=0;

for(int i=0;i<n;i++)
{
  string s;
  cin>>s;
  if(s=="AC")ac++;
  else if(s=="WA")wa++;
  else if(s=="RE")re++;
  else tle++;
}

cout<<"AC x "<<ac<<"\n";
cout<<"WA x "<<wa<<"\n";
cout<<"TLE x "<<tle<<"\n";
cout<<"RE x "<<re<<"\n";



}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main () {
	unsigned long long K,A,B;
	cin >> K >> A >> B;
	unsigned long long currentCookie = 1;
	unsigned long long currentStep = 0;
	if(A+(long)2 >= B){
		//交換は無駄
		cout << (K + (long long)1) << endl;
	}else{
		while(true){
			if(A > currentCookie){
                currentStep += A - currentCookie;
				currentCookie = A;
			}else{
				if(currentStep + (unsigned long long)2 <= K){
					currentCookie += (unsigned long long)(B - A);
					currentStep += (unsigned long long)2;
				}else{
					currentCookie += (unsigned long long)1;
					currentStep += (unsigned long long)1;
				}

			}
			if(K == currentStep){
				break;
			}
		}
		cout << currentCookie << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 #define REP(i, a, n) for(int i=a; i<n; i++) //(i, 0, n)でi=0~n-1までn回
 #define sortv(v) sort(v.begin(), v.end());
 #define sortg(v) sort(v.begin(), v.end(), greater<>());
 #define rev(v) reverse(v.begin(), v.end());
 
 int main() {
   int r, d, x;
   cin >> r >> d >> x;
   REP(i, 0, 10){
     x=x*r-d;
     cout << x << endl;
   }
 }


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int[] s = new int[4];
		for(int i = 0; i < 4; i++) s[i] = sc.nextInt();
		Arrays.sort(s);
		if(s[0] == 1 && s[1] == 4 && s[2] == 7 && s[3] == 9) System.out.println("YES");
		else System.out.println("NO");
		
	}//end main
	
}//end Main

class Pair{
	int y; int x;
	public Pair(int y, int x){
		this.x = x;
		this.y = y;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22868
/// ~Love it

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define x1 qeerdx
#define y1 qeerdy
 
#define lb lower_bound
#define ub upper_bound
 
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define mp  make_pair
#define pb  push_back
 
#define fi first
#define se second
 
#define   sz(x)  (int)x.size()
#define  all(x)  x.begin(), x.end()
#define  bit(x)  __builtin_popcountll(x)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair <ll,ll> pii;
 
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
 
int kob (int x, int y) { return ((ll)x * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int)3e6, maxn2 = (int) 1e6+55;
 
static long holdrand = 1L;
void srand(unsigned int seed){holdrand = (long) seed;} 
int rand() {return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);}

int d[maxn][2];

int main () {
	string s; cin >> s;
	reverse (all (s));
	s += '0';
	
	d[0][0] = (s[0] - '0');
	d[0][1] = 10 - (s[0]-'0');
	
	for (int i = 1; i < sz (s); i ++) {
		int dig = s[i]-'0';
		d[i][0] = min (d[i-1][0] + (dig), d[i-1][1] + (dig+1)); 
		d[i][1] = min (d[i-1][0] + (10 - dig), d[i-1][1] + (10 - (dig+1))); 
	}
	
	cout << d[sz(s)-1][0];
}























Measured memory_bytes: 9476
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n);
   for(int &i : a){
      cin >> i;
   }
   sort(all(a));
   int ans = 0;

   auto TR = [&](int a,int b,int c){
      if(a == b or a == c or b == c) return false;
      return a+b > c and a+c > b and b+c > a;
   };

   for(int i = 0; i < n; ++i){
      for(int j = i+1; j < n; ++j){
         for(int k = j+1; k < n; ++k){
            ans += TR(a[i],a[j],a[k]);
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct Row {
  int m,P,Y,x=-1;
  Row(int m, int P, int Y): m(m),P(P),Y(Y) {}
};
ostream& operator<<(ostream& s, const Row& x) {
  return s<< "(" << x.m << "," << x.P << "," << x.Y << "," << x.x <<  ")";
}
bool sort_m(const Row& x, const Row& y) { return x.m < y.m; }
bool sort_P(const Row& x, const Row& y) { return x.P < y.P; }
bool sort_Y(const Row& x, const Row& y) { return x.Y < y.Y; }
void p(const vector<Row>& xs) {
  cout<< xs.size() <<": ";
  for(const auto& x:xs) cout<<x<<",";
  cout<<endl;
}

int N,M;
vector<Row> rows;
int main() {
  cin>>N>>M;
  for(int m=1;m<=M;++m) {
    int P,Y;
    cin>>P>>Y;
    rows.push_back(Row(m,P,Y));
  }
  //p(rows);
  stable_sort(rows.begin(), rows.end(), sort_Y);
  //p(rows);
  stable_sort(rows.begin(), rows.end(), sort_P);
  //p(rows);
  rows[0].x = 1;
  for(int i=1;i<rows.size();++i) {
    if(rows[i].P == rows[i-1].P) rows[i].x = rows[i-1].x + 1;
    else                         rows[i].x = 1;
  }
  //p(rows);
  stable_sort(rows.begin(), rows.end(), sort_m);
  //p(rows);
  for(const auto& x:rows) printf("%06d%06d\n", x.P, x.x);
}

Measured memory_bytes: 4692
import java.util.*;
import java.awt.Point;

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

		while(true){
			int n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt();
			if(n==0 && m==0 && l==0) break;
			Point[][] map = new Point[n+1][n+1];

			while(m-- > 0){
				int a=sc.nextInt(),b=sc.nextInt(),d=sc.nextInt(),e=sc.nextInt();
				map[a][b] = new Point(d,e);
				map[b][a] = new Point(d,e);
			}

			Queue<State> open = new PriorityQueue<State>();
			Set<State> closed = new HashSet<State>();

			State st = new State(0,l,1);
			open.add(st);

			State ans = null;
			while(!open.isEmpty()){
				st = open.poll();
				if(closed.contains(st)) continue;
				closed.add(st);
				if(st.id == n){
					ans = st;
					break;
				}
				open.addAll(st.nexts(map));
			}
			System.out.println(st.cost);
		}
	}
}

class State implements Comparable<State>{
	int cost;
	int money;
	int id;

	State(int cost, int money, int id){
		this.cost = cost;
		this.money = money;
		this.id = id;
	}

	List<State> nexts(Point[][] map){
		List<State> sts = new ArrayList<State>();
		int n = map.length;

		for(int i=1;i<n;i++){
			if(i == id) continue;
			if(map[id][i] == null) continue;
			sts.add(new State(cost+map[id][i].y, money, i));
			if(money >= map[id][i].x)
				sts.add(new State(cost, money-map[id][i].x, i));
		}

		return sts;
	}

	public int compareTo(State st){
		return cost - st.cost;
	}

	public boolean equals(Object o){
		State st = (State)o;
		return this.money==st.money && this.id==st.id;
	}

	public int hashCode(){
		return money + id;
	}
}

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

int main()
{
  long long int amt,fh=0,f=0,hap;
  cin>>amt;
  fh=amt/500;
  amt = amt%500;
  f=amt/5;
  hap=(fh*1000)+(f*5);
  cout<<hap<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
       scanf("%d",&a[i]);
    }
    long long ret=0;
    int head=1,tail=1;
	int sum=0;
    for(tail=1;tail<=n;tail++){
    	while((sum^a[tail])<sum+a[tail]){
        	sum^=a[head++];
		}
		//printf("%d  %d\n",head,tail);
    	sum^=a[tail];
        ret+=(tail-head+1);
    }
    printf("%lld",ret);
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    string s,t;
    cin >> s;
    rep0(i, s.size()){
        if(s[i] == 'B' && s[i + 1] == 'C'){
            t.push_back('*');
            ++i;
        }else t.push_back(s[i]);
    }
    ll a = 0,ans = 0;
    rep0(i, t.size()){
        if(t[i] == 'A')++a;
        else if(t[i] == '*')ans += a;
        else a = 0;
    }
    pf(ans);
    return 0;
}


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

#define MAX_HW 1400

using namespace std;

int G[MAX_HW + 5][MAX_HW + 5], T[MAX_HW + 5][MAX_HW + 5];

int main()
{
    int h, w, i, j, length;
    scanf("%d %d", &h, &w);
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            scanf("%d", &G[i][j]);
        }
    }
    length = 0;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (G[i][j] > 0) {
                T[i][j] = 0;
            }
            else {
                T[i][j] = 1;
                length = 1;
            }
        }
    }
    for (i = 1; i < h; i++) {
        for (j = 1; j < w; j++) {
            if (T[i][j] > 0) {
                T[i][j] = min(T[i - 1][j - 1], min(T[i][j - 1], T[i - 1][j])) + 1;
            }
            if (T[i][j] > length) {
                length = T[i][j];
            }
        }
    }
    printf("%d\n", length * length);

    return 0;
}

Measured memory_bytes: 18076
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

double sq(double a){
    return a*a;
}
int main(){
    vector<pair<double,double> >vec;
    double x,y,b,z,s=0;
    char c;
    while(cin>>x>>c>>y)
        vec.push_back(make_pair(x, y));
    int a=1;
    while(a+1!=vec.size()){
        x=sqrt(sq(vec[0].first-vec[a].first)+sq(vec[0].second-vec[a].second));
        y=sqrt(sq(vec[0].first-vec[a+1].first)+sq(vec[0].second-vec[a+1].second));
        b=sqrt(sq(vec[a+1].first-vec[a].first)+sq(vec[a+1].second-vec[a].second));
        z=(x+y+b)/2;
        s+=sqrt(z*(z-x)*(z-b)*(z-y));
        a++;
    }
    cout<<s<<endl;
}

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

using namespace std;
 
int main() {
	int N;
	cin >> N;
	N *= 2;
	vector<int> v;
        int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
                v.push_back(a);
	}
 
	int count = 0;
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i += 2) {
		count += min(v[i], v[i+1]);
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#113c
N,M = map(int, input().split())

PY_dict = dict() #key:県P, value:市の生誕年 のリスト
PY_list = list() #(P,M) の 入力順
PY_ans = dict()  #key:(P,M) value:Number

#入力受付
for i in range(M):
    P,Y = map(int, input().split())
    
    PY_list.append((str(P).zfill(6),Y))
    
    if P not in PY_dict:
        PY_dict[P] = list()
        
    PY_dict[P].append(Y)
        
#県毎に番号算出
for PY in PY_dict.items():
    P = str(PY[0]).zfill(6)
    Y = PY[1]
    Y.sort(reverse=False)
        
    for i in range(1,len(Y)+1):
        number = P + str(i).zfill(6)
        PY_ans[(P,Y[i-1])] = number
        
#入力順に表示
for PY in PY_list:
    print(PY_ans[PY])

Measured memory_bytes: 71080
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val n=input.toInt
    val k=input.toList.foldLeft(0){(acc,x)=>acc+x-'0'}
    if(n%k==0){
      "Yes"
    }else{
      "No"
    }
  }
}


Measured memory_bytes: 25424
// AOJ 2731 Shifting a Matrix
// 2018.2.11 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define SIZE 700

int N;
typedef struct { short r, c; } T;
T ans[101][101], t0[101][101];
T tbl[SIZE+1][101][101];
char used[SIZE+1]; int top;
char s[1002], *p;

char *seq(T res[101][101], char *s);

// malloc
int new() { int i, k;
	used[k=i=top] = 1;
	while (++i < SIZE) if (!used[i]) { top = i; break; }
	return k;
}

// free
void dis(int k) { used[k] = 0; if (k < top) top = k; }

char *in(int *res, char *p) { int n = 0;
	while (isdigit(*p)) n = (n<<3)+(n<<1) + (*p++ & 0xf); *res = n; return p;
}

void calc(T a[101][101], T b[101][101])
{
	int r, c;
	T t[101][101];

	for (r = 0; r < N; r++) for (c = 0; c < N; c++) {
		t[r][c] = a[b[r][c].r][b[r][c].c];
	}
	memcpy(a, t, sizeof(t));
}

char *ope(T a[101][101], char *s)
{
	int k, r, c;
	char x;

	x = *s++;
	s = in(&k, s), k--;
	memcpy(a, t0, sizeof(t0));

	if      (x == 'L') for (c = 0; c < N; c++) a[k][c].c = (c+1  ) % N;
    else if (x == 'R') for (c = 0; c < N; c++) a[k][c].c = (c-1+N) % N;
    else if (x == 'U') for (r = 0; r < N; r++) a[r][k].r = (r+1  ) % N;
	else               for (r = 0; r < N; r++) a[r][k].r = (r-1+N) % N;
	return s;
}

char *rep(T a[101][101], char *s)
{
	int n, _b;
	T (*b)[101];
	
	b = tbl[_b=new()];
	s = seq(b, s)+1;
	s = in(&n, s);
	memcpy(a, t0, sizeof(t0));

	while (n) {
		if (n & 1) calc(a, b);
		calc(b, b);
		n >>= 1;
	}
	dis(_b);
	return s;
}

char *seq(T res[101][101], char *s)
{
	int _t;
	T (*t)[101];

	memcpy(res, t0, sizeof(t0));

	t = tbl[_t=new()];
	while (*s == '(' || isalpha(*s)) {
//printf("seq %s", s);
		if (*s == '(') s = rep(t, s + 1);
		else s = ope(t, s);
		calc(res, t);
	}
	dis(_t);
	return s;
}

int main()
{
	int L, r, c;
	
	fgets(p=s, 16, stdin), p = in(&N, p), in(&L, p+1);
	fgets(s, 1002, stdin);

	for (r = 0; r < N; r++) for (c = 0; c < N; c++)
		t0[r][c].r = r, t0[r][c].c = c;

	seq(ans, s);
	for (r = 0; r < N; r++) {
		printf("%d", N*ans[r][0].r + ans[r][0].c + 1);
		for (c = 1; c < N; c++)
			printf(" %d", N*ans[r][c].r + ans[r][c].c + 1);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 28400
import java.util.Scanner;


class Main { 
  public static void main(String[] args)

{
	Scanner stdIn=new Scanner(System.in);
	int S = stdIn.nextInt();
	int h,m,s;
	
	
	
	h=S/3600;
	int i=S-(3600*h);
	m=i/60;
	s=i-(60*m);
	
	
	System.out.println(h+":"+m+":"+s);
	
	
	
  }
}

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

using namespace std;

using ll = long long;

int main() {

    ll K;
    cin >> K;
    ll sum = 0;
    for (int i = 1; i <= K; i++)
        for (int j = 1; j <= K; j++)
            for (int k = 1; k <= K; k++)
                sum += gcd(i, gcd(j, k));
    cout << sum << '\n';
    return 0;
}


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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if((B-A)%2==0)
    cout << (B-A)/2 << endl;
  else{
    long long k=min((A+B-1)/2,(2*N-A-B+1)/2);
    cout << k << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int m = max(a, max(b, c));

    if (a == m) {
        out((a << k) + b + c);
    }
    else if (b == m) {
        out((b << k) + a + c);
    }
    else  {
        out((c << k) + b + a);
    }

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int q;cin>>q;
    vector<pair<ll,ll>> ans;
    priority_queue<ll> small;
    priority_queue<ll,vector<ll>,greater<ll>> big;
    ll r=(ll)0,ssum=(ll)0,bsum=(ll)0,m=(ll)0,stmp,btmp;int res=0;
    int c;ll a,b;
    rep(i,q){
        cin>>c;
        if(c==1){
            cin>>a>>b;
            res++;
            stmp=(small.size())?small.top():-inf;
            btmp=(big.size())?big.top():inf;
            if(res%2){
                if(a<stmp){
                    ssum-=stmp;
                    m=stmp;
                    small.pop();
                    small.push(a);
                    ssum+=a;
                }
                else if(a>btmp){
                    bsum-=btmp;
                    m=btmp;
                    big.pop();
                    big.push(a);
                    bsum+=a;
                }
                else m=a;
            }
            else{
                if(small.size()==0){
                    small.push(min(m,a));
                    big.push(max(m,a));
                    bsum+=max(m,a);
                    m=min(m,a);
                    ssum+=m;
                }
                else if(a<m){
                    bsum+=m;
                    big.push(m);
                    ssum+=a;
                    small.push(a);
                    m=max(stmp,a);
                }
                else if(m<=a){
                    ssum+=m;
                    small.push(m);
                    bsum+=a;
                    big.push(a);
                }
            }
            r+=b;
        }
        else ans.push_back(mp(m,bsum-ssum+r));
    }
    for(auto A:ans)cout<<A.first<<" "<<A.second<<endl;
}

Measured memory_bytes: 6408
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

char mat[100][100];

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> v;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        v.push_back(s);
    }

    bool height[100] = {}, width[100] = {};
    for(int i = 0; i < h; i++){
        if(count(v[i].begin(), v[i].end(), '.') == w){
            height[i] = true;
        }
    }

    for(int j = 0; j < w; j++){
        int cnt = 0;
        for(string t : v){
            if(t[j] == '.') cnt++;
        }
        if(cnt == h)    width[j] = true;
    }

    for(int i = 0; i < h; i++){
        if(height[i])   continue;
        for(int j = 0; j < w; j++){
            if(width[j])    continue;
            cout << v[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
A, B, C = list(map(int, input().split()))
K = int(input())


A_l  = [2**(i)*A for i in range(K+1)]
B_l  = [2**(i)*B for i in range(K+1)]
C_l  = [2**(i)*C for i in range(K+1)]

res = 0
for l, c in enumerate(C_l):
    for m, b in enumerate(B_l):
        for n, a in enumerate(A_l):
            if a < b and b < c and l + m + n <= K:
                print('Yes')
                res += 1
                break
        else:
            continue
        break
    else:
        continue
    break

if res == 0:
    print('No')

                






Measured memory_bytes: 9204
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

sub = 10**5
for i, h in enumerate(H):
    temp = t - h * 0.006
    if sub > abs(a - temp):
        sub = abs(a - temp)
        ans = i + 1
print(ans)

Measured memory_bytes: 3060
N = int(input())
S = input()
count = 0

for i in range(10):
    x = S.find(str(i))
    if x == -1 or x >= N - 2:
        continue
    for j in range(10):
        y = S.find(str(j), x + 1)
        if y == -1 or y == N - 1:
            continue
        for k in range(10):
            z = S.find(str(k), y + 1)
            if z != -1:
                count += 1
                
print(count)

Measured memory_bytes: 3064
#!/usr/bin/env pypy
 
import sys
import string
def get_int(): return int(sys.stdin.readline().strip())
def get_ints(): return map(int, sys.stdin.readline().strip().split()) 
def get_list(): return list(map(int, sys.stdin.readline().strip().split())) 
def get_string(): return sys.stdin.readline().strip()
def out(data): return sys.stdout.write(str(data))
def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr))

MAX = 10**9
MOD = 10**9 + 7

n = get_int()
alp = " "+string.ascii_lowercase
ans = ''

while n:
  ans = alp[(n-1)%26+1] + ans
  n = (n-1) // 26
print(ans)


Measured memory_bytes: 68644
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
bool isTrue(string A,string B){
    int len=A.size();
    for(int i=len;i>0;i--){
        A=A.back()+A.substr(0,len-1);
        if(A==B)return true;
    }
    return false;
}
int main(){
    string S,T;
    cin>>S>>T;
    if(S.size()!=T.size())
        cout<<"No"<<endl;
    else{
        if(isTrue(S,T))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long int
# define ld long double
# define pb push_back
# define mp make_pair
# define mod 1000000007 
# define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int solve(vector<vector<int>>& arr, vector<vector<int>>& dp, int dayLeft, int prev){
	if(dayLeft < 0)
		return 0;
	if(dp[dayLeft][prev] != -1)
		return dp[dayLeft][prev];
	int mx = 0;
	for(int i = 0; i < 3; i++){
		if(i != prev){
			mx = max(mx, arr[dayLeft][i] + solve(arr, dp, dayLeft - 1, i));
		}
	}
	return dp[dayLeft][prev] = mx;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
// online submission
	#endif
	IOS
	int n;
	cin >> n;
	vector<vector<int>> arr, dp(n, vector<int>(3, -1));
	for(int i = 0; i < n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		vector<int> temp;
		temp.pb(a);
		temp.pb(b);
		temp.pb(c);
		arr.pb(temp);
	}
	int ans = 0;
	for(int i = 0; i < 3; i++){
		ans = max(ans, arr[n - 1][i] + solve(arr, dp, n - 2, i));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 23484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1_CutAndBig
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
//            Console.Write("文字列1を入力してください : ");
            String s1 = Console.ReadLine();

            //クラス、メソッド呼び出し
            ClassA classA = new ClassA();
            Console.WriteLine(classA.CutAndBig(s1));
//            Console.WriteLine("何かキーを押してください。");
//            Console.ReadKey();
        }
    }

    class ClassA
    {
        public String CutAndBig(string s1)
        {
            
            String[] work = s1.Split(' ');
            String work2 = work[0].Substring(0, 1); 

            for (int i = 1; i < 3; i++)
            {
                work2 = work2 + work[i].Substring(0, 1);
            }

            return work2.ToUpper();
        }

    }
}


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

using namespace std;

int main()
{
  string n;
  int k;
  cin>>n>>k;
  long long dp[n.length()+1][4][2]={0};
      dp[0][0][1]=1;
  for (int i=1;i<=n.length();i++)
  {
      for (int j=0;j<4;j++)
      {
          if (j!=0)
          dp[i][j][0]+=(9*dp[i-1][j-1][0]+max((n[i-1]-'0'-1),0)*dp[i-1][j-1][1]);
          dp[i][j][0]+=(dp[i-1][j][0]+(n[i-1]=='0' ? 0 : 1)*dp[i-1][j][1]);
          if (n[i-1]!='0' && j!=0)
          dp[i][j][1]+=dp[i-1][j-1][1];
          else
            if (n[i-1]=='0')
          dp[i][j][1]+=dp[i-1][j][1];
      }
  }
  cout<<dp[n.length()][k][0]+dp[n.length()][k][1];
    return 0;
}


Measured memory_bytes: 256