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

using namespace std;
#define ll long long
typedef pair<ll , ll> ii;
ll n , kq[100005];
map<ll, ll> m, idx;
vector<ii> t;
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++){
        ll foo; cin >> foo;
        m[foo]++;
        if(!idx.count(foo)) idx[foo] = i;
    }
    for(auto x = m.begin() ; x != m.end(); x++)
        t.push_back({x->first , x->second});
    sort(t.begin(), t.end());
    for(int i = t.size() - 1;i > 0;i--){
        kq[idx[t[i].first]] += (t[i].first - t[i - 1].first) * t[i].second;
        t[i - 1].second += t[i].second;
        idx[t[i - 1].first] = min(idx[t[i - 1].first] , idx[t[i].first]);
    }
    kq[idx[t[0].first]] += t[0].second * t[0].first;
    for(int i = 1;i <= n;i++) cout << kq[i] << "\n";
    return 0;
}


Measured memory_bytes: 15988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		long sum = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		System.out.println(sum);

	}

}

Measured memory_bytes: 35640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	int N,K;
	SCD2(N,K);
	static int h[100002] = {};
	h[0] = 0;
	FORq(i,1,N){
		SCD(h[i]);
	}

	static int dp[100002] = {};
	FORq(i,0,N){
		dp[i] = 1100000000;
	}
	dp[0] = 0;
	dp[1] = 0;
	FORq(i,1,N){
		FORq(k,1,K){
			dp[i+k] = min(dp[i+k],dp[i] + abs(h[i+k] - h[i]));
		}
	}
	PRINTD(dp[N]);


}


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

int main()
{
    int K,S;
    cin >> K >> S;

    int count = 0;

    for(int x = 0; x <= K; x++)
    {
        for(int y = 0; y <= K; y++)
        {
            if((S - x - y <= K)&&(S -x -y>= 0))count++;
        }
    }

    cout << count << endl;
}

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

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

// 参考 URL
// http://kmjp.hatenablog.jp/entry/2018/03/11/1100

// 0 ~ N-1 であることに注意
template <typename T=long long>
vector<T> LISLDS(T N, T A, T B)
{
    vector<T> ret;
    for(long long i = B-1; i >= 0; --i) ret.push_back(i);

    if(A == 1) return ret;

    long long rem = N-B;
    long long p = rem/(A-1);  // 残りの A-1 個の部分列一つあたりに何個入れられるか
    long long r = rem%(A-1);  // 残りの A-1 個の部分列一つあたりに p 個入れた場合に何個余るか

    // 余りが出ないように A-1 この部分列を作る
    // 長さが p+1 の部分列を r 個作る <- 余りをなくす
    REP(i, r){
        int size = ret.size();
        for(int j = p; j >= 0; --j) ret.push_back(size+j);
    }
    // 長さが p の部分列を A-1-r 個作る
    REP(i, A-1-r){
        int size = ret.size();
        for(int j = p-1; j >= 0; --j) ret.push_back(size+j);
    }

    return ret;
}


int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    
    if(A+B > N+1 or A*B < N) cout << -1 << endl;
    else{
        for(auto v: LISLDS(N, A, B)) cout << v+1 << " ";
        cout << endl;
    }

    return 0;
}

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

int main() {
  int N, A,c, d;
  cin >> N;
   for (int i = 0;i<N ;i++){
     cin >> A;
       c = 0;
     for (int b = 2; true ;b *= 2){
     if(A%b == 0){
       c++;
     			} 
       else{
       break;
       }
     }
     if (i == 0 || d > c){
       d = c;
     }
   }									
  cout << d << endl;
			}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b[10],max=0,w;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		if(b[i]>max)
		{
			max=b[i];
			w=i;
		}
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(i!=w)
		sum+=b[i];
	}
	if(sum<=max)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define SHOWVEC(v) for(auto e : v) cerr << e << ' '; cerr << endl;
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  vector<ll> L(N, 0), W(N, 0);
  REP(i, N) {
    REP(j, N) {
      if (j < i) L[i] += (A[i] < A[j]);
      W[i] += (A[i] < A[j]);
    }
  }

  ll ans = 0;
  REP(i, N) {
    ll a = (K * L[i]) % MOD;
    ll b = (K * (K - 1) / 2) % MOD;
    (b *= W[i]) %= MOD;
    (ans += a + b) %= MOD;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
a.sort(reverse=True)
heapq.heapify(a)
for i in range(m):
    x = -heapq.heappop(a)
    x //= 2
    heapq.heappush(a,-x)
print(-sum(a))


Measured memory_bytes: 64240
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int h, w, dh, dw;
vector<string> s(1000);
vector<vector<int>> costs(1000, vector<int>(1000, INF));

int dijkstra(int cy, int cx) {
    costs[cy][cx] = 0;
    priority_queue<Pii, vector<Pii>, greater<Pii>> que;
    que.emplace(0, cy * w + cx);

    int cost, yx;
    while(!que.empty()) {
        tie(cost, yx) = que.top(); que.pop();
        int y = yx/w, x = yx%w;
        if(costs[y][x] < cost) continue;
        for(int yy=max(0, y-2);yy<=min(h-1, y+2);++yy) {
            for(int xx=max(0, x-2);xx<=min(w-1, x+2);++xx) {
                if(yy == y && xx == x) continue;
                if(s[yy][xx] == '#') continue;
                int diff_cost = (abs(yy-y) + abs(xx-x) == 1) ? 0 : 1;
                if(costs[yy][xx] > costs[y][x] + diff_cost) {
                    costs[yy][xx] = costs[y][x] + diff_cost;
                    que.emplace(costs[yy][xx], yy * w + xx);
                }
            }
        }
    }
    if(costs[dh][dw] >= INF) return -1;
    return costs[dh][dw];
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw >> dh >> dw;
    --ch; --cw; --dh; --dw;
    for(int i=0;i<h;++i) cin >> s[i];

    cout << dijkstra(ch, cw) << endl;
}


Measured memory_bytes: 8808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}

int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}

int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

vector<ll> prime_factor(int64_t n) {
	//map< ll, ll > ret;
	vector<ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			//ret[i]++;
			ret.push_back(i);
			n /= i;
		}
	}
	if (n != 1)ret.push_back(n);// ret[n] = 1;
	return ret;
}

const int MAX = 1000000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct edge {
	ll to;
	ll cost;
};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	long N;
	cin >> N;
	
	vector<ll> H(N);
	rep(i, N) {
		cin >> H[i];
	}

	ll count = 0; ll tmp = 0; ll ans = 0;
	for (auto it = H.begin(); it != H.end(); it++) {
		if (*it <= tmp) count++;
		else count = 0;
		tmp = *it;

		ans = max(ans, count);
	}

	cout << ans << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;


bool solve(vector<int> a, int target){
    int last = a[a.size() - 1];
    if(last == target)
        return true;
    a.pop_back();
    if(a.empty())
        return false;
    return (solve(a, target-last) || solve(a, target));
}

int main() {
    int n, q, x;
    vector<int> a;
    scanf("%d", &n);
    REP(i, n){
        scanf("%d", &x);
        a.push_back(x);
    }
    scanf("%d", &q);
    REP(i, q){
        scanf("%d", &x);
        if(solve(a, x))
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
ll a = pow(10, 18);
int main()
{
    int n; cin >> n;
    ll arr[n]; ll ans = 1;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 0; i < n; i++)
    {
        ll b = a / arr[i];
        if (b < ans)
        {
            ans = -1;
            break;
        }
        ans *= arr[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (arr[i] == 0)
        {
            ans = 0;
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4396
n = int(input())
a = input()
b = input()
c = input()

s = 0

for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        s += 2
    elif a[i] != b[i] or b[i] != c[i] or c[i] != a[i]:
        s += 1
    else:
        s += 0

print(s)


Measured memory_bytes: 3060
N = int(input())
P = [int(i) for i in input().split(" ")]

# 各数字が何番目に入っているかを保存する
pos = [0] * (N + 1)
for i in range(N):
    pos[P[i]] = i + 1

l = [0]+[i for i in range(N + 1)]
r = [i + 1 for i in range(N + 1)] + [N + 1]

# 1から順番に見ていく
ans = 0
for i in range(1, N + 1):
    idx = pos[i]
    l1, r1 = l[idx], r[idx]
    l2, r2 = l[l1], r[r1]
    ans += i * ((l1 - l2) * (r1 - idx) + (idx - l1) * (r2 - r1))
    l[r1], r[l1] = l1, r1
print(ans)

Measured memory_bytes: 20196
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ld INF_F = std::numeric_limits<float>::infinity();
constexpr ld PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll l;
    cin >> l;
    printf("%.12f\n", (double)l * l * l / 27);
//    printf("%16.12f", ld(l * l * l) / ld(27.0));
    return 0;
}

Measured memory_bytes: 3220
N, M = map(int, input().split())
s = []
c = []
for _ in range(M):
    a, b = map(int, input().split())
    s.append(a)
    c.append(b)

if (M == 0):
    for i in range(1000):
        if (len(str(i)) == N):
            print(i)
            exit()

for i in range(1000):
    cnt = 0
    for j in range(M):
        if len(str(i)) != N:
            break
        else:
            if (s[j] == 1):
                if (int(str(i)[0]) == c[j]):
                    cnt += 1
            elif(s[j] == N):
                if (int(str(i)[-1]) == c[j]):
                    cnt += 1
            else:
                if (int(str(i)[s[j] - 1:s[j]]) == c[j]):
                    cnt += 1
    if (cnt == M):
        print(i)
        exit()
    cnt = 0


print(-1)


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

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 41448
let main = (input) => {
    let kind = 0
    let chose = 0
    let usrInput = input.split(/\n/)
    kind = parseInt(usrInput[0].split(/\s+/)[0])
    chose = parseInt(usrInput[0].split(/\s+/)[1])
    let price = usrInput[1].split(/\s+/)
    let priceInt = []
    price.forEach(element => {
        priceInt.push(+element)
    });

    let sum = 0
    for (let index = 0; index < chose; index++) {
        let minus = 0
        for (let jake = 0; jake < priceInt.length; jake++) {
            if(priceInt[minus]>priceInt[jake])
                minus = jake
        }
        sum+=priceInt[minus]
        priceInt.splice(minus,1)
    }

    console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 32504
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[101][100001];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (0 < j) {
        dp[i + 1][j] += dp[i + 1][j - 1];
        dp[i + 1][j] %= MOD;
      }
      if (0 <= j - a[i] - 1) {
        dp[i + 1][j] += MOD;
        dp[i + 1][j] -= dp[i][j - a[i] - 1];
      }
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
    string s, t;
    cin>>s>>t;
    ll a, b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u == s) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
}


int main()
{
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int lmax[200005];
int rmax[200005];
int a[200005];
int main(void) {
    int N; cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= N; i++) {
        lmax[i] = max(lmax[i-1], a[i]);
    }
    for (int i = N; i >= 0; i--) {
        rmax[i] = max(rmax[i+1], a[i]);
    }
    for (int i = 1; i <= N; i++) {
        cout << max(lmax[i-1], rmax[i+1]) << endl;
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,T;
  cin >> N >> T;
  int ans = INF;
  rep(i,N) {
    int c,t;
    cin >> c >> t;
    if(t <= T) {
      ans = min(ans,c);
    }
  }
  if(ans == INF) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main()
{
  char b;
  std::cin >> b;

  std::map<char, char> MM;
  MM['A'] = 'T';
  MM['T'] = 'A';
  MM['C'] = 'G';
  MM['G'] = 'C';

  print(MM[b]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <string>
using namespace std;

struct pp {
  int ind, val;
  bool operator<(const pp& rhs) const {
    return val < rhs.val;
  }
};

int main() {
  int n; cin >> n;
  map<string, priority_queue<pp> > mapp;
  set<string> cities;
  for (int i = 0; i < n; i++) {
    string s; int rate;
    cin >> s >> rate;
    cities.insert(s);
    if (mapp.find(s) == mapp.end()) {
      priority_queue<pp> tmp;
      mapp.insert(make_pair(s, tmp));
    }
    pp p; p.ind = i+1; p.val = rate;
    mapp[s].push(p);
  }

  for (auto it = cities.begin(); it != cities.end(); it++) {
    while (!mapp[*it].empty()) {
      cout << mapp[*it].top().ind << endl;
      mapp[*it].pop();
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[3];
  int n1, n2;
  int c1, c2;
  int i;

  c1 = 0; c2 = 0;
  n1 = -200; n2 = -200;

  for ( i=0; i<3; i++ ) {
    scanf("%d", &a[i]);
    if ( n1 == -200 ) {
      n1 = a[i];
      c1 = 1;
    } else if ( n1 == a[i] ) {
      c1 = 2;
    } else if ( n2 == -200 ) {
      n2 = a[i];
      c2 = 1;
    } else if ( n2 == a[i] ) {
      c2 = 2;
    }
  }
  
  if ( c1 == 2 ) {
    printf("%d\n", n2);
  } else {
    printf("%d\n", n1);
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
int main(){
    FAST_IO ;
    bigint N , D ; cin >> N >> D ;
    int ans = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        bigint x , y ; cin >> x >> y ;
        bigint d = x * x + y * y ;
        if( d <= D * D )
            ans++ ;
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    vector<long double> a(N);
    rep(i,N) cin>>a[i];
    long double p = 0.0, q = 1.0;
    rep(i,N){
        a[i] = q / a[i];
        p += a[i];
    }
    p = q / p;
    cout<<fixed<<setprecision(10)<<p<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXW 100100
#define MAXN 110
#define INF 9999999999999
using namespace std;
typedef long long int lli;

lli pd[MAXN][MAXW];
bool visitado[MAXN][MAXW];
lli peso[MAXN];
lli valor[MAXN];
lli n, we;

lli solve(lli ind, lli w){
	if(w < 0) return -INF;
	if(ind == n+1) return 0;
	if(visitado[ind][w]) return pd[ind][w];
	
	
	lli n_coloca = solve(ind+1, w);
	lli coloca = solve(ind+1, w-peso[ind]) + valor[ind]; 
	
	visitado[ind][w] = 1;
	return pd[ind][w] = max(coloca,n_coloca);
}


int main (){
	int i;
	cin >> n >> we;
	
	for(i = 1; i <= n; i++){
		cin >> peso[i] >> valor[i];
	}
	
	lli sol = solve(1,we);
	cout << sol << endl;
	
}


Measured memory_bytes: 87808
n = input()
A = list(map(int,input().split()))
dic ={}
for i in A:
    if i%2 ==0:
        dic[i]=1
l = []
for j in dic.keys():
    if j%3 != 0 and j%5 != 0:
        print("DENIED")
        break
    else:
        l.append(j)
if len(l)==len(dic):
    print("APPROVED")

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
}


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

int main(){
    int q; cin >> q;
    map<string,int> m;
    rep(i ,q){
        int man; cin >> man;
        string key;
        int x;
        map<string,int>::iterator itr;
        switch (man)
        {
            case 0:
                cin >> key >> x;
                m[key] = x;
                break;
            case 1:
                cin >> key;
                itr = m.find(key);
                if(itr == m.end()) cout << 0 << endl;
                else cout << itr->second << endl;
                break;
            case 2:
                cin >> key;
                m.erase(key);
                break;
        }
    }
}


Measured memory_bytes: 27808
// abc146_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    auto T = S;
    while (true){
        auto it = T.find("()");
        if (it == string::npos) break;
        T.replace(it, 2, "");
    }

    int l = count(ALL(T), ')');
    int r = count(ALL(T), '(');

    string ans;
    REP(i, l) ans += '(';
    ans += S;
    REP(i, r) ans += ')';

    print(ans);

    return 0;
}


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

int main(){
    ll n;
    ll k;
    cin>>n>>k;
    vector<ll> v(n),cnt(n,0),cn(n,0);
    for(ll i=0;i<n;i++) cin>>v[i];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(v[i]>v[j]){
                cn[i]++;
                if(i<j) cnt[i]++;
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=k*cnt[i];
        ans%=1000000007;
        ans+=((k*(k-1)/2)%1000000007)*cn[i];
        ans%=1000000007;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int N, K;
    cin >> N >> K;
    set<int> s;

    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for(int i = 0; i < d; i++) {
            int temp;
            cin >> temp;
            if (s.count(temp) == 0) N--;
            s.insert(temp);
        }
    }

    cout << N;
    return 0;
}


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

int main(void){
    
    int data[3];
    for(int i=0;i<3;i++) cin >> data[i];
    sort(data,data+3,greater<int>());
    cout << data[0] * 10 + data[1] + data[2] <<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	int N, i;
	scanf("%d%d", &N, &i);

	if (N%i == 0)printf("0");
	else printf("1");


}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int[] arr;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        arr = Arrays.stream(input.split("")).mapToInt(Integer::parseInt).toArray();

        long sum = calc(0, arr.length - 1);
        System.out.println(sum);
    }

    private static long calc(int position, int end) {
        if (position > end) return 0;

        long tmp = 0;
        for (int i = position; i < end; i++) {
            tmp += toInt(position, i) * Math.pow(2, (end - i - 1)) + calc(i + 1, end);
        }
        tmp += toInt(position, end);
        return tmp;
    }

    private static long toInt(int start, int end) {
        if (start == end) {
//            System.out.println("start: " + start + " end: " + end + " -> " + arr[start]);
            return arr[start];
        }

        long tmp = 0;
        for (int i = start; i <= end; i++) {
            tmp += arr[i] * Math.pow(10, (end - i));
        }
//        System.out.println("start: " + start + " end: " + end + " -> " + tmp);
        return tmp;
    }
}

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

m = 1000000007

A.sort()
if N % 2 == 0:
    B = list(range(1, N, 2)) * 2
else:
    B = [0] + list(range(2, N, 2)) * 2
B.sort()

if A != B:
    print(0)
else:
    result = 1
    for i in range(N // 2):
        result *= 2
        result %= m
    print(result)


Measured memory_bytes: 20572
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

LL f(LL n, LL k) {
	if (k == 0)return 0LL;
	if (n == 0)return 1LL;
	LL x = (1LL << (n + 2)) - 3;
	LL y = (x - 3) / 2;
	if (k <= 1) return 0LL;
	if (k <= 1 + y) return f(n - 1, k-1);
	return (1LL<<n) + f(n - 1, k - y - 2);
}

int main(){
	LL n, k;
	cin >> n >> k;
	cout << f(n, k) << endl;
	return 0;
}


Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
a = Array.new(n){[]}
n.pred.times do
    x, y = gets.split.map(&:to_i)
    a[x - 1] << y - 1
    a[y - 1] << x - 1
end
p = Array.new(n){0}
q.times do |i|
  x, y = gets.split.map(&:to_i)
  p[x - 1] += y
end
c = Array.new(n){0}
c[0] = 1
que = []
que << 0
while que.size > 0
  e = que.shift
  a[e].each do |i|
    next if c[i] > 0
    c[i] = 1
    p[i] += p[e]
    que << i
  end
end
puts p

Measured memory_bytes: 25468
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		long bc = (long)b*c;
		long bd = (long)b*d;
		long ad = (long)a*d;
		long ac = (long)a*c;
		
		long ans = Math.max(bc, Math.max(bd, Math.max(ad, ac)));
		System.out.println(ans);
	}

}


Measured memory_bytes: 35724
import numpy as np

h,w=map(int,input().split())
s=np.array([[(1 if x=='.' else 0) for x in list(input())] for y in range(h)])

r=np.zeros((h,w),dtype=int)
l=np.zeros((h,w),dtype=int)
d=np.zeros((h,w),dtype=int)
u=np.zeros((h,w),dtype=int)

l[:,0] = s[:,0]
r[:,w-1] = s[:,w-1]
for i in range(1,w):
  l[:,i] = (l[:,i-1]+1) * s[:,i]
  r[:,w-i-1] = (r[:,w-i]+1) * s[:,w-i-1]

u[0]=s[0]
d[h-1]=s[h-1]
for i in range(1,h):
  u[i] = (u[i-1]+1) * s[i]
  d[h-i-1] = (d[h-i]+1) * s[h-i-1]

print(((l+r+u+d).max()-3))


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

using namespace std;

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

	long long n;
	cin >> n;
	if (n == 1) {
		cout << "0\n";
		return 0;
	}

	long long temp = n;
	map<long long, int> pw;
	int res = 0;
	for (long long i = 2; i * i <= n; i++) {
		long long cur = i;
		int cn = 1;
		while (temp % cur == 0) {
			temp /= cur;
			pw[i] += cn;
			cn++;
			cur *= i;
		}
		while (temp % i == 0) temp /= i;
	}
	bool prime = temp > 1;
	for (long long i = 2; i * i <= temp; i++) {
		if (temp % i == 0) {
			prime = false;
			break;
		}
	}
	if (prime) pw[temp]++;
	for (auto &p : pw) {
		int cn = (int) ((-1.0 + sqrt(1.0 + 8.0 * p.second)) / 2.0);
		res += cn;
		/*int cn = 1;
		while (p.second - cn >= 0) {
			res++;
			p.second -= cn;
			cn++;
		}*/
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 3676
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(n<4){
       cout<<"No"<<endl; 
       return 0;
    }
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
  char w[100];
  scanf("%s", &w);
  
  int len = strlen(w);
  int num = 0;
  for(int i=0; i<len; i++){
    if( count(w, w+len, w[i]) % 2 == 0){
      num ++;
      
      if(num == len)
        printf("Yes");
    }
    else{
      printf("No");
      break;
    }
  }    
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    
    int count = 0;
    rep(i, n){
        if (i%2 == 0 and a[i]%2 != 0)count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	double ans = 0;
	repn(i, 1, n + 1){
		int s = i;
		double p = 1.0 / n;
		while(s < k){
			s *= 2;
			p /= 2;
		}
		ans += p;
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

//typedef unsigned long long ull;

void RabinCarp(string T, string P, int d){ 
    int n = T.size();
    int m = P.size();
    int h = 1;
    int p = 0;
    int t[n];
    t[0] = 0;
  
    for(int i=0; i<m-1; i++){
      h = h * d;
    }
    for(int i=0; i<m; i++){                                                                                                                              
        p = d*p + P[i];
        t[0] = d*t[0] + T[i];
    }

    for(int s=0; s<n-m+1; s++){
        if(p==t[s]) {
          cout << s << endl;
        }
        if(s<n-m){
            t[s+1]=d*(t[s]-T[s]*h) + T[s+m];
        }
    }
}

int main(){
    int d = 167;
    string T, P;
    cin>>T>>P;

    RabinCarp(T, P, d);

    return 0;
}


Measured memory_bytes: 8988
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef pair<int,pair<int,int> > triple;
#define mkt(i,j,k) make_pair((i),make_pair((j),(k)))
#define solved first
#define time second.first
#define teamid second.second 

const int MAX_T=50;
const int MAX_P=10;
int wa[MAX_T][MAX_P];
triple team[MAX_T];

int main(){ _;
  int M,T,P,R,m,t,p,j;
  while(cin>>M>>T>>P>>R,(M|T|P|R)!=0){
    REP(i,MAX_T)REP(j,MAX_P)wa[i][j]=0;
    REP(i,MAX_T)team[i]=mkt(0,0,i);
    REP(i,R){
      cin>>m>>t>>p>>j;
      t--;p--;
      if(j==0){
	team[t].solved++;
	team[t].time-=m+wa[t][p]*20;
      }
      else{
	wa[t][p]++;
      }
    }
    sort(team,team+T,greater<pair<int,pair<int,int> > >());
    int cursolved=team[0].solved;
    int curtime=team[0].time;
    cout<<team[0].teamid+1;
    for(int i=1;i<T;i++){
      cout<<((cursolved==team[i].solved&&curtime==team[i].time)?"=":",")<<team[i].teamid+1;
      cursolved=team[i].solved;
      curtime=team[i].time;
    }
    cout<<endl;
  }
}

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

typedef pair<string, int> psi;

int bfs(string worm) {
  queue<psi> que;
  que.push(psi(worm, 0));

  map<string, int> d;

  while (!que.empty()) {
    psi p = que.front();
    que.pop();

    if (d[p.first]) continue;

    string str = p.first;

    bool flag = false;
    for (int i = 0; i < str.size() - 1; i++) {
      if (str[i] != str[i+1]) {
	  flag = true;
	  break;
      }
    }

    if (!flag) return p.second;

    d[p.first] = p.second;

    for (int i = 0; i < str.size() - 1; i++) {
      if (str[i] != str[i+1]) {
	char temp;
	string next;

	if (str[i] != 'b' && str[i+1] != 'b') {
	  temp = 'b';
	} else if (str[i] != 'g' && str[i+1] != 'g') {
	  temp = 'g';
	} else {
	  temp = 'r';
	}

	next = str;
	next[i] = next[i+1] = temp;

	que.push(psi(next, p.second+1));
      }
    }
  }
  return -1;
}

int main(void) {
  string worm;
  while (cin >> worm) {
    if (worm[0] == '0') {
      break;
    }

    int ret = bfs(worm);
    if (ret != -1) {
      cout << ret << endl;
    } else {
      cout << "NA" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3192
N = int(input())
HS = [int(i) for i in input().split()]

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(HS[1] - HS[0])

for i in range(2, N):
  dp[i] = min(dp[i-1] + abs(HS[i] - HS[i-1]), dp[i-2] + abs(HS[i] - HS[i-2]))

print(dp[N-1])


Measured memory_bytes: 20480
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string s;
	string t = "CODEFESTIVAL2016";
	cin >> s;
	int rsl = 0;
	rep(i, 0, s.size()) if(s[i] != t[i]) rsl++;
	cout << rsl << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, x;
  cin>>N>>x;
  int ans[2*N-1];
  for(int i=0;i<2*N-1;++i) ans[i] = 0;
  map<int, int> amap;
  if(N==2 && x==2) {
    cout<<"Yes"<<endl;
    cout<<1<<endl;
    cout<<2<<endl;
    cout<<3<<endl;
    return 0;
  }
  if(1<=x-1 && x+2<=2*N-1) {
    ans[N-2] = x+1;
    amap[x+1]++;
    ans[N-1] = x-1;
    amap[x-1]++;
    ans[N] = x;
    amap[x]++;
    ans[N+1] = x+2;
    amap[x+2]++;
    int now = 1;
    for(int i=0;i<2*N-1;++i) {
      if(ans[i]>0) continue;
      while(amap[now]>0) now++;
      ans[i] = now;
      amap[now]++;
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<2*N-1;++i) cout<<ans[i]<<endl;
    return 0;
  }
  if(1<=x-2 && x+1<=2*N-1) {
    ans[N-2] = x-2;
    amap[x-2]++;
    ans[N-1] = x;
    amap[x]++;
    ans[N] = x+1;
    amap[x+1]++;
    ans[N+1] = x-1;
    amap[x-1]++;
    int now = 1;
    for(int i=0;i<2*N-1;++i) {
      if(ans[i]>0) continue;
      while(amap[now]>0) now++;
      ans[i] = now;
      amap[now]++;
    }
    cout<<"Yes"<<endl;
    for(int i=0;i<2*N-1;++i) cout<<ans[i]<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}



Measured memory_bytes: 13756
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string key[10]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
	
	int n;
	cin>>n;
	
	cout<<key[n%10]<<endl;
}

Measured memory_bytes: 3604
from sys import stdin
import sys
import numpy as np
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    P, Q, R = map(int, input().split())
    print(np.min([P + Q, Q + R, R + P]))
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 12456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll= long long;
int main(){
    ll n,k;
    cin>>n>>k;
    ll j= n%k;
    ll ans =j;
    int flag =1;
    while(flag){
        if( ans==abs(j-k)) flag =0;
        ans=min(j,abs(j-k));
        j=abs(j-k);
    }
    cout << ans;
}


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

constexpr int MAX_N = 110;
constexpr int MAX_W = 100100;

int main() {
    int n, weight;
    cin >> n >> weight;
    vector<long long> w(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    
    long long dp[MAX_N][MAX_W] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < MAX_W; j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j - w[i] >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    
    cout << dp[n][weight] << '\n';
    return 0;
}

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


int main(){
    ll n,m; cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(),a.end());
    ll sum = 0,ans = 0;
    for(ll i=0;i<n;i++){
        if(sum<m){
            ans += min(a[i].second,m-sum)* a[i].first;
            sum += a[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int c, verdict[4] = {0}; 
  scanf("%d", &c);

  for(int i = 0; i < c; i++) {
    char str[5];
    scanf("%s", str);
    switch(str[0]) {
      case 'A':
        verdict[0]++;
        break;
      case 'W':
        verdict[1]++;
        break;
      case 'T':
        verdict[2]++;
        break;
      case 'R':
        verdict[3]++;
        break;
    }
  }

  printf("AC x %d\n", verdict[0]);
  printf("WA x %d\n", verdict[1]);
  printf("TLE x %d\n", verdict[2]);
  printf("RE x %d\n", verdict[3]);
  return 0;
}

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

const int mod = 1e9+7;
const int maxn = 1e6+5;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    tlfclwx();
    int a, b;
    cin >> a >> b;
    int c = a%b;
    if(c == 0) cout << a/b << endl;
    else cout << a/b+1 << endl;
}


Measured memory_bytes: 256