akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int k = Integer.parseInt(in.next());
            int x = Integer.parseInt(in.next());
            if (500 * k >= x) {
                out.println("Yes");
                return;
            }

            // 出力
            out.println("No");

        }

    }
}



Measured memory_bytes: 21332
def main():
    global N, graph, vis
    N, M = map(int, input().split())
    AB = {tuple(map(int, input().split())) for _ in [0] * M}

    graph = [[False for _ in [0] * N] for _ in [0] * N]
    for a, b in AB:
        graph[a-1][b-1] = graph[b-1][a-1] = True

    ans = 0
    for a, b in AB:
        graph[a-1][b-1] = graph[b-1][a-1] = False
        vis = [False] * N
        dfs(0)

        connected = True
        for i in range(N):
            if not vis[i]:
                connected = False
        if not connected:
            ans += 1
        graph[a-1][b-1] = graph[b-1][a-1] = True

    print(ans)

def dfs(x):
    if vis[x]: return
    vis[x] = True
    for i in range(N):
        if graph[x][i]:
            dfs(i)

main()


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

int main ( ) {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> h(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
        if(h[i] >= k) {
            ans++;
        }
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 640
a = [[i for i in map(int, input().split())] for j in range(3)]
n = int(input())

# a = [[66, 85, 92], [56, 37, 86], [7, 52, 23]]
# n = 9
# B = [30, 85, 52, 48,89, 92, 26, 5, 67]

d = [[0] * 3 for i in range(3)]
for i  in range(n):
    b = int(input())
    # b = B[i]
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1

flag = False

# horizontal
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[i][j]
    if cnt == 3:
        flag = True

# vertical
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[j][i]
    if cnt == 3:
        flag = True

# diagonal 1
cnt = 0
for i in range(3):
    cnt += d[i][i]
    if cnt == 3:
        flag = True

# diagonal 2
cnt = 0
for i in range(3):
    cnt += d[i][2-i]
    if cnt == 3:
        flag = True
print("Yes") if flag == True else print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a; cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

bool is_prime(int n)
{
    for (int i = 2; i * i < n; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    cin >> X;
    while (true)
    {
        if (is_prime(X))
        {
            cout << X << "\n";
            break;
        }
        X++;
    }
}


Measured memory_bytes: 256
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def max(a, b):
    return a if a > b else b
 
def is_match(string, pattern):
    # print(string, pattern)
    # pat_len = len(pattern)
    # skip = [pat_len for _ in range(256)]
    # for i in range(pat_len):
    #     skip[ord(pattern[i])] = pat_len - i - 1
    # i = pat_len - 1
    # while i < len(string):
    #     j = pat_len - 1
    #     while string[i] == pattern[j]:
    #         if j == 0:
    #             return True
    #         i -= 1
    #         j -= 1
    #     i = i + max(skip[ord(string[i])], pat_len-j)
    # return None
    if pattern in string:
        return True
    else:
        return False


def main():
    N = int(input())
    S = input()

    dp = [0] * N

    for i in range(1, N):
        length = dp[i - 1] + 1
        match_string = S[i - length + 1: i + 1]
        matched_string = S[:i+1-length]
        # print(match_string, matched_string)
        if is_match(matched_string, match_string):
            dp[i] = dp[i - 1] + 1
        else:
            dp[i] = dp[i - 1]
        # print(dp[i])
    
    # print(dp)
    print(dp[-1])



if __name__ == '__main__':
    main()

Measured memory_bytes: 18768
import numpy as np
import sys
temp = input().split()
N = int(temp[0])
M = int(temp[1])
A = []
B = []
check = False
def change(n):
  if(n=='#'):
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+i, j:M+j]).all():
      check = True
      break
  if check:
    break

if check:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 18596
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
	int n, m;
	string u[300];
	
	cin >> n;
	for(int i=0; i<n; ++i) cin >> u[i];
	cin >> m;
	
	bool open = false;
	for(int i=0; i<m; ++i){
		string t;	
		cin >> t;
		
		bool door=false;
		for(int j=0; j<n; ++j){
			if(t == u[j]){
				door=true;	
				break;
			}
		}
		
		if(!door) cout << "Unknown " << t <<endl;
		else if(door && open){
			cout << "Closed by " << t << endl;	
			open = false;
		}
		else if(door && !open){
			cout << "Opened by " << t << endl;	
			open = true;			
		}
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define x first
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
 
struct node
{
    int num,l,r,ls,rs;
    node(int _l,int _r)
    {
        num=0;
        l=_l;
        r=_r;
    }
};
 
vector<node> T;
vector<ll> d;
 
int make(int l,int r)
{
    int id=T.size();
    T.push_back(node(l,r));
    T[id].ls=(l+1==r?-1:make(l,(l+r)/2));
    T[id].rs=(l+1==r?-1:make((l+r)/2,r));
    return id;
}
 
void update(int id,int l,int r,int t)
{
    if(l==r||T[id].l>=r||T[id].r<=l)
        return ;
    if(T[id].l>=l&&T[id].r<=r)
    {
        T[id].num+=t;
        return ;
    }
    int mid=(T[id].l+T[id].r)>>1;
    if(l<mid)
        update(T[id].ls,l,r,t);
    if(r>mid)
        update(T[id].rs,l,r,t);
    int mi=min(T[T[id].ls].num,T[T[id].rs].num);
    T[id].num+=mi;
    T[T[id].ls].num-=mi;
    T[T[id].rs].num-=mi;
}
 
ll gettot(int id)
{
    if(id==-1) return 0; 
    if(T[id].num>0)
        return d[T[id].r]-d[T[id].l];
    return gettot(T[id].ls)+gettot(T[id].rs);
}
 
int main()
{
    T.reserve(50000);
    int n;
    scanf("%d",&n);
    set<int> s;
    priority_queue<pip,vector<pip>,greater<pip> > pq; 
    for(int i=0;i<n;i++)
    {
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        s.insert(y1);s.insert(y2);
        pq.push(make_pair(x1,make_pair(y1,y2)));
        pq.push(make_pair(x2,make_pair(y2,y1)));
    }
    map<int,int> y;
    d.clear();
    for(set<int>::iterator it=s.begin();it!=s.end();it++)
    {
        y[*it]=d.size();
        d.push_back(*it);
    }
    make(0,d.size()-1);
    ll ans=0;
    while(true)
    {
        pip t=pq.top();pq.pop();
        if(pq.empty()) break;
        if(t.second.first<t.second.second)
            update(0,y[t.second.first],y[t.second.second],1);
        else
            update(0,y[t.second.second],y[t.second.first],-1);
        ans+=gettot(0)*(pq.top().x-t.x);
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long A, long long B) {
    int ans;
    if (A >= 13) {
        ans = B;
    } else if (A >= 6) {
        ans = B / 2;
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


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

int main(){
    string s;
    getline(cin,s);
    long long sum =0;
    for(auto i=0;i<s.size();i++){
        sum += (long long)(s[i] - '0');
    }
    if(sum%9 == 0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


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

int main() {
    ll a,b,c,k;
    std::cin >> a>>b>>c>>k;
    ll ans = 0;
    if(a>=k){
        std::cout << k << std::endl;
        return 0;
    }
    ans += a;
    k -= a;
    if(b>=k){
        std::cout << ans << std::endl;
        return 0;
    }
    k -= b;
    std::cout << ans-k << std::endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll count = 1;
    map<ll, ll> facts;
    cin >> N;
    repi2(i, 1, N) {
        ll x = i;
        for(ll j = 2;j * j <= x;j++) {
            while(x % j == 0) x /= j, facts[j]++;
        }
        if(x > 1) facts[x]++;
    }
    iter(i, facts) (count *= i.second + 1) %= MOD;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
al=input().split()
mc = 0
tt = 0
min = abs(int(al[0]))

for i in range(N):
    if int(al[i]) < 0:
        mc += 1
    tt += abs(int(al[i]))

    if min > abs(int(al[i])):
       min = abs(int(al[i]))

if (mc % 2):
    print(tt-2*min)
else:
    print(tt)


Measured memory_bytes: 11212
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,c=0,p;
	cin>>n;
	map<int,int> mp;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[i-a[i]]++;	
	} 
	for(int i=0;i<n-1;i++){
		p=a[i]+i;
		mp[i-a[i]]--;
		c+=max((mp[p]),0ll);
		
		//mp[p]--;
	}
	cout<<c;
	
	return 0;
}




Measured memory_bytes: 27824
a, b, c, x, y = map(int, raw_input().strip().split())

low, high = min(x, y), max(x, y)

common_price = min(low * (a + b), low * 2 * c)
if x > low:
    diff = x - low
    diff_price = min(a * diff, c * 2 * diff)
elif y > low:
    diff = y - low
    diff_price = min(b * diff, c * 2 * diff)
else:
    diff_price = 0

print common_price + diff_price

Measured memory_bytes: 2568
"use strict"
function main(arg) {
    let getInt = Number(arg.trim().split(" ")[3]);
    let oneCount = Number(arg.trim().split(" ")[0]);
    let zeroCnt = Number(arg.trim().split(" ")[1]);
    let minusCnt = Number(arg.trim().split(" ")[2]);

    let result = 0;


    if(oneCount == 0 && zeroCnt == 0 && minusCnt == 0){
        console.log(0);
        return;
    }
    if(oneCount > 0 ){
        if(getInt > oneCount){      
            result = oneCount * 1;  
            }else{
            result = getInt * 1;
            }
            getInt = getInt - oneCount;  
    }
  

    if(getInt > 0){
        getInt = getInt - zeroCnt;
    }

    if(getInt > 0){
        result = result + (getInt * - 1);
    }

    console.log(result);

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

Measured memory_bytes: 29896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 2e5+5;

ll a[L];
ll pref[L];

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

    ll N, K;
    cin >> N >> K;

    for(ll i=1; i<=N; i++)
    {
        cin >> a[i];
        a[i] %= K;
    }

    for(ll i=1; i<=N; i++)
    {
        pref[i] = pref[i-1] + a[i];
        pref[i] %= K;
    }

    for(ll i=1; i<=N; i++)
    {
        pref[i] -= i;
        pref[i] %= K;

        pref[i] += K;
        pref[i] %= K;
    }

    map <ll, ll> f;

    ll ans = 0;

    for(ll i=0; i<=N; i++)
    {
        if(i < K)
        {
            ans += f[pref[i]];

            f[pref[i]]++;
        }

        else
        {
            f[pref[i-K]]--;

            ans += f[pref[i]];

            f[pref[i]]++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;

vector<string> str;

int R, C;
int a[11][10001] = {};

int solve(int p,string c){
	if (p == R){
		str.push_back(c);
		return 0;
	}
	solve(p + 1, c);
	solve(p + 1, c + (char)(p + 48) + ",");
}

signed main()
{
	
	while (1){
		int ans = 0;
		cin >> R >> C;
		if (R == 0 && C == 0) return 0;
		for (int i = 0; i < R; i++){
			for (int j = 0; j < C; j++){
				cin >> a[i][j];
			}
		}

		solve(0, "");
		for (int i = 0; i < str.size(); i++){
			vector<int> tmp;
			string num = "";
			for (int j = 0; j < str[i].length(); j++){
				if (str[i][j] == ','){
					tmp.push_back(stoi(num));
					num = "";
				}
				else {
					num += str[i][j];
				}
			}

			int score = 0;
			for (int k = 0; k < C; k++){
				int t1 = 0, t2 = 0;
				for (int l = 0; l < R; l++){
					bool flag = false;
					for (int m = 0; m < tmp.size(); m++){
						if (l == tmp[m]){
							flag = true;
							if (a[l][k] == 1) t2++;
							else t1++;
						}
					}
					if (flag == false){
						if (a[l][k] == 1) t1++;
						else t2++;
					}
				}
				score += max(t1, t2);
			}
			ans = max(ans, score);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
int main() {
    char a,b;
    cin>>a>>b;

    if(a>b){
        cout<<'>'<<endl;
    }
    else if(a<b){
        cout<<'<'<<endl;
    }
    else{
        cout<<'='<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
char s[15][1005];
int sum[MAXN];
int tmpsum[MAXN];
int ans=1e9;
void check(vector<pi>vec,int tmpans){
    REP(i,1,n)sum[i]=tmpsum[i]=0;
    REP(i,1,m){
        int cnt=0,flag=0;
        for(int j=0;j<vec.size();j++){
            tmpsum[++cnt]=0;
            for(int k=vec[j].first;k<=vec[j].second;k++){
                if(s[k][i]=='1')tmpsum[cnt]++;
            }
            if(tmpsum[cnt]+sum[cnt]>t)flag=1;
        }
        if(flag==1){
            tmpans++;
            REP(j,1,cnt){
                sum[j]=tmpsum[j];
                if(sum[j]>t)return;
            }
        }
        else {
            REP(j,1,cnt)sum[j]+=tmpsum[j],tmpsum[j]=0;
        }
    }
    ans=min(ans,tmpans);
}
void dfs(int x,vector<pi>vec,int tmpans){
    if(x>n){
        check(vec,tmpans);
        return;
    }
    REP(i,x,n){
        auto tmp=vec;
        tmp.push_back({x,i});
        dfs(i+1,tmp,tmpans+1);
    }
}
int main(){
    cin>>n>>m>>t;
    REP(i,1,n)cin>>s[i]+1;
//    int a=0;
//    REP(i,1,n)REP(j,1,m){
//        if(s[i][j]=='1')a++;
//    }
//    if(a<=t){
//        cout<<0;
//        return 0;
//    }
    vector<pi>v;
    dfs(1,v,0);
    cout<<ans-1;
}

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        string S = NextString();
        int[] left = new int[N + 1];
        int[] right = new int[N];
        left[0] = right[N - 1] = 0;
        for (int i = 0; i < N; i++)
            if (S[i] == 'W') left[i + 1] = 1;
        for (int i = 1; i < N; i++) left[i] += left[i - 1];
        for (int i = N - 1; i > 0; right[i - 1] += right[i], i--)
            if (S[i] == 'E') right[i - 1] += 1;
        int ans = N;
        for (int i = 0; i < N; i++)
            ans = Math.Min(ans, right[i] + left[i]);
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 15072
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n, i;
    cin >> n;
    vll arr(n + 1, 0);
    fo(i, n + 1)
        cin >> arr[i];

    vll b(n, 0);
    fo(i, n)
        cin >> b[i];

    ll res = 0;
    fo(i, n)
    {
        if(b[i] <= arr[i])
        {
            res += b[i];
            b[i] = 0;
        } else
        {
            res += arr[i];
            b[i] -= arr[i];
        }
        if(b[i] <= arr[i + 1])
        {
            res += b[i];
            arr[i+1] -= b[i];
            b[i] = 0;
        }
        else
        {
            res += arr[i + 1];
            b[i] -= arr[i + 1];
            arr[i + 1] = 0;
        }

    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B;

	cin >> A >> B;
	int diff = abs(A - B);
	
	if (diff % 2 != 0)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << (diff / 2) + min(A, B) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <string>

int main()
{
	int cnt = 0;
	std::string s;
	bool flg = true;

	std::cin >> s;

	auto oneChar = s.find(s[0], 1);
	flg &= oneChar != std::string::npos;

	auto tweChar = oneChar == 1 ? 2 : 1;
	tweChar = s.find(s[tweChar], tweChar + 1);
	flg &= tweChar != std::string::npos;

	flg &= s[oneChar] != s[tweChar];

	std::cout << (flg ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def rotate(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])

    def issame(self, other_dice):
        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_north()

        for i in range(4):
            if self.faces[0] == other_dice.faces[0]:
                for j in range(4):
                    if self.faces == other_dice.faces:
                        return True
                    self.rotate()
            self.roll_east()
        return False

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

print("Yes" if dice1.issame(dice2) else "No")

Measured memory_bytes: 6788
void main() {
	auto N = ri;
	auto X = readAs!(int[]);
	auto c = X.dup;
	c.sort();
	auto ave = c[$/2 - 1];
	//ave.writeln;
	//X.sort();
	auto r = X.length / 2;
	foreach(i; 0..N) {
		if(X[i] > ave) c[r-1].writeln;
		else c[r].writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

const int MAXN=15;
int n,ans;
int a[MAXN];

void DFS(int cur,long long prod){
	if(cur==n+1){
		if(~prod&1) ++ans;
		return;
	}
	DFS(cur+1,prod*a[cur]);
	DFS(cur+1,prod*(a[cur]-1));
	DFS(cur+1,prod*(a[cur]+1));
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	DFS(1,1);
	printf("%d",ans);
	return 0;
}

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

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

using namespace std;

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

	string s(n,'?');
	rep(i,m){
		int a;
		char b; scanf("%d %c",&a,&b); a--;
		if(s[a]=='?' || s[a]==b) s[a]=b;
		else return puts("-1"),0;
	}

	if(n>1 && s[0]=='0') return puts("-1"),0;
	rep(i,n) if(s[i]=='?') s[i]=(n>1&&i==0?'1':'0');

	cout<<s<<'\n';

	return 0;
}


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

using namespace std;

typedef long long ll;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int n;
    string s;

    cin >> n;

    vector<vector<int> > table(n, vector<int>(26));
    bool doesShare;
    int x;
    string ans = "";

    int i, j, len;
    char ch;

    for (i = 0; i < n; i++) {
        cin >> s;

        len = s.size();
        for (j = 0; j < len; j++) {
            ch = s[j] - 'a';

            table[i][ch]++;
        }
    }

    for (i = 0; i < 26; i++) {
        doesShare = true;
        x = INT_MAX;
        for (j = 0; j < n; j++) {
            if (table[j][i]) {
                x = min(table[j][i], x);
            } else {
                doesShare = false;

                break;
            }
        }

        if (doesShare) ans += string(x, (char)(i + 'a'));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] h = new int[N];
        for(int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }
        
        int ans = h[0];
        for(int i = 0; i < N-1; i++) {
            if(h[i+1] > h[i]) ans += h[i+1] - h[i];
        }
        System.out.println(ans);
    }
}

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

int main(){
    ll n,imin=0,ans;
    cin>>n;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        if(a>imin){
            ans=a+b;
            imin=a;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 510000;
const int MOD = 1000000007;
// 最長増加部分列の長さを求める
ll LIS(const vector<ll> &a) {
    ll N = (ll)a.size();
    vector<long long> dp(N, INF);
    for (ll i = 0; i < N; ++i) {
        // dp[k] >= a[i] となる最小のイテレータを見つける
        auto it = upper_bound(dp.begin(), dp.end(), a[i]);

        // そこを a[i] で書き換える
        *it = a[i];
    }

    // dp[k] < INF となる最大の k に対して k+1 が答え
    // それは dp[k] >= INF となる最小の k に一致する
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main() {
    ll N; cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; ++i) cin >> a[i];
    for (ll i = 0; i < N; ++i) a[i] = -a[i];
    cout << LIS(a) << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,k,key=0;
    int bb,cc;
    cin>>a>>b>>c>>k;
    bb=b;
    cc=c;
    for(int i=0; i<=k; i++)
    {
        b=bb;//初始化
        c=cc;
        b=b*(1<<i);
        c=c*(1<<(k-i));
        if(a<b&&b<c)
            key=1;
    }
    if(key)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<< endl;
    return 0;

}


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

int main(){
    int n, k;
    cin >> n >> k;
    
    int ans = 1;
    for(int karen = 0; karen < n; karen++){
        if(ans < k){
            ans *= 2;
        }
        else{
            ans += k;
        }
        // cout << ans << endl;
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#define SWAP(a,b) {int temp; temp = a; a = b; b = temp;}

int main(void){
	int x,y;

	while(1){
		scanf("%d %d", &x, &y);

		if(x == 0 && y == 0){
			break;
		}else if(x > y){
			SWAP( x, y);
		}

		printf("%d %d\n", x, y);
	}

	return 0;
}

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

count = 0
for i in range(1, 10 ** 7):
    tmp = i
    flag = True
    div_count = 0
    for j in range(3):
        if tmp%100 == 0:
            tmp = tmp // 100
            div_count += 1

    if div_count == D:
        count += 1

    if count == N:
        print(i)
        break

Measured memory_bytes: 3060
//approach 1
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int sum[401];
int slime(int *a,int i,int j,int dp[][401]){
    if(i>=j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int ans=LONG_LONG_MAX;
    for(int k=i;k<=j-1;k++){
        ans=min(ans,(sum[j]-sum[i-1])+slime(a,i,k,dp)+slime(a,k+1,j,dp));
    }
    return dp[i][j]=ans;
}
int32_t main(){
    int n;
    cin>>n;
    int a[401];
    sum[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    int dp[401][401];
    memset(dp,-1,sizeof dp);
    cout<<slime(a,1,n,dp)<<endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++)
    cin >> V[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  int res = 0;
  for (int i = 0; i < N; i++)
    res = max(res, res + V[i] - C[i]);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.stream.Collectors;

public final class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String in = br.readLine();
		System.out.println(new Solver().solve(in));
	}
}

class Solver {

	String solve(String in) {

		String turn = "First";
		List<Character> l = in.chars().mapToObj(c -> (char) c).collect(Collectors.toList());
		LinkedList<Character> ll = new LinkedList<Character>(l);
		ListIterator<Character> li = ll.listIterator(1);
		boolean yes = true;
		while (ll.size() > 2 && li.nextIndex() < ll.size() - 1) {
			char prev = (char) li.previous();
			li.next();
			li.next();
			char next = (char) li.next();
			li.previous();
			li.previous();
			if (prev == next) {
				li.next();
			} else {
				li.remove();
				if (li.previousIndex() > 0)
					li.previous();
				if (turn.equalsIgnoreCase("First")) {
					turn = "Second";
				} else
					turn = "First";
			}
		}
		return turn.equalsIgnoreCase("First") ? "Second" : "First";
	}
}


Measured memory_bytes: 34004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int MOD = 1e9 + 7;

int a[N];

int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	ll res = 0;
	for (int i=0; i<n; i++)
		cin >> a[i];
	for (int i=1; i<n; i++)
		res += min(1LL * (a[i] - a[i-1]) * x, 1LL * y);
	cout << res << "\n";
}

Measured memory_bytes: 640
def ryoukin(x, y, h, w) :
    length = x + y + h
    if length <= 60 and w <= 2 :
        return 600
    elif length <= 80 and w <= 5 :
        return 800
    elif length <= 100 and w <= 10 :
        return 1000
    elif length <= 120 and w <= 15 :
        return 1200
    elif length <= 140 and w <= 20 :
        return 1400
    elif length <= 160 and w <= 25 :
        return 1600
    else :
        return 0

while True :
    n = int(input())
    if n == 0 :
        break
    ans = 0
    for i in range(n) :
        x, y, h, w = map(int, input().split())
        ans += ryoukin(x, y, h, w)
    print(ans)


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.weight", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss (str );
		int w;
		ss >> w;
		vector<int> res; res.clear();
		int weight = 1;
		while (w > 0 ){
			if (w % 2 != 0 ) res.push_back (weight );
			weight *= 2;
			w /= 2;
		} // end while
		rep (i, res.size() ){
			cout << res[i] << (i != res.size() - 1 ? ' ' : '\n' );
		} // end rep

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1244
def d_card_eater(N, A):
    # 解説どおり
    from collections import Counter
    kind = len(set(A))  # 数列に現れる値の種類の数
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(d_card_eater(N, A))

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<long> h(n);
    long ans = (10e+9)+1;
    for (int i = 0; i < n; i++) cin >> h.at(i);
    sort(h.begin(), h.end());
    for (int i = 0; i < n-k+1; i++) {
        ans = min(h.at(i+k-1)-h.at(i), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int gcd2(int a, int b){
    if(a == b){ return a;}
    else if(a > b){ return gcd2(a-b, b); }
    else{ return gcd2(a, b-a); }
}

int gcd3(int a, int b, int c){
    return gcd2(gcd2(a, b), c);
}

int main(void){
    int K;
    scanf("%d", &K);
    int a, b, c, tmp;
    int ans = 0;
    for(a = 1; a <= K; ++a){
        for(b = a; b <= K; ++b){
            for(c = b; c <= K; ++c){
                tmp = gcd3(a, b, c);
                if(a == b && b == c){}
                else if(a < b && b < c){ tmp *= 6;}
                else{ tmp *= 3; }
                ans += tmp;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1732
N = int(input())
S = input()
A = 'abcdefghijklmnopqrstuvwxyz'
X = []
for var in A:
    X.append(S.count(var))
Y = X[0]

for i in range(1,26):  
    temp=1  
    for k in range(i+1):
        if k ==0:
            temp*=X[i]
        else:
            temp*=(X[i-k]+1)        
    Y+=temp
print(Y%(10**9+7))

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int n; cin >> n;
    vi p(n); list(i,n) cin >> p[i];

    int ans = 0;
    list(i,n){
        if(p[i]==i+1){
            ans++;
            if(i==n-1) swap(p[i],p[i-1]);
            else swap(p[i],p[i+1]);
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	int r, g;
	cin >> r >> g;
	cout << g - r + g << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios()                \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)

signed main()
{
	ios();
	int N,K;
	string S;
	cin >> N >> K >> S;
	S[K-1] = S[K-1] - 'A' + 'a';
	cout << S << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func rsort(a []int, n int) {
	for i := 1; i < n; i++ {
		v := a[i]
		j := i - 1
		for j >= 0 && a[j] < v {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = v
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	rsort(a, n)

	var alice, bob int
	for i, v := range a {
		if i%2 == 0 {
			alice += v
		} else {
			bob += v
		}
	}

	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
import bisect
n=input()
a=[input() for i in xrange(n)]
dp=[float('inf') for _ in xrange(n)]
for i in xrange(n):
    dp[bisect.bisect_left(dp,a[i])]=a[i]
for i in xrange(n):
    if dp[i]==float('inf'):
        i-=1
        break
print(i+1)

Measured memory_bytes: 12628
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,m=1;
		var hs=new SortedDictionary<int,int>();
		int[][] a=new int[n][];
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			a[i]=sc.Ia;
			if(a[i][0]==1){
				if(hs.ContainsKey(a[i][1])){hs[a[i][1]]++;}
				else{hs.Add(a[i][1],1);}
			}
		}
		List<int> kl=new List<int>(hs.Keys);
		foreach(var e in kl){
			int q=hs[e];
			hs[e]=m;m+=q;
		}
		Bit bit=new Bit(m);
		Bit bit2=new Bit(m);
		int[] b=new int[m];
		long p=0;
		for(int i=0,j=0;i<n;i++) {
			if(a[i][0]==1){
				p+=a[i][2];
				b[hs[a[i][1]]]=a[i][1];
				bit.Ud(hs[a[i][1]],(long)1e9+a[i][1]);
				bit2.Ud(hs[a[i][1]],1);
				hs[a[i][1]]++;
				j++;
			}
			else{
				int lb=-1,ub=m-1,mid=0;
				while(ub-lb>1){
					mid=(ub+lb)/2;
					if(bit2.Get(mid)>=((j+1)>>1)){ub=mid;}
					else{lb=mid;}
				}
				sb.Append(b[ub]+" "+(Math.Abs((1e9+b[ub])*(j-(j>>1)-1)-bit.Get(ub-1))+Math.Abs((1e9+b[ub])*(j>>1)-(bit.Get(m-1)-bit.Get(ub)))+p)+"\n");
			}
		}
		Console.Write(sb);
	}
}
public class Bit{
	private int n;
	private long[] bit;
	public Bit(int n){
		this.n=n;
		bit=new long[n+1];
	}
	public void Ud(int a,long p){while(a<=n){bit[a]+=p;a+=a&-a;}}
	public long Get(int n){
		long a=0;
		while(n>0){a+=bit[n];n-=n&-n;}
		return a;
	}
	public long Get2(int m,int n){
		long a=0,b=0;
		while(n>m){a+=bit[n];n-=n&-n;}
		if(n==m){return a;}
		while(n!=m){b+=bit[m];m-=m&-m;}
		return a-b;
	}
	public void Clear(){bit=new long[n+1];}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


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

using namespace std;

long long N;
long long arr[100005];

int main(){
    cin >> N;
    long long lst = 0;
    for(int i = 0; i<N; i++){
        cin >> arr[i];
        if(i%2 == 0){
            lst += arr[i];
        }
        else{
            lst -= arr[i];
        }
    }
    cout << lst << " ";
    for(int i = 0; i<N-1; i++){
        long long n = 2*arr[i]-lst;
        lst = n;
        cout << lst << " ";
    }
}


Measured memory_bytes: 2048
inpstr = input()

inp = inpstr.split(" ")
inp = list(map(int,inp))

c5 = 0
c7 = 0
for i in inp:
  if i==5:
    c5 += 1
  elif i==7:
    c7 += 1
if c5 == 2 and c7 == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;


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

	double a, b; cin >> a >> b;
	decltype(a) c = (a + b) / 2.0;
	cout << (int)ceil(c) << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vi t(n);
    REP(i,n){
        cin>>t[i];
    }
    sort(all(t));
    int cnt=0;
    /*REP(i,n)cout<<t[i]<<" ";
    cout<<endl;*/
    int num=0;
    int tlimit=INF;
    REP(i,n){
        if(tlimit<t[i] || num>=c){ // ﾀﾞｰｼｪﾘｲｪｰｽ
            //cerr<<num<<endl;
            num=0;
            cnt++;
        }

        if(num==0){
            tlimit=t[i]+k;
            num=1;
        }else if(tlimit>=t[i] && num<c){
            num++;
        }
    }
    if(num)cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
map<int, int> mp;
#define maxn 200010
int a[maxn];
int main() {
    int n, m;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++mp[x];
    }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
    for (int i = 0; i < m; ++i) {
        if (mp.find(a[i]) == mp.end()) { printf("NO\n"); return 0; }
        --mp[a[i]]; if (mp[a[i]] == 0) mp.erase(a[i]);
    }
    printf("YES\n");

    return 0;
}


Measured memory_bytes: 10368
import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))


Measured memory_bytes: 68924