akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 l[MAXN],r[MAXN];
multiset<int64> Lb,Rb;
int64 c,d[2];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(l[i]);read(r[i]);
    }
    Lb.insert(l[1]);Rb.insert(l[1]);c = 0;
    for(int i = 2 ; i <= N ; ++i) {
        d[0] -= r[i] - l[i];d[1] += r[i - 1] - l[i - 1];
        int64 a = *(--Lb.end()) + d[0],b = *(Rb.begin()) + d[1];
        if(l[i] < a) {
            c += abs(a - l[i]);
            Lb.erase(Lb.find(a - d[0]));Rb.insert(a - d[1]);
            Lb.insert(l[i] - d[0]);Lb.insert(l[i] - d[0]);
        }
        else if(l[i] > b){
            c += abs(b - l[i]);
            Rb.erase(Rb.find(b - d[1]));Lb.insert(b - d[0]);
            Rb.insert(l[i] - d[1]);Rb.insert(l[i] - d[1]);
        }
        else {
            Lb.insert(l[i] - d[0]);Rb.insert(l[i] - d[1]);
        }
    }
    out(c);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

namespace
{
	ll ModPow(ll a, ll p, ll mod)
	{
		if (p == 0)
			return 1;
		if (p % 2 == 0)
		{
			ll halfp = p / 2;
			ll half = ModPow(a, halfp, mod);
			return (half * half) % mod;
		}
		else
		{
			return (a * ModPow(a, p - 1, mod)) % mod;
		}
	}

	ll Combination(int n, int r, ll mod)
	{
		r = min(r, n - r);
		ll num = 1;
		ll den = 1;
		for (int i = 0; i < r; ++i)
		{
			num *= (n - i);
			num %= mod;
			den *= (i + 1);
			den %= mod;
		}
		ll ret = (num * ModPow(den, mod - 2, mod)) % mod;
		return ret;
	}
}

int main()
{
	ll MOD = 1000000007;
	int S;
	cin >> S;
	if (S <= 2)
	{
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	for (int i = 1; i < S; ++i)
	{
		int T = S - 3 * i;
		if (T < 0)
			break;
		ans += Combination(T + i - 1, i - 1, MOD);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
	vector<int> a;
	for (int i = 0; i < 5; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	for (int i = 0; i < 5; ++i) {
		if (a[i] == 0) {
			cout << i + 1;
		}
	}
	return 0;
}

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

#define MAX(A, B) (((A) > (B)) ? (A) : (B))

int main () {
  int N;
  scanf("%d", &N);
  int* a = malloc(N * sizeof(int));
  int b;
  int m1 = 0;
  int m2 = 0;
  int p1, p2;
  for (int i=0; i<N; i++) {
    scanf("%d", &b);
    if (b >= m1) {
      m2 = m1;
      p2 = p1;
      m1 = b;
      p1 = i;
    }
    else if (b >= m2) {
      m2 = b;
      p2 = i;
    }
  }
  
  for (int i=0; i<N; i++) {
    if (i != p1) {
      printf("%d\n", m1);
    }
    else {
      printf("%d\n", m2);
    }
  }
  
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int a,p;
    cin >> a >> p;
    pr((a*3+p)/2);
}

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

int main(){
  string S;
  cin >> S;
  int odd0=0, even1=0;
  int ans;
  for(int i=0; i<S.size(); i++){
    if(i%2==0 && S[i]=='0') odd0++;
    if(i%2==1 && S[i]=='1') even1++;
  }
  ans = min(even1+odd0, int(S.size())-even1-odd0);
  cout << ans << endl;
}


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

ll pow(ll n, ll k, ll mod){
    ll result = 1;
    while (k > 0){
        if (k % 2 != 0){
            result = result * n % mod;
        }
        n = (n * n) % mod;
        k = k / 2;
    }
    return result;
}

ll comb(ll n, ll r, ll mod){
    if(r == 0 || r == n){
        return 1;
    }
    else{
        ll k = min(r, n-r);
        ll x = 1;
        ll y = 1;
        for(ll i = 0; i < k; i++){
            x = x * (n-i) % mod;
            y = y * (i+1) % mod;
        }
        ll ans = x*pow(y, mod-2, mod)%mod;
        return ans;
    }
}

int main(){
    ll n, a, b;
    ll mod = 1000000007;
    cin >> n >> a >> b;
    ll p = pow(2, n, mod);
    ll q = comb(n, a, mod);
    ll r = comb(n, b, mod);
    ll ans = (p-q-r-1+mod*3) % mod;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

string S;
const string K = "keyence";

void solve()
{
	if(S == K) cout << "YES" << endl;
	else if(S.length() <= K.length()) cout << "NO" << endl;
	else{
		bool f = false;
		for(int len=1; len<=S.length(); ++len)for(int i=0;i+len<=S.length();++i){
			string cur = S.substr(0,i)+S.substr(i+len);
			if(cur == K){
				f = true;
				break;
			}
		}
		if(f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

int main()
{
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import  java.util.*;
import static java.lang.System.in;

public class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n+1];
        for(int i=1;i<=n;i++) a[i]=sc.nextInt();
        long[][] dp = new long[n+1][n+1];
        long[] sum = new long[n+1];
        for(int i=1;i<=n;i++) sum[i] = sum[i-1]+a[i];
        for(int i=0;i<=n;i++) Arrays.fill(dp[i],Long.MAX_VALUE/2);
        for(int i=0;i<=n;i++) dp[i][i] = 0;
        for(int i=1;i<n;i++) dp[i][i+1] = a[i]+a[i+1];
        for(int dx=2;dx<n;dx++){
            for(int i=1;i+dx<=n;i++){
                int j = i+dx;
                for(int k=i;k<=j-1;k++) dp[i][j] =Math.min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
            }
        }
        System.out.println(dp[1][n]);
    }
}


Measured memory_bytes: 25684
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    int z = 0;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) if (s[i] != t[i]) z++;
    cout << z;
}


Measured memory_bytes: 3864
def f(n, A):
    odd = 0
    four = 0

    for a in A:
        if a % 2 == 1:
            odd += 1
        if a % 4 == 0:
            four += 1

    if odd == 0:
        return True

    if n % 2 == 0:
        return odd - four <= 0
    else:
        return odd - four <= 1


n = int(input())
A = list(map(int, input().split()))
print("Yes" if f(n, A) else "No")


Measured memory_bytes: 14252
n, a, b = map(int, input().split())
if n == 1:
  if a == b:
    print(1)
  else:
    print(0)
elif n == 2:
  if a > b:
    print(0)
  else:
    print(1)
else:
  ans = max(0, (n-2)*(b-a)+1)
  print(ans)

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;

const int MAXN = 1e5, INF = 1e9 + 5, MOD = 1e9 + 7;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int h, w, m;
    cin >> h >> w >> m;
    vi r(h, 0), c(w, 0);
    set<ii> st;
    int mxR = 0, mxC = 0;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        st.insert(ii(x, y));
        r[x]++;
        c[y]++;
        mxR = max(mxR, r[x]);
        mxC = max(mxC, c[y]);
    }
    int ans = 0;
    for (auto[x, y]: st) ans = max(ans, r[x] + c[y] - 1);
    vi rmx, cmx;
    for (int i = 0; i < h; i++) if (r[i] == mxR) rmx.pb(i);
    for (int i = 0; i < w; i++) if (c[i] == mxC) cmx.pb(i);
    for (int i : rmx) {
        for (int j : cmx) {
            if (st.find(ii(i, j)) == st.end()) {
                cout << mxR + mxC;
                return 0;
            }
        }
    }
    cout << ans;
}

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

int main() {
  int date;
  cin >> date;
  
  string todayIs = "Christmas";
  string eve = " Eve";
  
  for(int i = 0; i < 25 - date; i++){
    todayIs += eve;
  }
  cout << todayIs << endl;
}



Measured memory_bytes: 256
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	int i,j,k,l,n,count;
	while(scanf("%d",&n)!=EOF){
    count=0;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			for(k=0;k<10;k++){
				for(l=0;l<10;l++){
						if(i+j+k+l==n){
							count++;
						}
					}
				}
			}
		}
			printf("%d\n",count);
	}
			return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;cin >> n >> W;
	vector<int> w(n);
	vector<int> v(n);
	rep(i,n) cin >> w.at(i) >> v.at(i);
	vector<vector<ll>> dp(n+1,vector<ll>(W+1));
	rep(i,n){
		rep(j,W+1){
			if(j-w[i]>=0) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
			else dp[i+1][j]=dp[i][j];
		}
	}
	cout << dp[n][W] << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
    // 1. C++ Productivity Tips
    // 2. To be used while Coding Interview Prep
    // 3. Solving Problems can take time
    // 4. Writing for loops, reading multiple variables is boring.
    // 5. Debugging Tools are not present in Coding Interviews.
    char c;
    cin>>c;
    if(c<97){
        cout<<"A"<<"\n";
    }else{
        cout<<"a"<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 3012
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        int[] box = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int num = 0;
        int b = 0;
        for (int i = 0; i < N; i++)
        {
            if (box[i] % 2 == 1) continue;
            b = box[i];
            for (int j = 0; b % 2 == 0; j++)
            {
                b /= 2;
                num += 1;
            }
           // Console.WriteLine(num);
        }
        Console.WriteLine(num);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 14176
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, A, B;
  cin >> N >> A >> B;

  long long ret = 0;

  if ((B - A) % 2 == 1) {
    if (N - B > A - 1) {
      ret += A;
      long long tmp_a = A;
      A = 1;
      B -= tmp_a;
    } else {
      ret += N - B + 1;
      long long tmp_b = B;
      B = N;
      A += N - tmp_b + 1;
    }
  }

  ret += (B - A) / 2;

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let xd = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x d -> x, d)) in
    Array.sort compare xd;

    let m = 998244353 in
    let ( +@) a b = (a + b) mod m in
    let ( *@) a (_, b) = (a * b) mod m in

    let rec loop c (x, d) = function
        | [] -> [ x, c +@ 1 ]
        | ((a, b) as h) :: tl ->
            if a < x + d then loop (c *@ h) (x, d) tl else (x, c +@ 1) :: h :: tl
    in
    Array.fold_right (loop 1) xd []
    |> List.fold_left ( *@) 1
    |> print_int
)

Measured memory_bytes: 14720
import java.util.InputMismatchException;
import java.util.Scanner;

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

                try
                    {
                        int inputA = scanner.nextInt();
                        int inputB = scanner.nextInt();

                        // 面積を求める
                        int area = inputA * inputB;

                        // 周の長さを求める
                        int length = (inputA + inputB) * 2;

                        System.out.println(area + " " + length);
                    }
                catch (InputMismatchException e)
                    {
                        System.out.println("整数を入力してください");
                        e.printStackTrace();
                    }
            }
    }

Measured memory_bytes: 17160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  char N[1000];
  int f=0, i;
  scanf("%s",N);
  int l = strlen(N);
  for(i=0;i<l/2;i++){
    if(N[i]!=N[l-i-1]){f=1; break;}
  }
  if(f==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
n = int(input())
A = []
B = []

for _ in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()

ans = 0
for i in range(n):
    temp = B[i] - ((A[i]+ans) % B[i])
    if temp == B[i]:
        temp = 0
    ans += temp

print(ans)

Measured memory_bytes: 11052
def gen_is_prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    # return [i for i in range(n + 1) if is_prime[i]]
    return is_prime


if __name__ == "__main__":
    max_n = 10 ** 5
    is_prime = gen_is_prime(max_n)

    is_like_2017 = [False] * (max_n + 1)
    for i in range(max_n + 1):
        if is_prime[i] and is_prime[(i + 1) // 2]:
            is_like_2017[i] = True

    sum_is_like_2017 = [0] * (max_n + 2)
    for i in range(max_n + 1):
        sum_is_like_2017[i + 1] = sum_is_like_2017[i] + is_like_2017[i]

    q = int(input())
    lr = [map(int, input().split()) for _ in range(q)]
    for l, r in lr:
        print(sum_is_like_2017[r + 1] - sum_is_like_2017[l])


Measured memory_bytes: 54064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll a[n];
    ll num_m = 0;
    ll num_p = 0;
    ll mn = 1000000001;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mn = min(mn, abs(a[i]));
        ans += abs(a[i]);
        if (a[i] > 0) num_p++;
        if (a[i] < 0) num_m++;
    }

    if (num_m % 2 != 0) ans -= 2 * mn;

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}


int main(){

	int n;
	cin >> n;
	vector<vector<int>> x(n,vector<int>(n));
	for(int i=0;i<n;++i) {
		for(int j=0;j<n;++j){
			cin>>x[i][j];
		}
	}
	vector<int> dp(1<<n);
	dp[0]=1;
	for (int mask=0; mask<(1<<n)-1;++mask){
		int p = __builtin_popcount(mask);
		for (int i=0;i<n;++i){
			if (x[p][i] && !(mask & (1<<i))){
				int m =mask^(1<<i);
				dp[m] = (dp[m]+dp[mask])%mod;
			}
	
	}

}
cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 11332
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_arr = [0]+list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    period = N
    visit = [False] * (N+1)
    order = []
    next_visit = 1
    for i in range(N):
        order.append(next_visit)
        visit[next_visit] = True
        next_visit = A_arr[next_visit]
        if visit[next_visit]:
            period = len(order[order.index(next_visit):])
            ofst = len(order[:order.index(next_visit)])
            break
    if K<=ofst:
        cnt = order[K]
    else:
        tmp = order[order.index(next_visit):]
        cnt = tmp[(K-ofst)%period]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 100988
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int  
signed main(){
  int n,a[100005],sum=0;
  int date[100005]={};
  vector<int> q;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    date[a[i]]++;
    if(date[a[i]]==1) q.push_back(a[i]);
  }
  for(int i=0;i<q.size();i++){
    if(1<date[q[i]]) sum+=(date[q[i]]-1);
  }
  if(sum%2==0) cout<<q.size()<<"\n";
  else cout<<q.size()-1<<"\n";
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;

int main(){
    IOS;
    string s;
    cin>>s;
    if(s[0]=='M')cout<<6;
    if(s[0]=='T'){
        if(s[1]=='U')cout<<5;
        else cout<<3;
    }
    if(s[0]=='W')cout<<4;
    if(s[0]=='S'){
        if(s[1]=='U')cout<<7;
        else cout<<1;
    }
    if(s[0]=='F')cout<<2;





    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

bool cardArray[4][13] = {};

void setDeck(int num)
{
	int i, card;
	char type;
	for (i = 0; i < num; i++)
	{
		cin >> type >> card;
		if (type == 'S') cardArray[0][card - 1] = true;
		if (type == 'H') cardArray[1][card - 1] = true;
		if (type == 'C') cardArray[2][card - 1] = true;
		if (type == 'D') cardArray[3][card - 1] = true;
	}
}

void displayDeck()
{
	int i, j;
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j ++)
		{
			if (!cardArray[i][j])
			{
				switch (i)
				{
					case 0:
						cout << 'S';
						break;
					case 1:
						cout << 'H';
						break;
					case 2:
						cout << 'C';
						break;
					case 3:
						cout << 'D';
						break;
					default:
						break;
				}
				cout << " " << j + 1 << endl;
			}
		}
	}
}

int main()
{
	int numcards;
	cin >> numcards;
	setDeck(numcards);
	displayDeck();
	return 0;
}

Measured memory_bytes: 1160
import heapq
def dijkstra(s):
    p=[x for x in range(n)]#親の記憶
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                p[u]=v
                heapq.heappush(hq, (tmp, u))
    return p

n,m = map(int,input().split())
#重み付き有向グラフの隣接リストe(重み=1)
e = [[] for _ in range(n)]
t=1
for _ in range(m):
    a,b= map(int,input().split())
    a,b = a-1, b-1
    e[a].append((t, b))
    e[b].append((t, a))

ans = dijkstra(0)
print('Yes')
for i in range(1,n):
  print(ans[i]+1)


Measured memory_bytes: 111280
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x, y, lmn, lmx;
    cin >> x >> y;
    cout << x*y << endl;
}

// 2+2+2+2+2 +4=14, 6, 7, 4

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

using namespace std;
int N;
void dfs(string s, char mx){
 if(s.length() == N){
 printf("%s\n", s.c_str());
 } else {
 for(char c='a';c<=mx;c++){
 dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
 }
 }
}
int main(void){
 cin >> N;
 dfs("", 'a');
 return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

template <typename T>
ll nCr(T n, T r) {
ll ans = 1;
    for (int i = n; i > n - r; --i) {
            ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans/i;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<int>B(N);
    for (int i = 0; i < N; ++i) cin >> B[i];
    vector<int>C(N);
    for (int i = 0; i < N; ++i) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll res = 0;
    for (auto&& b : B) {
        // lower_boundのイテレータから先頭のイテレータを引くと，あるkeyより小さい要素の個数を求めることができる．
        // この場合，bより小さい要素の数である．
        ll pre = lower_bound(A.begin(), A.end(), b) - A.begin();
        // 末尾のイテレータからupper_boundのイテレータを引くと，あるkeyより大きい要素の個数を求めることができる．
        // この場合，bより大きい要素の数である．
        ll over = C.end() - upper_bound(C.begin(), C.end(), b);
        res += pre * over;
    }
    cout << res << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[222222];

int main() {
    map<li, li> cnt;
    li n;
    cin >> n;
    li sum = 0;
    cnt[sum]++;
    rin{
        cin >> a[i];
        sum += a[i];
        cnt[sum]++;
    }
    li res = 0;
    for (auto& e : cnt) {
        li cnt_now = e.second;
        if (cnt_now > 1) {
            res += cnt_now * (cnt_now - 1) / 2;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a,b,c,d,e,k,ans=0;
constexpr ll INF=99999999999999999;
int main(){
  ll k;
    cin>>a>>b>>k;
    d=0;
    for(int i=a;i>0;i--){
        if(a%i+b%i==0)d++;
        if(d==k){
            ans=i;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[10010];
int take[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
signed main() {
    int N, M; cin >> N >> M;

    vector<int> can_use(10);
    for(int i=0; i<M; i++) {
        int val; cin >> val;
        val--;
        can_use[val] = true;
    }

    fill(dp, dp + N, -1);
    dp[0] = 0;
    for(int i=0; i<=N; i++) {
        if(dp[i] < 0) continue;
        for(int j=0; j<10; j++) {
            if(!can_use[j]) continue;
            chmax(dp[i + take[j]], dp[i] + 1);
        }
    }

    string res = "";
    int rem = N;
    while(rem) {
        int d = dp[rem];
        for(int i=8; i>=0; i--) {
            if(rem < take[i]) continue;
            if(!can_use[i]) continue;
            if(dp[rem - take[i]] + 1 == d) {
                res += (char)('0' + i + 1);
                rem -= take[i];
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
    using namespace std;
	
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		long long n,w;
		cin>>n>>w;
		long long dp[n+1][w+1];
		long long aw[n+1];
		long long av[n+1];
		for(long long i=1;i<=n;i++){
			cin>>aw[i]>>av[i];
		}
		for(long long i=0;i<=n;i++){
			dp[i][0]=0;
		}
		for(long long i=0;i<=w;i++){
			dp[0][i]=0;
		}
		for(long long i=1;i<=n;i++){
			for(long long j=1;j<=w;j++){
				if(aw[i]<=j){
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-aw[i]]+av[i]);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		cout<<dp[n][w]<<"\n";
		
        return 0;
    }

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

int p,q,r;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    
    while(n--){
        int x;
        cin >> x;
        if(x <= a){
            p++;
        }else if(x <= b){
            q++;
        }else{
            r++;
        }
    }
    cout << min(p, min(q,r)) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

c = 0
t = 0

for k in B:
    if k*k > c*t and B[k] >= 4:
        c = k
        t = k
    elif c >= k > t and B[k] >= 2:
        t = k
    elif k > c and B[k] >= 2:
        t = c
        c = k

print(t*c)

Measured memory_bytes: 18600
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	//int n=s.size();
	bool same = false;
	string m = "";
	rep(i, n)
	{
		if (s[i] == s[i + 1])
		{
			same = true;
			m.push_back('d');
		}
		else
		{
			if (!same)
			{
				m.push_back('s');
			}
			else
			{
				same = false;
			}
		}
	}
	//cout << m << endl;
	ll ans=1;
	if(m[0]=='d'){
		ans=6;
	}else{
		ans=3;
	}
	FOR(i,1,m.size()){
		if(m[i]=='s'){
			if(m[i-1]=='d'){
				ans=ans;
			}else{
				ans*=2;
			}
		}else{
			if(m[i-1]=='d'){
				ans*=3;
			}else{
				ans*=2;
			}
		}
		ans%=M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll get_val(vector<ll>&ft,ll index)
{
  ll res=0;
  for(;index>=0;index=(index & (index+1))-1)
    res+=ft[index];
  return res;
}

void update(vector<ll>&ft,ll index,ll val)
{
  for(;index<(ll)ft.size();index|=index+1)
    ft[index]+=val;
}

ll mex(vector<ll>&a, ll n)
{
  ll res=0;
  // set<ll>st;
  vector<ll>b(n+1,0);
  for(auto x:a) b[x]++;
    while(res<n && b[res]>0) res++;
  return res;
}

ll n;
ll ans[100005];
vector<pair<ll,ll>> tree[100005];
ll vis[100005];

void func(ll vertex, ll len)
{
  vis[vertex]=1;
  if(len%2==0) ans[vertex]=0;
  else ans[vertex]=1;
  for(auto x:tree[vertex])
  {
    if(vis[x.first]==0) func(x.first,len+x.second);
  }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    
    // Sieve();
   ll tests=1;
 // cin>>tests;
  // ll t=1;
    while(tests--)
    {
      ll i,j,u,v,w;
      cin>>n;
      rep(i,0,n) vis[i]=0;
      rep(i,0,n-2)
      {
        cin>>u>>v>>w;
        tree[u].pb({v,w});
        tree[v].pb({u,w});
      }
      func(1,0);
      rep(i,1,n) cout<<ans[i]<<"\n";

    }

    return 0;
   }

Measured memory_bytes: 24440
n=int(input())
last=(0,0,0)
for i in range(n):
    t,x,y=map(int,input().split())
    if t-last[0]<abs(x-last[1])+abs(y-last[2]):
        print("No")
        exit()
    else:
        if (t-last[0]-abs(x-last[1])-abs(y-last[2]))%2==0:
            last=(t,x,y)
        else:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3572
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();
    int y = n-a ;
    int x = y % b ;
    System.out.println(x);
  }
}


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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> as;
    as.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(as));

    auto p = minmax_element(begin(as), end(as));
    ll ans = numeric_limits<ll>::max();
    for (ll i = *p.first; i <= *p.second; ++i) {
        auto sum = accumulate(begin(as), end(as),
            0L,
            [i](auto acc, auto n) {
                return acc + (i - n) * (i - n);
            });
        ans = min(sum, ans);
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))
d = defaultdict(lambda :0)
for a in A:
    d[a] += 1
key_list = list(d.keys())
value_list = list(d.values())
value_list.sort()
tmp_num = len(value_list)

del_num = tmp_num - K
counter = 0
if del_num > 0:
    for v in value_list[0:del_num]:
        counter += v
print(counter)


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

int main() {
    int N; cin >> N;
    vector<vector<pair<int, int>>> T(N);
    for(int i = 0; i < N; ++i) {
        int A; cin >> A;
        while(A--) {
            int x, y; cin >> x >> y;
            T[i].emplace_back(x - 1, y);
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << N); ++bit) {
        bitset<20> bs(bit);
        bool ok = true;
        for(int i = 0; i < N; ++i) {
            if(!bs[i]) continue;
            for(auto t : T[i]) {
                int x, y; tie(x, y) = t;
                if(bs[x] != y) ok = false;
            }
        }
        if(ok) ans = max(ans, (int)bs.count());
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
/*
	watch me go
*/
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}


signed main()
{
    haha
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    int ans=0;
    set<int> s;
    map<int,int> m;
    int arr[a],brr[b],crr[c];
    for(int i=0;i<a;i++)
    cin>>arr[i];
    for(int i=0;i<b;i++)
    cin>>brr[i];
    for(int i=0;i<c;i++)
    cin>>crr[i];
     sort(arr,arr+a,greater<int>());
      sort(brr,brr+b,greater<int>());
    sort(crr,crr+c,greater<int>());
    int c1=0;
    int c2=0;
    int c3=0;
    int in=0;
    for(int i=0;i<x;i++)
    {
        //c1++;
        s.insert(arr[i]);m[arr[i]]++;
        
    }
  
    for(int i=0;i<y;i++)
    {
        //c2++;
        s.insert(brr[i]);m[brr[i]]++;
        
    }
   // cout<<in<<endl;
   
   // cout<<in<<endl;
    for(int i=0;i<c;i++)
    {
        int x1=*s.begin();
       // cout<<x1<<" "<<crr[i]<<endl;
        if(crr[i]>x1)
        {
            
            m[x1]--;
            if(m[x1]==0)
            s.erase(x1);
            s.insert(crr[i]);
            m[crr[i]]++;
            
        }
        else
        break;
    }
    for(auto x:m)
    {
        ans+=(x.first*x.second);
    }
    
    
   
  cout<<ans;
    
    
   
  
}










 
 

Measured memory_bytes: 28544
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;//人数
  long long K;//所持ポイント
  int Q;//正解数
  cin >> N >> K >> Q;
  vector<int> data(Q);//正解者数データ
  for(int i = 0; i < Q; i++)
    cin >> data.at(i);
  vector<int> point(N);//正解数データ
  for(int i = 0; i < Q; i++){
    point.at(data.at(i) - 1)++;
  }//入力完了
  for(int i = 0; i < N; i++){
    if(Q - point.at(i) >= K)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
 long long int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  
  string s;
  cin>>s;  
  for(int i = a;i < c;i++){
      if(s[i] == s[i+1] and s[i] == '#'){
          cout << "No";
          return 0;
      }
  }
  for(int i = b;i < d;i++){
      if(s[i] == s[i+1] and s[i] == '#'){
          cout << "No";
          return 0;
      }
  }
  if (c<d)cout << "Yes";
  else if(c > d){
      bool ok = 0;
      for(int i = b-1;i < d;i++){
          if(s[i] == s[i-1] and s[i] == s[i+1] and s[i] == '.')ok = 1;
      }
      if(ok)cout << "Yes";
      else cout << "No";
  }
  else cout << "No";
   
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int num[101];
int main(){
  int n,m=0;
  while(cin >>n){
    num[n]++;
    if(num[n]>m) m = num[n];
  }
  for(int i=0; i<101; i++)
    if(num[i] == m) cout <<i<<endl;
  return 0;
}

Measured memory_bytes: 1160
import sys
from heapq import heapify, heappush, heappop
read = sys.stdin.read


def main():
    N, M, *LRC = map(int, read().split())
    graph = [[(0, i - 1)] for i in range(N + 1)]
    graph[1] = []

    for L, R, C in zip(*[iter(LRC)] * 3):
        graph[L].append((C, R))

    distance = [-1] * (N + 1)
    queue = []
    heapify(queue)
    heappush(queue, (0, 1))

    while queue:
        cost, node = heappop(queue)
        if distance[node] == -1:
            distance[node] = cost
            for add_cost, next_node in graph[node]:
                if distance[next_node] == -1:
                    heappush(queue, (cost + add_cost, next_node))

    print(distance[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 50556
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=4010;
const int mod=998244353;
int sum1,sum2;
char s[MAXN];
int f[MAXN][2],dp[MAXN][MAXN];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
    for (int i=1;i<=n;i++) sum1+=(s[i]-'0');
    sum2=2*n-sum1;
    for (int i=1;i<=n;i++) f[i][0]+=f[i-1][0]+(s[i]-'0'),f[i][1]+=f[i-1][1]+2-(s[i]-'0');
	dp[0][0]=1;
	for (int i=0;i<=sum1;i++){
		for (int j=0;j<=sum2;j++)
		 if (i|j)
		 if (i<=f[min(i+j,n)][0]&&j<=f[min(i+j,n)][1]) 
		 {
		 	if (i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
		 	if (j) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod; 
		 }
	} 
    cout << dp[sum1][sum2] << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  bool jud = false;

  if (a < b && b < c) jud = true;
  rep(i, 0, k) {
    if (a >= b)
      b *= 2;
    else
      c *= 2;
  }

  if (a < b && b < c) jud = true;

  if (jud == true)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int A, B, C;
    cin >> A >> B >> C;

    REP(i, 1000){
        if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
            cout << i << endl;
            return 0;
        }
        int a = (B + C) / 2;
        int b = (A + C) / 2;
        int c = (A + B) / 2;
        A = a;
        B = b;
        C = c;
    }
    cout << -1 << endl;
    
    return 0;
}

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

signed main(void)
{
	int n;
	ll ans;
	cin >> n;
	vector<int> vec(n);
	ans = 0;
	rep(i, n)  cin >> vec[i];
	sort(vec.rbegin(), vec.rend());
	rep(i, n / 2) ans += 2 * vec[i];
	ans -= vec[0];
	if (n % 2 != 0)
		ans += vec[n / 2];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define N 110
using namespace std;
long long n,b1,b2,sum=0;
int main(){
	int i;
	cin>>n;
	for(i=1;i<n;i++)
	{
		cin>>b2;
		if(i==1)
		{
			sum+=b2;
		}
		else
		{
			sum+=min(b1,b2);
		}
		b1=b2;
	}
	cout<<sum+b2<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

H, W, K = list(map(int, input().split()))

mapping = defaultdict(int)

for source in range(1 << (W - 1)):
    l = [False for _ in range(W - 1)]
    for i in range(W - 1):
        l[i] = bool(source & (1 << i))
    flag = True
    for i in range(W - 2):
        if l[i] and l[i + 1]:
            # invalid
            flag = False
            # print("break",l)
            break
    if not flag:
       continue

    for i in range(W):
        if i > 0 and l[i - 1]:  # decrement
            mapping[i, i - 1] += 1
        elif i < W - 1 and l[i]:  # increment
            mapping[i, i + 1] += 1
        else:
            mapping[i, i] += 1

last = [1] + [0] * (W - 1)
for _ in range(H):
    current = [0] * W
    for (start, dst), count in mapping.items():
        current[dst] += last[start] * count
        current[dst] = current[dst] % (10**9+7)
    last = current
print(last[K - 1] %(10**9+7))

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

using namespace std;

int main(){
	for(int x,y,s;scanf("%d%d%d",&x,&y,&s),x;){
		int ans=0;
		for(int a=1;a<=s;a++) for(int b=1;b<=s;b++) if(a*(100+x)/100+b*(100+x)/100==s) {
			ans=max(ans,a*(100+y)/100+b*(100+y)/100);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1028