akhauriyash/Code-Regression huggingface dataset:
<?php
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
list($N,$K)=sscanf(trim(fgets(STDIN)),"%d %d");
$As = [];
$sc = new Scanner();
for ($i=0; $i < $N; $i++) {
    $As[$i] = $sc->nextInt();
}
//$startPt
$ptC = [];
$pt = [];
$pt[0] = 0;
$pt[1] = $As[$pt[0]]-1;
$pos = $pt[1];
$cnt = 2;
$ptC[0] = $ptC[$pt[1]] = true;
while(true){
    $pt[$cnt] = $As[$pt[$cnt-1]]-1;
    $pos = $pt[$cnt];
    if($cnt == $K){
        print($pos+1);
        exit;
    }
    if(isset($ptC[$pos])){
        $startPt = array_search($pos, $pt);
        $pt = array_slice($pt ,$startPt);
        break;
    }
    $ptC[$pos] = true;
    $cnt++;
}
print($pt[($K - $startPt) % (count($pt)-1)]+1);

Measured memory_bytes: 50420
//#define NDEBUG
 
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <map>
#include <set>
#include <vector>
#include <complex>
#include <queue>
#include <tuple>
#include <deque>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
ull mask = 1LL<<63;
int bm[1<<16];
int main() {
    ll x0, n, k;
    cin >> n >> k >> x0; k--;
    if (!x0) {
        cout << "0" << endl;
        return 0;
    }
    ull x = x0;
    for (int i = 0; i < n; i++) {
        bm[(x+mask)>>48]++;
        x ^= x<<13;
        x ^= x>>7;
        x ^= x<<17;
    }
    ll sm = 0;
    ll u;
    for (u = 0; u < 1<<16; u++) {
        if (k < sm+bm[u]) break;
        sm += bm[u];
    }
    k -= sm;
    vector<ll> v;
    x = x0;
    for (int i = 0; i < n; i++) {
        if ((x+mask)>>48 == u) v.push_back((ll)x);
        x ^= x<<13;
        x ^= x>>7;
        x ^= x<<17;
    }
    sort(v.begin(), v.end());
    cout << v[k] << endl;
    return 0;
}

Measured memory_bytes: 1504
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];
map<string,ll> mp;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    ll n,m;
    cin >>n;
    for(int i=1;i<=n;i++){
        string s;
        cin >>s;
        mp[s]++;
    }
    cin>>m;
    for(int i=1;i<=m;i++){
        string s;
        cin >> s;
        mp[s]--;
    }
    ll ans=0;
    for(auto t:mp){
        if(t.S>0)   ans=max(ans,t.S);
    }
    cout <<ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var x, y, a, b, c int
	fmt.Fscan(r, &x)
	fmt.Fscan(r, &y)
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)
	as := make([]int, a)
	bs := make([]int, b)
	cs := make([]int, c)
	for i := 0; i < a; i++ {
		fmt.Fscan(r, &as[i])
	}
	for i := 0; i < b; i++ {
		fmt.Fscan(r, &bs[i])
	}
	for i := 0; i < c; i++ {
		fmt.Fscan(r, &cs[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	sort.Sort(sort.Reverse(sort.IntSlice(bs)))

	var d []int
	for i := 0; i < x; i++ {
		d = append(d, as[i])
	}
	for i := 0; i < y; i++ {
		d = append(d, bs[i])
	}
	for i := 0; i < c; i++ {
		d = append(d, cs[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(d)))

	ans := 0
	for i := 0; i < x+y; i++ {
		ans += d[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 12928
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;

  bool result = true;
  F0R(i, S.size()) {
    if (i & 1) {
      if (S[i] == 'R') {
        result = false;
        break;
      }
    }
    else {
      if (S[i] == 'L') {
        result = false;
        break;
      }
    }
  }

  cout << (result ? "Yes" : "No");
}
#endif


Measured memory_bytes: 256
import math
N = int(input())

if N <= 26:
    M00 = [N]
else:
    l = 1
    M = N
    M0 = []
    while(M>0):
        M -= 26**l
        M0.append(M)
        l+=1

    MM = M0[l-3]-1
#    print(MM)
    cnt = l-1
#    print(cnt)
    M00 = []
    while(cnt>=1):
        #    print(cnt)
        a = math.floor(MM/26**(cnt-1))
        M00.append(a+1)
        MM -= a*26**(cnt-1)
        #    print(MM)
        cnt -= 1
    
#print(MM)
str0 = []
for i in range(len(M00)):
    str0.append(chr(M00[i]+96))
    
print(''.join(str0))

Measured memory_bytes: 9220
#include <stdio.h>
#include <string.h>

int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
string s;
int k;
ll dp[200][4][2];
ll f(int i,int cnt,bool b)
{
    if (cnt>k)
        return 0;
    if (i==(int)s.length())
        return(cnt==k);
    if (dp[i][cnt][b]!=-1)
        return dp[i][cnt][b];
    int lmt;
    if (!b)
    {
        lmt=s[i]-'0';
    }
    else
    {
        lmt=9;
    }
    ll res=0;
    for (int j=0;j<=lmt;j++){
        bool t=b;
        int c=cnt;
        if (!b&&j<lmt)
            t=1;
        if (j!=0)
            c++;
        if (c<=k)
            res+=f(i+1,c,t);
    }
    return dp[i][cnt][b]=res;
}
int main()
{
    FASTINOUT;
    cin>>s;
    cin>>k;
    memset(dp,-1,sizeof dp);
    cout<<f(0,0,0);
    return 0;
}


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

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

///////////////////////////////////////////////////////////////////////////


int main() { 

    ll X;
    cin >> X;
    
    int A, B;

    if(A >= 0)
    rep(i, 100){
        for(int j=-100; j<=100; j++){
            if(i*i*i*i*i - j*j*j*j*j == X){
                A = i;
                B = j;
            }
        }
    }
    
    if(A <= 0)
    for(int i=-1000; i<=0; i++){
        for(int j=-10000; j<=i; j++){
            if(i*i*i*i*i - j*j*j*j*j == X){
                A = i;
                B = j;
            }
        }
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
string s;

int main() {
	io(); cin >> s;
	string tmp = s;
	reverse(tmp.begin(), tmp.end());
	if (tmp != s) { cout << "No"; return 0; }
	string sa = s.substr(0, (s.length() - 1) >> 1);
	tmp = sa;
	reverse(tmp.begin(), tmp.end());
	if (tmp != sa) cout << "No";
	else cout << "Yes";
}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;

void printVec(vector<char> s) {
    for (int i = 0; i < (int) s.size(); ++i) {
        cout << s[i];
    }
}


int main() {
    //SYNC
    string s;
    vector<char> ans;
    cin >> s;
    for (int i = 0; i < (int) s.size(); ++i) {
        if(s[i] == 'B') {
            if (ans.size()){
                ans.pop_back();
            }
        } else {
            ans.push_back(s[i]);
        }
    }
    printVec(ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int genap[100005],ganjil[100005];
vector<int> v;
int main(){
    int n;
    cin>>n;
    int mx=0,mxx=0,valx,valxx;
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        if(i%2==0){
            genap[x]++;
            if(mx<genap[x]){
                valx=x;
                mx=genap[x];
            }
        }
        else{
            ganjil[x]++;
            if(mxx<ganjil[x]){
                valxx=x;
                mxx=ganjil[x];
            }
        }
        v.push_back(x);
    }
    //cout<<valx<<" "<<valxx<<endl;
    if(valx!=valxx){
        cout<<n-mx-mxx<<endl;
    }
    else{
            int temp;
            temp=0;
            for(int i=0;i<=100000;i++){
                if(valx == i){continue;}
                else{
                    temp=max(temp,genap[i]);
                }
            }
        int temp2;temp2=0;
            for(int i=0;i<=100000;i++){
                if(valxx==i){continue;}
                else{
                    temp2=max(temp2,ganjil[i]);
                }
            }
        if(temp>temp2){
            cout<<n-temp-mxx<<endl;
        }
        else{
            cout<<n-temp2-mx<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll H;
  cin >> H;
  ll ans = pow(2, floor(log2(H))+1) - 1;
  cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())

a = [int(input()) for _ in range(n)]
a_sorted = sorted(a, reverse=True)

if a_sorted[0] == a_sorted[1]:
    for i in range(n):
        print(a_sorted[0])
else:
    for i in range(n):
        if a[i] != a_sorted[0]:
            print(a_sorted[0])
        else:
            print(a_sorted[1])


Measured memory_bytes: 91180
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 10000+5
using namespace std;

int a[MAX];
int F[105][105];

int main()
{
	int h,w,n;
	si(h); si(w); si(n);
	clr(a); clr(F);
	rep(i,0,n)
	si(a[i]);
	int x=0,y=0;
	bool flag = true;
	rep(i,0,n)
	{
		int num = a[i];
		while(num)
		{
			F[x][y]=i+1;
			if(flag) y++;
			else y--;
			num--;
			if(y==w)
			{
				x++;
				y=w-1;
				flag=!flag;
			}
			else if(y==-1)
			{
				x++;
				y=0;
				flag=!flag;
			}
		}
	}
	rep(i,0,h)
	{
		rep(j,0,w)
		printf("%d ",F[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int W, H;
int c[50][50];
bool visited[50][50];
int vy[8] = {-1,-1,0,1,1,1,0,-1};
int vx[8] = {0,1,1,1,0,-1,-1,-1};
void calc(int y, int x) {
  if(y < 0 || y >= H || x < 0 || x >= W) return;
  if(visited[y][x] || c[y][x] == 0) return;
  visited[y][x] = true;
  FOR(i,0,8) calc(y+vy[i],x+vx[i]);
  return;
}
int main()
{
  while(cin >> W >> H, (W || H)) {
    CLR(visited);
    FOR(y,0,H) FOR(x,0,W) cin >> c[y][x];
    int ans = 0;
    FOR(y,0,H) {
      FOR(x,0,W) {
        if(visited[y][x] || c[y][x] == 0) continue;
        calc(y, x);
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
s = str(input())

if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
else:
  print(1)

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

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int sum1 = 0, sum2 = 0, sum3 = 0;
    sum1 = a * x + b * y;
    if(x <= y){
        sum2 = 2 * c * x + b * (y - x);
        sum3 = 2 * c * y;
    }
    else{
        sum2 = 2 * c * y + a * (x - y);
        sum3 = 2 * c * x;
    }

    int sum = min(min(sum1, sum2), min(sum2, sum3));
    cout << sum << endl;

    return 0;
}

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

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n, m; cin >> n >> m;
    vector<pii> edges;
    vector<int> in_cnt(n, 0);
    vector<vector<int>> adj(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        in_cnt[b]++;
    }
    int root = -1;
    for (int i = 0; i < n; i++) {
        if (in_cnt[i] == 0) {
            root = i;
        }
    }

    queue<int> q;
    q.push(root);
    vector<int> parent(n, -1);
    parent[root] = 0;
    while(!q.empty()) {
        int cur = q.front();
        q.pop();
        for (int i = 0; i < adj[cur].size();i ++) {
            int dst = adj[cur][i];
            in_cnt[dst]--;
            if (in_cnt[dst] == 0) {
                q.push(dst);
                parent[dst] = cur + 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << parent[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    string a, b;
    while (cin >> a >> b) {
        int n, m;
        cin >> n >> m;
        string c;
        cin >> c;
        if (a == c) {
            n -= 1;
        } else if (b == c) {
            m -= 1;
        }
        cout << n << " " << m << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

A, B, C, D = LI()
time = [0]*100
time[A:B] = list(map(lambda x: x+1, time[A:B]))
time[C:D] = list(map(lambda x: x+1, time[C:D]))
print(time.count(2))

Measured memory_bytes: 39664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tmp1 = sc.nextInt();
		long tmp2 = sc.nextInt();
		long a = Math.min(tmp1, tmp2);
		long b = Math.max(tmp1, tmp2);

		long cnt = 0;
		if(a == 1 && b == 1) {
			cnt = 1;
		} else if(a == 1 && b != 1){
			cnt =  b - 2;
		} else {
			cnt = (b - 2) * (a - 2);
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100

wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)

sug = 0
conc = 0
sug_max = 0 
conc_best = 0
sug_best = 0 
sug_wat_best = 0

for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            conc = sug/(sug+k)*100
            if 0<= sug <= sug_max and k+sug <= f and conc_best <= conc :
                conc_best = conc
                sug_wat_best = sug + k
                sug_best = sug
print(sug_wat_best, sug_best)


Measured memory_bytes: 9132
class SegmentTree
  attr_accessor(:node, :op, :e, :offset)
  
  def initialize(n, op, e)
    @op = op
    @e = e

    ofs = 1
    while ofs < n
      ofs <<= 1
    end
    
    @node = Array.new((ofs << 1) - 1, @e) # 0-indexed
    @offset = ofs - 1 # log2(n).ceil - 1
  end

  def update(i, x) # 一点更新
    i += @offset
    @node[i] = x
    
    while i > 0
      i = (i - 1) >> 1
      @node[i] = @op.call(@node[(i << 1) + 1], @node[(i << 1) + 2])
    end
  end

  def query(l, r) # [l, r)
    l += @offset
    r += @offset

    res = @e
    while l < r
      if l & 1 == 0
        res = @op.call(res, @node[l])
      end
      if r & 1 == 0
        res = @op.call(res, @node[r - 1])
      end
      l = l >> 1
      r = (r - 1) >> 1
    end
    return res
  end
end

m = 3 * (10 ** 5)
chmax = -> (x, y) { (x > y)? x : y }
chmin = -> (x, y) { (x < y)? x : y }
n, k = $stdin.readline.chomp.split.map(&:to_i)
seg = SegmentTree.new(m + 1, chmax, 0)

res = 0
n.times do
  a = $stdin.readline.to_i
  l = chmax.call(a - k, 0)
  r = chmin.call(a + k, m)
  t = seg.query(l, r + 1) + 1
  res = (res < t)? t : res
  seg.update(a, t)
end
puts res


Measured memory_bytes: 22560
#!/usr/bin/env python3
from math import isinf


def main():
    V, E = map(int, input().split())
    D = [[float('inf')] * V for _ in range(V)]

    for i in range(V):
        D[i][i] = 0

    for i in range(E):
        s, t, d = map(int, input().split())
        D[s][t] = d

    for k in range(V):
        for i in range(V):
            for j in range(V):
                if D[i][j] > D[i][k] + D[k][j]:
                    D[i][j] = D[i][k] + D[k][j]

    for i in range(V):
        if D[i][i] < 0:
            print("NEGATIVE CYCLE")
            return

    for di in D:
        print(' '.join(('INF' if isinf(dij) else str(dij) for dij in di)))

main()

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

int main() {
  int s;
  cin>> s;
  int a=s/10;
  int b=s%10;
  if (a==9||b==9){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}







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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define EUC_DIS(x, y) sqrt(x*x + y*y)


using namespace std;

int main(){

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

    int x = 0;
    int n;
    int max = 0;
    int sum = 0;

    cin >> n;
    string s;
    cin >> s;

    REP(i, n){
        sum += s[i] == 'I' ? 1 : -1;
        if(sum > max) max = sum;
    }


    if(max <= 0)
        cout << 0 << '\n';
    else
        cout << max << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int arrayCnt = new Integer(s.nextLine()).intValue();
		String[] tmp = s.nextLine().split(" ");
		int[] targetArray = new int[arrayCnt];
		for(int i=0 ; i < arrayCnt ; i++) {
			targetArray[i] = new Integer(tmp[i]).intValue();
		}

		int cnt = new Integer(s.nextLine()).intValue();
		String[] aaa = s.nextLine().split(" ");
		int existCnt = 0;
		for(int i=0 ; i<aaa.length ; i++) {
			if(search(targetArray, new Integer(aaa[i]).intValue())) {
				existCnt++;
			}
		}
		System.out.println(existCnt);
	}

	public static boolean search(int[] targetArray, int aaa) {
		int start = 0;
		int end = targetArray.length-1;

		while(start <= end) {
			int mid = (start + end) / 2;
			if(targetArray[mid] == aaa)
				return true;
			else if(targetArray[mid] < aaa) {
				start = mid + 1;
			} else if(targetArray[mid] > aaa) {
				end = mid - 1;
			}
		}
		return false;
	}

}

Measured memory_bytes: 51244
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int c;
    c = b - a;
    int an, bn;
    for(int i = 1; i < c; i++){
        an += i;
    }
    int x;
    x = an - a;
    cout << x << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 100000000;
  for (int i = 0; i <= N; i++) {
    int X = i, Y = N - i;
    int K = 0, L = 0;
    while (X > 0) {
      K += X % 6;
      X /= 6;
    }
    while (Y > 0) {
      L += Y % 9;
      Y /= 9;
    }
    ans = min(ans, K + L);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维 
**/
int main()
{
	ll n,i,j,t,k,m;
		 cin>>n>>m;
		 if(m==1||n==1){
		 	cout<<1; return 0;
		 }
		 if(n%2==0) cout<<n*m/2;
		 else {
		 	cout<<(n-1)*m/2+(m+1)/2;
		 }
 } 

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val (x,y,z) = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    var k = x - z * 2
    while(true){
        k -= y
        if(k >= 0) ans++
        else break
        k -= z
    }
    println(ans)
}


Measured memory_bytes: 37824
import java.util.Scanner;
//import java.lang.Math;

public class Main {
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    while(true)
    {
      int m = scan.nextInt();
      int f = scan.nextInt();
      int r = scan.nextInt();
      if( m == -1 || f == -1 )
      {
        if ( m == -1 && f == -1 && r == -1 ) break;
        System.out.println("F");
        continue;
      }
      String s;
      int sum = m + f;
      if ( sum >= 80 ) s = "A";
      else if ( sum >= 65 ) s = "B";
      else if ( sum >= 50 ) s = "C";
      else if ( sum >= 30 )
      {
        if ( r >= 50 ) s = "C";
        else s = "D";
      } else s = "F";

      System.out.println(s);
    }
    scan.close();
  }
}



Measured memory_bytes: 26352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * 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;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int T = in.nextInt();
			out.println(T / A * B);
		}
	}

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

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

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

		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    LL n, m;
    cin >> n >> m;
    /*
        oo
        oo
        oo
        oo
    */
    if(n > 2 && m > 2) cout << (n-2) * (m-2) << endl;
    else if(max(n, m) > 2 && min(n, m) == 1) cout << max(n, m) - 2 << endl;
    else if(max(n, m) > 2 && min(n, m) == 2) cout << 0 << endl;
    else if(n == 1 && m == 1) cout << 1 << endl;
    else cout << 0 << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    if (n % 2 == 1) {
        cnt = n / 2 + 1;
    } else {
        cnt = n / 2;
    }
    MSG(fixed << setprecision(16) << (double) cnt / n)
}


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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int i;
    int ans;
    ans=n;
    int k=0;
    for(i=0; i<n-1; i=i+k+1){
        k=0;
        for(int j=i+1; j<n; j++){
            if(s[i]==s[j]){
                ans-=1;
                k++;
            }else{
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{    
    int n;
    cin >> n;
    vector<int> s;
    vector<int> h;
    vector<int> c;
    vector<int> d;
    for(int i = 0;i < n;i++)
    {
        char a;
        int b;
        cin >> a >> b;
        switch(a)
        {
        case 'S':
            s.push_back(b);
            break;
        case 'H':
            h.push_back(b);
            break;
        case 'C':
            c.push_back(b);
            break;
        case 'D':
            d.push_back(b);
            break;
        default:
            break;
        }
    }

    for(int i = 1;i < 14;i++)
    {
        bool flg = false;
        for(vector<int>::iterator itr = s.begin();itr != s.end();itr++)
        {
            if(i == *itr)
            {
                flg = true;
            }
        }
        if(flg == false)
        {
            cout << "S " << i << endl;
        }
    }

    for(int i = 1;i < 14;i++)
    {
        bool flg = false;
        for(vector<int>::iterator itr = h.begin();itr != h.end();itr++)
        {
            if(i == *itr)
            {
                flg = true;
            }
        }
        if(flg == false)
        {
            cout << "H " << i << endl;
        }
    }

    for(int i = 1;i < 14;i++)
    {
        bool flg = false;
        for(vector<int>::iterator itr = c.begin();itr != c.end();itr++)
        {
            if(i == *itr)
            {
                flg = true;
            }
        }
        if(flg == false)
        {
            cout << "C " << i << endl;
        }
    }

    for(int i = 1;i < 14;i++)
    {
        bool flg = false;
        for(vector<int>::iterator itr = d.begin();itr != d.end();itr++)
        {
            if(i == *itr)
            {
                flg = true;
            }
        }
        if(flg == false)
        {
            cout << "D " << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1216
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 1e5 + 5;


int main(){
    int n;
    cin >> n;
    cout << 3LL * n * n  << endl;
}


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

class Main{
	public void run(){
		/*
		・方向が1つ前と同じならつなぐ数は1つ前と変化しない
		・方向が1つ前と変わった場合、1つ前の方向ですでに置かれた数だけ最大数から減った数
		*/
		int W = ni();
		int H = ni();
		Long[] cs = new Long[W+H];
		HashSet<Long> w = new HashSet<>();
		HashSet<Long> h = new HashSet<>();
		for(int i=0;i<W;i++){
			long t = (long)ni();
			w.add(t);
			cs[i] = t;
		}
		for(int i=0;i<H;i++){
			long t = (long)ni();
			h.add(t);
			cs[i+W] = -t;
		}
		Arrays.sort(cs, new Comparator<Long>(){
			public int compare(Long o1, Long o2){
				return (int)(Math.abs(o1) - Math.abs(o2));
			}
		});
//		debug(cs);
		long cost = 0;
		long wp = 0;
		long hp = 0;

		if(cs[0] >= 0){
			cost += (H + 1) * cs[0];
			wp++;
		}else{
			cost -= (W + 1) * cs[0];
			hp++;
		}
//		debug(cost);

		for(int i=1;i<W+H;i++){

			if(cs[i] >= 0){
				long tmp = (H  + 1 - hp) * cs[i];
//				debug(tmp);
				cost += tmp;
				wp++;
			}else{
				long tmp = (W + 1 - wp) * cs[i];
				cost -= tmp;
				hp++;
			}
		}
		out.println(cost);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 39520
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

#define INF 1145141919
typedef pair<int, int> P;

int N, M, Q;
int U[200000], V[200000];
int R[200000];

vector<int> G[100000];
bool T[200000];
int B[100000], D[100000];
bool W[100000];

int main() {
  scanf("%d %d %d", &N, &M, &Q);

  for (int i=0; i<M; i++) {
    scanf("%d %d", &U[i], &V[i]);
    U[i]--, V[i]--;
    if (U[i] > V[i]) swap(U[i], V[i]);
    G[U[i]].push_back(V[i]);
    G[V[i]].push_back(U[i]);
  }
  for (int i=0; i<N; i++) B[i] = INF, D[i] = INF;
  B[0] = 0, D[0] = 0;

  priority_queue< P, vector<P>, greater<P> > q;
  q.push(P(0, 0));
  while (!q.empty()) {
    int d = q.top().first,
        s = q.top().second; q.pop();
    if (B[s] < d) continue;
    for (int t : G[s]) {
      if (B[t] > d+1) {
        B[t] = d+1;
        q.push(P(d+1, t));
      }
    }
  }

  for (int i=0; i<Q; i++) {
    scanf("%d", &R[i]);
    R[i]--;
    T[R[i]] = true;
  }
  for (int i=0; i<N; i++) {
    G[i].clear();
  }
  for (int i=0; i<M; i++) {
    if (T[i]) continue;
    G[U[i]].push_back(V[i]);
    G[V[i]].push_back(U[i]);
  }

  q.push(P(0, 0));
  while (!q.empty()) {
    int d = q.top().first,
        s = q.top().second; q.pop();
    if (D[s] < d) continue;

    for (int t : G[s]) {
      if (D[t] > d+1) {
        D[t] = d+1;
        q.push(P(d+1, t));
      }
    }
  }
  int c = 0;
  for (int i=0; i<N; i++) {
    if (B[i] != D[i]) c++;
    else W[i] = true;
  }
  stack<int> ans;
  ans.push(c);
  for (int i=0; i<Q-1; i++) {
    int j = R[Q-1-i];
    int s = U[j], t = V[j];
    if (D[s] != D[t]) {
      if (D[s] > D[t]) swap(s, t);
      if (D[s] == B[s] && D[t] != B[t]) {
        D[t] = min(D[t], D[s]+1);
        if (D[t] == B[t]) {
          c--;
          W[t] = true;
          q.push(P(D[t], t));
          while (!q.empty()) {
            int d = q.top().first,
                s = q.top().second; q.pop();
            if (D[s] < d) continue;

            for (int t : G[s]) {
              if (!W[t] && B[t] == d+1) {
                D[t] = d+1;
                W[t] = true;
                c--;
                q.push(P(d+1, t));
              }
            }
          }
        }
      }
    }
    G[s].push_back(t);
    G[t].push_back(s);
    ans.push(c);
  }

  while (!ans.empty()) {
    int x = ans.top(); ans.pop();
    printf("%d\n", x);
  }
  return 0;
}

Measured memory_bytes: 13520
def main():
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    S = [list(input().split()[0]) for i in range(H)]

    from collections import deque

    dist = [0]*(H*W)
    for s in range(H*W):
        search_list = deque([s])
        visited_set = set([])
        d = [0] * (H*W)
        while search_list:
            now = search_list.popleft()
            visited_set.add(now)
            h = now // W
            w = now % W
            if S[h][w] == '#':
                continue
            for i, j in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
                new_h = h+i
                new_w = w+j
                new_s = new_h * W + new_w
                if new_h in [-1, H] or new_w in [-1, W]:
                    continue
                elif new_s in search_list:
                    continue
                elif new_s in visited_set:
                    continue
                elif S[new_h][new_w] == '#':
                    continue
                else:
                    d[new_s] = d[now]+1
                    search_list.append(new_s)
        dist[s] = max(d)
    print(max(dist))


if __name__ == "__main__":
    main()


Measured memory_bytes: 45404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h,w,k;
char s[10][10];
char t[10][10];
ll ans;
ll cnt;
int main(void){
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            for(int I=0;I<h;I++){
                for(int J=0;J<w;J++){
                    t[I][J]='.';
                }
            }
            for(int I=0;I<h;I++){
                if(i&(1<<I)){
                    for(int J=0;J<w;J++){
                        t[I][J]='R';
                    }
                }
            }
            for(int J=0;J<w;J++){
                if(j&(1<<J)){
                    for(int I=0;I<h;I++){
                        t[I][J]='R';
                    }
                }
            }
            for(int I=0;I<h;I++){
                for(int J=0;J<w;J++){
                    if(s[I][J]=='#'&&t[I][J]!='R'){
                        cnt++;
                    }
                }
            }
            //cout<<cnt<<endl;
            if(cnt==k) ans++;
            cnt=0;
        }
    }
    cout<<ans<<endl;
    
}



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

using namespace std;

long double d(long double x1,long double y1,long double x2,long double y2){

    long double val=((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1));
    return sqrt(val);
}

int main()
{
    cout<<setprecision(10);
    long double n;
    cin>>n;
    vector<pair<long double,long double>>v;
    for(int i=0;i<n;i++){
        long double x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    vector<int>p(n,0);
    for(int i=0;i<n;i++){
        p[i]=i;
    }
     long double ans=0;
     long double c=0.0;
    do{
        for(int i=0;i<n-1;i++){
            long double x1=v[p[i]].first;
            long double x2=v[p[i+1]].first;
            long double y1=v[p[i]].second;
            long double y2=v[p[i+1]].second;
            ans+=d(x1,y1,x2,y2);
        }
        ++c;
    }while(next_permutation(p.begin(),p.end()));
    cout<<fixed<<ans/c<<endl;
}


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

int main()
{
    int q;
    cin >> q;
    priority_queue<ll> quel;
    priority_queue<ll, vector<ll>, greater<ll>> quer;
    ll ans = 0;
    while(q--){
        int t;
        cin >> t;
        if(t == 2){
            cout << quel.top() << " " << ans << endl;
            continue;
        }
        ll a, b;
        cin >> a >> b;
        ll l;
        if(quel.size()) l = quel.top();
        if(quel.empty()){
            quel.push(a);
            ans += b;
        }
        else if(a <= l){
            quel.push(a);
            ans += l - a + b;
        }
        else{
            quer.push(a);
            ans += a - l + b;
        }
        if(quel.size() < quer.size()){
            ans -= quer.top() - quel.top();
            quel.push(quer.top());
            quer.pop();
        }
        if(quel.size() > quer.size() + 1){
            quer.push(quel.top());
            quel.pop();
        }
    }
}


Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int n;
int main()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int k;
        cin>>k;
        a[k]++;
    }
    for(int i=1;i<=n;i++) cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 4332
#include<stdio.h>
int main(){
    int i, j, k, m, n, l, r, c = 0;
    scanf("%d", &n);
    int A[n];
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &k);
    int B[k];
    for(i = 0; i < k; i++) scanf("%d", &B[i]);
    
    for(j = 0; j < k; j++){
         l = 0;
         r = n;
    while (l < r) {
    m = (l + r) / 2;
        if (A[m] == B[j]) c++;
        if (A[m] == B[j]) break;
        if (B[j] < A[m]) r = m;
        else l = m + 1;
    }
    }
    printf("%d\n", c);
    return 0;
    }


Measured memory_bytes: 2320
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n,t;
	long long ans=0;
	scanf("%d%d",&n,&t);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n-1;i++)if(a[i+1]-a[i]<t)ans+=a[i+1]-a[i];else ans+=t;
	ans+=t;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define rsort(v) sort(v.rbegin(),v.rend());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

/******************************START********************************/
int main()
{
	char ch1,ch2,ch3;
	string s1,s2,s3;
    lli i,j,k,a,t,b,c,n,m,x,sum=0,ans=0,temp;
    db d1;
    cin >> d1 >> n;
    db d2,d3=0;
    for(i=0;i<n;i++){
    	cin >> d2;
    	d3+=d2;
	}
	a=ceil(d1/d3);
	if(a==1)	cout << "Yes" << endl;
	else cout << "No" << endl;
    
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
edge = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

visited = [False for _ in range(n)]
def dfs(v):
    if all(visited):
        return 1
    res = 0
    for e in edge[v]:
        if not visited[e]:
            visited[e] = True
            res += dfs(e)
            visited[e] = False
    return res

visited[0] = True
print(dfs(0))


Measured memory_bytes: 3064
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//æ˜‡é †

using namespace std;

const int mod=1e9+7;

signed dis(int x1,int y1, int x2, int y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

signed main(){
    SPEED;
    int n;
    cin >> n;
    vi d(n);
    rep(i,n)
    {
        cin >> d[i];
    }
    SORT(d);
    int ans=n;
    rep(i,n-1)
    {
        if(d[i]==d[i+1])--ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int c[3][3];
	int total = 0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> c[i][j];
			total += c[i][j];
		}
	}
	if(total%3!=0){
		cout << "No" << endl;
		return 0;
	}
	int C1 = c[0][0]+c[0][1]+c[0][2];
	int C2 = c[1][0]+c[1][1]+c[1][2];
	int C3 = c[2][0]+c[2][1]+c[2][2];
	int C4 = c[0][0]+c[1][0]+c[2][0];
	int C5 = c[0][1]+c[1][1]+c[2][1];
	int C6 = c[0][2]+c[1][2]+c[2][2];	
	if((C1-C2)%3==0 && (C2-C3)%3==0 && (C3-C1)%3==0 && (C4-C5)%3==0 && (C5-C6)%3==0 && (C6-C4)%3==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();

  vector<vector<int>> index(26);
  for(int i=0;i<n;i++){
    int x=s.at(i)-'a';
    index.at(x).push_back(i);
  }

  int k=-1;
  ll count=0;;
  bool flag=true;
  for(int i=0;i<m;i++){
    int x=t.at(i)-'a';
    if(index.at(x).size()==0){
      flag=false;
      break;
    }
    int j=upper_bound(index.at(x).begin(),index.at(x).end(),k)-index.at(x).begin();
    if(j==index.at(x).size()){
      count++;
      j=upper_bound(index.at(x).begin(),index.at(x).end(),-1)-index.at(x).begin();
    }
    k=index.at(x).at(j);
  }

  if(flag){
    cout<<count*(ll)n+(ll)k+1<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 1216