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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(i64, a, b, c, k);
  i64 res = a - b;
  outl(k % 2 ? -res : res);

  return 0;
}


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

using namespace std;

const int NMAX = 100;
const int INF = 1e9;

int N, M;
string a[NMAX + 2];

int dp[NMAX + 2][NMAX + 2];

int main()
{
    cin >> N >> M;

    for(int i = 0; i < N; i++)
        cin >> a[i];

    if(a[0][0] == '#')
        dp[0][0] = 1;

    for(int i = 0; i < N; i++)
        for(int j = 0; j < M; j++)
        {
            if(i == 0 && j == 0)
                continue;

            dp[i][j] = INF;

            if(a[i][j] == '.')
            {
                if(i != 0)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);

                if(j != 0)
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            }
            else
            {
                if(i != 0 && a[i - 1][j] == '#')
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);

                if(j != 0 && a[i][j - 1] == '#')
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);

                if(i != 0 && a[i - 1][j] == '.')
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);

                if(j != 0 && a[i][j - 1] == '.')
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            }
        }

    cout << dp[N - 1][M - 1];

    return 0;
}


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

int main() {
  int n, cnt = 0;
  int loop = 0;
  cin >> n;
  int l[n];
  REP(i, n) scanf("%d", &l[i]);
  sort(l, l+n);

  REP(i, n-2) {
    FOR(j, i+1, n-1) {
      int minIndex = -1;
      FOR(k, j+1, n) {
        if (l[k] > l[j]-l[i]) {
          minIndex = k;
          break;
        }
      }
      if (minIndex == -1) continue;

      int maxIndex = -1;
      for (int k = n-1; k > minIndex; k--) {
        if (l[k] < l[i]+l[j]) {
          maxIndex = k;
          break;
        }
      }
      if (maxIndex == -1) {
        if (l[minIndex] < l[i]+l[j]) cnt++;
        continue;
      }
      cnt += maxIndex - minIndex + 1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int M, K;
    cin >> M >> K;
    vector<int> ans;
    if((K >> M) > 0){
        cout << -1 << endl;
    }else if(M == 1) {
        if (K == 0) cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        else cout << -1 << endl;
    }else{
        for(int i = 0;i < (1 << M);i++) if(i != K)  ans.push_back(i);
        ans.push_back(K);
        for(int i = (1 << M)-1;i >= 0;i--) if(i != K)   ans.push_back(i);
        ans.push_back(K);
        for(auto a : ans)   cout << a << " ";
        cout << endl;
    }

}

Measured memory_bytes: 2932
n=int(input())
t=list(map(int,input().split()))
m=int(input())
ans_l=[]
for i in range(m):
    p,x=map(int,input().split())
    tmp=sum(t)-t[p-1]+x
    ans_l.append(tmp)

for i in range(m):
    print(ans_l[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int l = s.size();
  cout << s.substr(0, l-8) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
    int N; 
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    ll res = 0;
    for(int i = 0; i < N; i++){
        ll AB_cnt = 0;     // AでB[i]未満の要素数
        ll BC_cnt = 0;     // CでB[i]より大きい要素数
        
        AB_cnt = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        BC_cnt = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        res += AB_cnt * BC_cnt;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1408
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.trim().split_whitespace();
	let a:i64 = iter.next().unwrap().parse().ok().unwrap();
	let op = iter.next().unwrap();
	let b:i64 = iter.next().unwrap().parse().ok().unwrap();
	if op == "+" {
		println!("{}", a+b);
	}else{
		println!("{}", a-b);
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

//
// ローリングハッシュ
//
// verified:
//   ABC 141 E - Who Says a Pun?
//     https://atcoder.jp/contests/abc141/tasks/abc141_e
//

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and S[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(const RollingHash &T, int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != T.get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};


int main() {
    ll N;
    string S;
    cin >> N >> S;

    RollingHash rh(S);

    ll ans = 0;
    rep(i, N) for(ll j = i+1; j < N; j++) {
        ll lcp = rh.getLCP(i, j);
        if(i + lcp <= j) chmax(ans, lcp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
T, A = map(int, (input().split(" ")))
H = list(map(int,input().split(" ")))
ans_t = 10000
ans = 0
 
for i in range(N):
  t = T - H[i] * 0.006
  l = abs(A - t)
  if l < ans_t:
    ans_t = l
    ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    vector<ll> a(n);
    for(ll& i:a){
        cin >> i;
    }
    ll ans = 0;
    for(int i = 1; i<n; i++){
        if(a[i] < a[i-1]){
            ans+=(a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int n, m;
  cin >> n;
  map<string, int> blue;

  string word;
  for(int i = 0; i < n; ++i) {
    cin >> word;
    auto itr = blue.find(word);
    if(itr != blue.end())
      blue[word] += 1;
    else
      blue[word] = 1;
  }

  cin >> m;
  map<string, int> red;
  for(int i = 0; i < m; ++i) {
    cin >> word;
    auto itr = red.find(word);
    if(itr != red.end())
      red[word] += 1;
    else
      red[word] = 1;
  }

  for(auto itr = blue.begin(); itr != blue.end(); ++itr) {
    auto it = red.find(itr->first);
    if(it != red.end())
      itr->second -= red[itr->first];
  }


  int mv = 0;
  for(auto itr = blue.begin(); itr != blue.end(); ++itr) {
    mv = max(mv, itr->second);
  }
  cout << mv << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
  ll n;
  cin>>n;
  if(n==1)cout<<"1"<<endl;
  else{
  ll r=n;
  ll ans=1,memo=1;
  r=r/2;
  while(1){
    r=r/2;
    ans+=memo*2;
    memo*=2;
    if(r==0)break;
  }
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N ,A,B;
    cin >> N >> A>>B;
    long long  C=A+B;
    if(N%C<=A){
        cout <<N/C*A+N%C<<endl;
    }
    else{
        cout<<N/C*A+A<<endl;
    }
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = 301000;
    let mut pr = vec![true; n];
    let mut fac = vec![Vec::new(); n];
    for i in 6 .. n {
        if i % 7 != 1 && i % 7 != 6 {
            pr[i] = false;
            continue;
        }
        if !pr[i] { continue; }
        fac[i].push(i);
        for j in 2 .. (n - 1) / i + 1 {
            pr[i * j] = false;
            fac[i * j].push(i);
        }
    }
    for a in fac.iter_mut() {
        a.sort();
    }
    loop {
        let u: usize = get();
        if u == 1 { break; }
        print!("{}:", u);
        for a in &fac[u] {
            print!(" {}", a);
        }
        println!();
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 25468
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:04:49 2020

@author: masat
"""

N = int(input())

P_list = list(map(int, input().split()))

#print(P_list)

min_Pj = P_list[0]
counter = 0
for Pi in P_list:
    min_Pj = min(min_Pj, Pi)
    #print(min_Pj)
    if Pi <= min_Pj:
        counter += 1
    else:
        pass

print(counter)



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

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

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

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

int main(){
    int N;
    cin >> N;
    int d[55];
    rep(i, N) {
        cin >> d[i];
    }

    int ans = 0;
    rep(i, N) {
        rep(j, i) {
            ans += d[j] * d[i];
        }
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///

void _case(){
    ll a,b,c,k,s=0;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k el;
    else{
        k-=a;
        s+=a;
        k-=b;
        if(k>0){
            if(k<=c) s-=k;
            else s-=c;
        }
        cout<<s el;
    }
}

main()
{

    _case();

}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 3632
S = input()
n = len(S)
countc = 0
counta = 0
for m in range (3, n):
    if S[m-1] == 'C':
        countc = countc + 1
        S = S[:m-1] + 'c' + S[m:]
if S[1-1] == 'A':
    counta = 1
    S = 'a' + S[1:]
if(countc == 1 and counta == 1 and S.islower()):
    print('AC')
else:
    print('WA')

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

inline ll read() {
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

int main() {
    ll n = read();
    if (n == 2 || n == 1) puts("0");
    else {
        ll ans = 0;
        for (ll i = 1; i * i < n; i++) {
            if (n % i == 0 && i + 1 != n / i) ans += n / i - 1;
        }  
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[11],i,j,tmp;

	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]>a[j]){
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
				
			}
		}

	}

	for(i=0; i<3; i++){
		printf("%d\n", a[9-i]);

	}
	return 0;

}


Measured memory_bytes: 2104
s = input()
li = []

def push_0(li):
    li.append(0)

def push_1(li):
    li.append(1)

def push_Back(li):
    if li == []:
        a = 1
    else:
        li.pop(-1)

for i in s:
    if i == '0':
        push_0(li)
    elif i == '1':
        push_1(li)
    else:
        push_Back(li)

for i in li:
    print(i, end='')

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

void dfs(const vector<vector<pair<int, int64_t>>> &to, vector<int64_t> &d, int v, int p) {
  for (auto next : to.at(v)) {
    if (next.first == p) continue;
    d.at(next.first) = d.at(v) + next.second;
    dfs(to, d, next.first, v);
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, int64_t>>> to(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    to.at(a).emplace_back(b, c);
    to.at(b).emplace_back(a, c);
  }
  int q, k;
  cin >> q >> k;
  k--;
  vector<int64_t> d(n);
  dfs(to, d, k, -1);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << d.at(x) + d.at(y) << "\n";
  }
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll x, y; cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << "0\n";
        exit(0);
    }
    ll n = (x + y) / 3;
    if (x - n < 0 || 2 * n - x < 0) {
        cout << "0\n";
        exit(0);
    }
    const ll mod = (ll) 1e9 + 7;
    function<ll(ll, ll)> modpow = [&](ll x, ll d) {
        if (d == 0) {
            return 1ll;
        }
        ll ret = modpow(x, d / 2); ret *= ret; ret %= mod;
        if (d & 1) {
            ret *= x;
            ret %= mod;
        }
        return ret;
    };
    ll k = x - n;
    assert(n >= k);
    vector<ll> fact(n + 10, 1ll);
    for (ll i = 2; i <= n + 5; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
    }
    ll C = (fact[n] * modpow(fact[k], mod - 2)) % mod;
    C = (C * modpow(fact[n - k], mod - 2)) % mod;
    cout << C << "\n";
}


Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

int A, B, C, D, E, F;

void solve() {
	cin >> A >> B >> C >> D >> E >> F;
	A *= 100; B *= 100;
	int ans1 = 0, ans2 = 0;
	for (int a = 0; A*a <= F; a++) {
		for (int b = 0; A*a + B*b <= F; b++) {
			int x = A * a + B * b;
			for (int c = 0; A*a + B*b + C*c <= F; c++) {
				for (int d = 0; A*a + B*b + C*c + D*d <= F; d++) {
					int y = C * c + D * d;
					if (x + y <= F && 100 * y <= E * x) {
						if (ans2*(x+y) <= ans1*y) {
							ans1 = x+y;
							ans2 = y;

						}
					}
				}
			}
		}
	}
	
	cout << ans1 << " " << ans2 << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv;

void insertionSort(int n, int[] x) {
    foreach (i; 1 .. n) {
        int v = x[i];
        int j = i - 1;
        while (j >= 0 && x[j] > v) {
            x[j+1] = x[j];
            --j;
        }
        x[j+1] = v;
        foreach (k, y; x) {
            y.write;
            if (k != n - 1) " ".write;
            else writeln;
        }
    }
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    foreach (x; a) {
        x.write;
        if (x != a[n-1]) " ".write;
        else writeln;
    }
    insertionSort(n, a);
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int a,b;cin>>a>>b;
    if(a<=5)cout<<0<<endl;
    else if(a<=12)cout<<b/2<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2) puts("Borys");
  else puts("Alice");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;

    bool ok = false;
    int k = 1;
    while(1){
        int v = k*(k-1)/2;
        if(v>=n){
            if(v == n) ok = true;
            break;
        }
        ++k;
    }

    if(ok){
        cout << "Yes" << endl;
        cout << k << endl;

        int val = 1;
        vector<vector<int>> ans(k);
        rep(i,k)for(int j=i+1; j<k; ++j){
            ans[i].pb(val);
            ans[j].pb(val);
            ++val;
        }

        rep(i,k){
            cout << ans[i].size();
            for(int j:ans[i]) cout << " " << j;
            cout << endl;
        }
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

#define ld long double

int n, m;
vector <int> g[605];
ld dp[605][605];

ld DP() {
	for (int u = 0; u < n; ++ u) {
		for (int v = 0; v <= n; ++ v) dp[u][v] = 0x3f3f3f3f;
	}
	dp[n - 1][n] = 0;
	for (int u = n - 2; ~u; -- u) {
		for (int v = u; v <= n; ++ v) {
			if (v == u) {
				if (g[u].size() == 1) continue;
				ld full = 1, mx = 0;
				for (int i = 0; i < g[u].size(); ++ i) {
					int to = g[u][i];
					full += dp[to][n] / ((int) g[u].size() - 1);
					mx = max(mx, dp[to][n]);
				}
				dp[u][v] = full - mx / ((int) g[u].size() - 1);
			} else {
				dp[u][v] = 1;
				for (int i = 0; i < g[u].size(); ++ i) {
					int to = g[u][i];
					dp[u][v] += min(dp[to][v], dp[to][n]) / (int) g[u].size();
				}
			}
		}
	}
	// for (int i = 0; i < n; ++ i) printf("%.10Lf ", dp[i][i]); puts("");
	ld ans = 0x3f3f3f3f;
	for (int i = 0; i <= n; ++ i) {
		ans = min(ans, dp[0][i]);
	}
	return ans;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++ i) {
		int u, v; scanf("%d%d", &u, &v); -- u, -- v;
		g[u].pb(v);
	}
	ld ans = DP();
	printf("%.10Lf\n", ans);
	return 0;
}

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

string str;

int main() {
  cin >> str;
  vector<int> alphabet(27, 0);
  rep (i, str.length()) {
    alphabet.at(str[i] - 'a')++;
  }
  string ans = "Yes";
  rep (i, 27) {
    if (alphabet[i] % 2 != 0) ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int N;
	cin >> N;
	int M = sqrt(2 * N);
	int sum = M * (M + 1) / 2;
	while (sum < N) {
		M++;
		sum += M;
	}
	int A = sum - N;
	for (int i = 1; i <= M; i++) if (i != A) cout << i << endl;
}


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

const int N=1e2+5;
const int M=1e5+5;
ll W,n;
ll w[N];
ll v[N];
ll mem[N][M];

ll go(int i,ll we)
{
    if (i==n)
        return 0;

    if (mem[i][we]!=-1)
        return mem[i][we];

    ll path1=go(i+1,we);
    ll path2=0;
    if (w[i]+we<=W)
        path2=v[i]+go(i+1,we+w[i]);
    return mem[i][we]=max(path1,path2);
}

int main()
{
    scanf("%lld %lld",&n,&W);
    for (int i=0;i<n;i++){
        scanf("%lld %lld",&w[i],&v[i]);
    }
    memset(mem,-1,sizeof mem);

    printf("%lld\n",go(0,0));

    return EXIT_SUCCESS;
}


Measured memory_bytes: 82304
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

bool is_p(string s) {
	string r = s;
	reverse(r.begin(), r.end());
	return s == r;
}

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	bool ans = is_p(s);
	int len = s.length();
	if (ans) {
		if (!is_p(s.substr(0, (len - 1) / 2))) {
			ans = false;
		}
		if (!is_p(s.substr(len / 2 + 1))) {
			ans = false;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int mm[10];

int main(){	
	fastio;
	cin>>mm[0]>>mm[1]>>mm[2]>>mm[3]>>mm[4];
	int k;cin>>k;
	bool f=true;
	FER(i,0,5)FER(j,i+1,5){
		int dif=mm[j]-mm[i];
		if(dif>k)f=false;
	}
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
program bbb

implicit none
integer :: n, d, i, j, k, co
real :: r
integer, allocatable, dimension(:,:) :: x

read*, n, d
allocate(x(d,n))
read*, x

co=0

do i=1,n
 do j=i+1,n
  r=0
  do k=1,d
  r=r+(x(k,i)-x(k,j))**2
  end do
 r=r**0.5
 if(r==int(r)) co=co+1
 end do
end do

write(*,'(i0)') co

end program

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int w,h,k;
inline ll solve(int w,int h,int k){
	ll ans=0;
	FOR(y,1,w){
		++ans;
		For(z,2,h-1){
			if (1ll*y*z+1ll*z*(w-y)-__gcd(z,y)-__gcd(w-y,z)-w<=2*k-2) ++ans;
			int l=1,r=z-1,tmp=__gcd(w-y,z),L=0,lim=2*k-2;
			while (l<=r){
				int mid=l+r>>1;
				if (1ll*y*z+1ll*(w-y)*mid-2-tmp<=lim) L=mid,l=mid+1;
					else r=mid-1;
			}
			int ret=2*L,R=L;
			For(x,L+1,z-1){
				if (1ll*y*z+1ll*(w-y)*x-y-min(z-x,w)-tmp>lim){R=x-1;break;}
				if (1ll*y*z+1ll*(w-y)*x-tmp-__gcd(x,y)-__gcd(w,z-x)<=lim){
					ret+=2;
				}
			}
			ans+=ret;
			if (R==0) break;
		}
	}
	return ans;
}

int main(){
	w=read(),h=read(),k=read();
	if (w==1||h==1) return puts("0"),0;
	printf("%lld\n",2*(solve(w,h,k)+solve(h,w,k)));
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,v,w,c,n,t,m,k,x,y=0,ans=1;
    string str,s="",u;
    cin>>a>>v>>b>>w>>t;
    if(w>=v)cout<<"NO";
    else{
        if((v-w)*t>=abs(a-b) and (abs(a-b)/(v-w)<=t)){
            cout<<"YES";
        }else{
            cout<<"NO";
        }
    }




    cout<<endl;
    return 0;
}




Measured memory_bytes: 3680
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n=I()
a=LI()

d={}
nd={}
for i,x in enumerate(a):
    if x in d:
        d[x]=min(i,d[x])
        nd[x]+=1
    else:
        d[x]=i
        nd[x]=1

A=sorted([i for i in d.items()],key=lambda x:x[0])
ans=[0]*n
px,pm=A.pop()
nn=nd[px]
while A:
    x,m=A.pop()
    ans[pm]+=(px-x)*nn
    nn+=nd[x]
    px,pm=x,min(m,pm)
ans[0]+=sum(a)-sum(ans)
for i in ans:
    print(i)

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

void testCase() {    
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double R;
    cin >> R;
    double PI = 3.14159265;
    cout << 2*PI*R << "\n";
}
















Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,m;
	cin>>n>>m;
	ll ans=1;
	vector<int> a(n),b(m),flag(n*m,0);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		a[i]--;
		if(flag[a[i]]>0){
			ans=0;
		}
		flag[a[i]]=1;
	}
	for(int i = 0; i < m; i++){
		cin>>b[i];
		b[i]--;
		if(flag[b[i]]>=2){
			ans=0;
		}
		if(flag[b[i]]>0) flag[b[i]]=3;
		else{
			flag[b[i]]=2;
		}
	}

	int j=-1,k=-1;
	for(int i = n*m-1; i >= 0 ; i--){
		if(flag[i]==3){
			j++;
			k++;
		}else if(flag[i]==2){
			ans*=j+1;
			ans%=mod;
			k++;
		}else if(flag[i]==1){
			ans*=k+1;
			ans%=mod;
			j++;
		}else{
			ans*=((j+1)*(k+1)-(n*m-(i+1)));
			ans%=mod;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int>d(n);
  for(int i=0;i<n;i++) cin >> d[i];
  int sum = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum += d[i]*d[j];
    }
  }
  cout<< sum <<endl;
}


Measured memory_bytes: 256
#Cbit全探索
n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for i in range(n)]
ans = [0]*(m+1); ans[0] = 10**7  
for i in range(2**n):
    state = [0]*(m+1)
    for j in range(n):
        if (i >> j) & 1:
             for k in range(m+1):
                state[k] += books[n-1-j][k]
    for j in range(1,m+1):
        if state[j] < x:
            break
    else:
        if ans[0] >= state[0]:
            ans = state
if ans[0] == 10**7:
	print(-1)
else:
  print(ans[0])

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;


long long fac[300001], finv[300001], inv[300001];
const int MOD = 998244353;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 300001; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N, A, B, K;
    cin >> N >> A >> B >> K;
    COMinit();
    ll ans = 0;
    for(ll i = 0; i*A <= K; i++){
        if( (K-i*A) % B != 0){
            continue;
        }
        ll j = (K-i*A)/B;
        ans = (ans + (COM(N, i)*COM(N, j))%MOD)%MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7296
import sys
from collections import defaultdict


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


sys.setrecursionlimit(20000000)


def main():
    N, T = map(int, input().split())
    A = list(map(int, input().split()))
    m = float("inf")
    count = defaultdict(int)
    for i in range(N):
        if A[i] < m:
            m = A[i]
        else:
            count[A[i] - m] += 1
    K = list(count.keys())
    print(count[max(K)])


if __name__ == "__main__":
    main()


Measured memory_bytes: 20952
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    r=n+m+l;
    (r>=22)? cout<<"bust\n":cout<<"win\n";
    return 0;
}



Measured memory_bytes: 256
n, x = list(map(int, input().split()))

def level_n_putty(n):
    if n == 0:
        return 1
    else:
        return 2 * level_n_putty(n-1) + 1

def level_n_hb(n):
    if n == 0:
        return 1
    else:
        return 2 * level_n_hb(n-1) + 3

m = level_n_hb(n)

s = 0
base = 0

while True:
    if x == base + 1:
        if n == 0:
            s += 1
        break
    elif x == base + m:
        s += level_n_putty(n)
        break
    else:
        l = level_n_hb(n-1)
        #print(n, base + l + 2, x)
        if x < base + l + 2:
            base += 1
            n -= 1
            m = l
        elif x == base + l + 2:
            s += 1 + level_n_putty(n-1)
            break
        else:
            base = base + l + 2
            s += 1 + level_n_putty(n-1)
            n -= 1
            m = l

print(s)


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

void chmax(int &a, int b) { if (a < b) a = b; return; }

int main(){
    int n; cin >> n;
    vector<int> v(n + 1), w(n + 1);
    for (int i = 1; i <= n; i++) cin >> v[i] >> w[i]; // 1-index

    int q; cin >> q;
    vector<int> vv(q), l(q);
    for (int i = 0; i < q; i++) cin >> vv[i] >> l[i];

    int L = *max_element(l.begin(), l.end());
    vector<int> depth(n + 1, 0);
    for (int i = 2; i <= n; i++) depth[i] = depth[i / 2] + 1;
    int K = depth[n] / 2 + 1;

    vector<vector<int>> dp(1 << K, vector<int>(L + 1, 0));
    for (int i = 1; i < (1 << K); i++) {
        for (int j = 0; j <= L; j++) {
            dp[i][j] = dp[i / 2][j];
            if (j) chmax(dp[i][j], dp[i][j - 1]);
            if (j >= w[i]) chmax(dp[i][j], dp[i / 2][j - w[i]] + v[i]);
        }
    }

    for (int i = 0; i < q; i++) {
        int id = vv[i], cap = l[i];
        if (depth[id] < K) {
            cout << dp[id][cap] << endl;
            continue;
        }

        vector<pair<int,int>> check;
        for ( ; depth[id] >= K; id /= 2) {
            check.push_back(make_pair(v[id], w[id]));
        }

        int ans = 0;
        for (int j = 0; j < (1 << (int)check.size()); j++) {
            int count = 0, cost = 0;
            for (int k = 0; k < (int)check.size(); k++) {
                if (j & (1 << k)) {
                    count += check[k].first;
                    cost += check[k].second;
                }
            }
            if (cost > cap) continue;
            count += dp[id][cap - cost];
            chmax(ans, count);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 208068
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
    }

    let mut ans: usize = 0;
    for i in 1..N + 1 {
        let n = N / i;
        ans += i * n * (n + 1) / 2;
    }
    //ans = a.iter().fold(0, |a, x| a + x);
    echo!(ans);
}


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

using namespace std;

int days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(void) {
    int M, D;
    while(1) {
        int elapsed = 0;
        cin >> M >> D;

        if(M == 0 && D == 0) break;

        for(int i = 1; i < M; i++) elapsed += days[i];

        elapsed += D;

        int t = elapsed % 7;

        if(t == 1) {
            cout << "Thursday" << endl;
        } else if(t == 2) {
            cout << "Friday" << endl;
        } else if(t == 3) {
            cout << "Saturday" << endl;
        } else if(t == 4) {
            cout << "Sunday" << endl;
        } else if(t == 5) {
            cout << "Monday" << endl;
        } else if(t == 6) {
            cout << "Tuesday" << endl;
        } else {
            cout << "Wednesday" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int n;

	cin >> n;
	vector<int> vec(n);
	map<int, int> m;
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		m[temp]++;
	}

	int ans = 0;
	for (auto a : m) {

		if (a.second % 2 != 0) {
			ans++;
		}

	}

	cout << ans << endl;
	
}


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

int main() {
    int n;
    cin >> n;

    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> q(n);
    rep(i, n) cin >> q[i];

    vector<int> v(n);
    rep(i, n) v[i] = i + 1;

    int cur = 1, a, b;
    do {
        if (v == p) a = cur;
        if (v == q) b = cur; 
        cur++;
    } while(next_permutation(v.begin(), v.end()));
    
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
long long a[10000000];
using namespace std;
int main(){
	long long n,l,max=0,s=0,res=0;
	cin>>n>>l;
	for (int i=1;i<=n;i++){
		a[i]=l+i-1;
		s+=a[i];
	}
	max=abs(a[1]);
	res=a[1];
	for (int i=2;i<=n;i++)
		if (abs(a[i])<max){
			max=abs(a[i]);
			res=a[i];
		}
	cout<<s-res;
	return 0;
}

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

using namespace std;

int main() {
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int n, s, sum, cnt;

    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        for (int i = 0; i < (1 << 10); i++) {
            sum = 0;
            for (int j = 0; j < 10; j++) {
                // if (bitset<10>(i).test(j)) {
                if (i & (1 << j)) {
                    sum += a[j];
                }
            }
            if (sum == s && bitset<10>(i).count() == n) { cnt++; }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  
  int j =0;
  int s =0;
  
  while(j < n-1){
    s += v.at(j);
    j++;
  }
  
  s += v.at(n-1) / 2;
  cout << s << endl;
}

Measured memory_bytes: 256