akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    ll cnt1 = 0;  // '<'の個数
    ll cnt2 = 0;  // '>'の個数
    ll ans = 0;
    rep(i, n) {
        if(s[i] == '<') {
            cnt1++;
        }
        else if(s[i] == '>') {
            cnt2++;
        }
        if(s[i] == '>' && s[i+1] == '<') {
            ll x = max(cnt1, cnt2);
            ll y = min(cnt1, cnt2);
            ans += x*(x+1)/2;
            ans += y*(y-1)/2;
            cnt1 = 0;
            cnt2 = 0;
        }
    }
    ll x = max(cnt1, cnt2);
    ll y = min(cnt1, cnt2);
    ans += x*(x+1)/2;
    ans += y*(y-1)/2;
    
    out(ans);
    re0;
}

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

const int N=20005;
int n,p[N],a[N],c[N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",p+i),c[p[i]]=i+(int)9e8;
	a[1]=1;
	for(int i=2;i<=n;++i)a[i]=a[i-1]+max(1,-(c[i-1]-c[i])+1);
	for(int i=1;i<=n;++i)printf("%d%c",a[i]," \n"[i==n]);
	for(int i=1;i<=n;++i)printf("%d%c",c[i]-a[i]," \n"[i==n]);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, k; cin >> n >> k;
	vi v(n+1); set<int> st;
	REP(i, n)
	{
		int a; cin >> a;
		v[a]++;
		st.insert(a);
	}
	sort(ALL(v));
	int ans = 0;
	int cnt = 0;
	REP(i, n)
	{
		if (v[i] == 0) continue;
		if (st.size() - cnt <= k) break;
		ans += v[i];
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long K){
    for(int i=0;i<K;i++){
        if(A>=B){
            B*=2;
        }else{
            C *= 2;
        }
    }
    if(B >A && C >B){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

const int N = 505000;
const int mod = 1e9 + 7;
const ll inf = 1e18;

int n, a[N];

ll s[N];
vector<pair<ll, ll> > fi[N], se[N];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n;
    fo(i, n)
        cin >> a[i];
    fo(i, n) s[i] = s[i-1]+ a[i];
    set<ll> v;
    fo(i, n) {
        ll cur = s[i];
        cur = (cur + 1) / 2;
        auto it = v.lower_bound(cur);
        auto it2 = it;
        for(int j = 0; j < 4; ++j) {
            if(it2 == v.end()) break;
            fi[i].pb({*it2, s[i] - *it2});
            it2++;
        }
        for(int j = 0; j < 4; ++j) {
            if(it == v.begin()) break;
            it--;
            if(*it != 0 && s[i] - *it != 0)
                fi[i].pb({*it, s[i] - *it});
        }
        v.insert(s[i]);
    }
    ll sum = 0;
    v.clear();
    for(int i = n; i >= 1; --i) {

        sum += a[i];
        ll cur = sum;
        cur = (cur + 1) / 2;
        auto it = v.lower_bound(cur);
        auto it2 = it;
        for(int j = 0; j < 4; ++j) {
            if(it2 == v.end()) break;
            if(*it2 != 0 && sum - *it2 != 0)
                se[i].pb({*it2, sum - *it2});
            it2++;
        }
        for(int j = 0; j < 4; ++j) {
            if(it == v.begin()) break;
            it--;
            if(*it != 0 && sum - *it != 0)
                se[i].pb({*it, sum - *it});
        }
        v.insert(sum);
    }
    ll res = 1e18;
    for(int i = 2; i + 2 <= n; ++i) {
        if(fi[i].size() && se[i + 1].size()) {
            for(auto &x : fi[i])
                for(auto &y : se[i+1]) {
                    ll mx = max(x.first, x.second);
                    mx = max(y.first, mx);
                    mx = max(y.second, mx);
                    ll mn = min( x.first, x.second);
                    mn = min(y.first, mn);
                    mn = min(y.second, mn);
                    res = min(res, mx - mn);
                }
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 94592
#!/usr/bin/env python3
import sys


def solve(S: int):
    S = str(S)
    ans = 10**3
    for i in range(0, len(S)-2):
        ans = min(ans, abs(753 - int(S[i:i+3])))
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


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

int main(){
	string S, T;
	cin >> S >> T;
	bool flag = false;
	int begin;
	for (begin = S.size() - T.size(); begin >= 0; --begin){
		flag = true;
		for (int j = 0; j < T.size(); ++j){
			if(S[begin + j] != '?' && S[begin + j] != T[j]){
				flag = false;
				break;
			}
		}
		if(flag) break;
	}
	if(!flag){
		printf("UNRESTORABLE\n");
		return 0;
	}
	for (int i = 0; i < begin; ++i){
		if(S[i] == '?') S[i] = 'a';
	}
	for (int i = begin; i < begin + T.size(); ++i){
		if(S[i] == '?') S[i] = T[i - begin];
	}
	for (int i = begin + T.size(); i < S.size(); ++i){
		if(S[i] == '?') S[i] = 'a';
	}
	for (int i = 0; i < S.size(); ++i){
		printf("%c", S[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
#C-116
n = int(input())
h_diff = [int(i) for i in input().split()]
ans = 0
for ni in range(n):
  while h_diff[ni] > 0:
    if 0 in h_diff[ni+1:]:
      r = h_diff[ni+1:].index(0) + (ni+1)
      ans += min(h_diff[ni:r])      
      h_diff[ni:r] = [i - min(h_diff[ni:r]) for i in h_diff[ni:r]]
    else:
      ans += min(h_diff[ni:])      
      h_diff[ni:] = [i - min(h_diff[ni:]) for i in h_diff[ni:]]
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int find(int n,int x){
	if(n==1) return(x);
	return(x+find(n/2,x*2));
}

int32_t main(){
	IOS;
	int n;cin>>n;
	cout<<find(n,1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> num(n);
    
    for(int i = 1; i <= n; ++i) {
        int a;
        cin >> a; --a;
        num[a] = i;
    }
    
    for(int i = 0; i < n; ++i) cout << num[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	cout << ((a % x != 0) ? (b / x - a / x) : (b / x - a / x + 1));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
ll pow2(ll a,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*a;
        }
        a=a*a;
        n>>=1;
    }
    return res;
}
int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    rep(i,n){
        int a=i+1;
        double tmp=1.0/n;
        while(a<k){
            a*=2;
            tmp/=2;
        }
        ans+=tmp;
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 3784
n=gets.to_i
a=[]
n.times do
  a << gets.to_i
end
a.sort!
if n==2
  puts a[1]-a[0]
elsif n==3
  puts [a[2]+a[1]-2*a[0],2*a[2]-a[1]-a[0]].max
elsif n.odd?
  if a[n/2]-a[n/2+1]>a[n/2-1]-a[n/2]
    puts -2*a[0..n/2-1].sum+a[n/2..n/2+1].sum+2*a[n/2+2..n-1].sum
  else
    puts -2*a[0..n/2-2].sum-a[n/2-1..n/2].sum+2*a[n/2+1..n-1].sum
  end
else
  puts -2*a[0..n/2-2].sum-a[n/2-1]+a[n/2]+2*a[n/2+1..n-1].sum
end


Measured memory_bytes: 16580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int coin_1 = sc.nextInt();
        
        System.out.println(coin_1 >= n % 500 ? "Yes" : "No");
    
    }
}


Measured memory_bytes: 25172
import math
N,K=map(int,input().split())

A=[i for i in range(N+1)]
wa=0
N=N+1
for i in range(K,N+1):

    mi=(i*(0+(i-1)))/(2)
    ma=(i*(N-i+(N-1)))/(2)

    wa=ma-mi+1+wa


wa=wa%(10**9+7)
print(int(wa))


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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

using bigint = boost::multiprecision::cpp_int;
using decfloat = boost::multiprecision::cpp_dec_float_50;

int main() {
  in(ll, n);
  bigint ans = 0;
  for (ll i = n; i >= 1; --i) ans += i * (n + 1 - i);
  dbg(ans);
  rep(i, n - 1) {
    in(ll, u, v);
    if (u > v) swap(u, v);
    ll x = u * (n - (v - 1));
    dbg(x);
    ans -= x;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n;
	char str[1024];

	scanf("%d ", &n); // neglect \n

	for (int i = 0; i < n; i++){
		fgets(str, sizeof(str), stdin); // include space 

		int len = strlen(str);
		for (int j = 0; j < len - 6; j++){
			if (strncmp(str + j, "Hoshino", 7) == 0){
				str[j + 6] = 'a';
			}
		}

		cout << str;
	}

	return (0);
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using i64 = long long;

i64 gcd(i64 a, i64 b) {
    if (b > a) std::swap(a, b);
    i64 m = a % b;
    return m ? gcd(b, m) : b;
}

auto sieve(i64 n) {
    std::vector<i64> ps, lp(n + 1);
    for (int i = 2; i <= n; i++) {
        if (!lp[i]) {
            lp[i] = i;
            ps.push_back(i);
        }
        for (int j = 0; j < (int)ps.size() && ps[j] <= lp[i] && i * ps[j] <= n; j++) {
            lp[i * ps[j]] = ps[j];
        }
    }
    return ps;
}

bool poly_div(std::vector<i64> a, const i64 p) {
    int n = (int)a.size() - 1;
    if (a[0] % p) return false;
    for (int i = n; i - p + 1 >= 0; i--) {
        a[i % (p - 1)] = (a[i % (p - 1)] + a[i]) % p;
        a[i] = 0;
    }
    return std::all_of(a.begin(), a.end(), [=](auto i) { return !(i % p); });
}

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n + 1);
    std::set<i64> ret;
    for (int i = 0; i <= n; i++) std::cin >> a[i];
    i64 g = abs(a[0]);
    for (int i = 1; i <= n; i++) if (a[i]) g = gcd(abs(a[i]), g);

    for (i64 i = 2; i * i <= g; i++) {
        if (g % i) continue;
        ret.insert(i);
        while (g % i == 0) g /= i;
    }
    if (g > 1) ret.insert(g);

    auto ps = sieve(n);
    std::reverse(a.begin(), a.end());
    for (auto p : ps) if (poly_div(a, p)) ret.insert(p);

    for (auto p : ret) std::cout << p << std::endl;

    return 0;
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
    for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {
        s << endl << P[i];
    }
    return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char s;
    cin >> s;
    if (s - 'a' >= 0) {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
    return 0;
}

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


int max_koyakusu(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	if (a%b==0) return b;
	return max_koyakusu(b, a%b);
}


int main(void) {
	int N, X;
	cin >> N >> X;

	vector <int> fromX;
	for (int i = 1; i <= N; i++) {
		int city;
		cin >> city;
		fromX.push_back(abs(X-city));
	}
	std::sort(fromX.begin(), fromX.end());

	int ans = fromX.at(0);
	for (int i = 1; i < fromX.size(); i++) {
		ans = max_koyakusu(fromX.at(i), ans);
	}
	cout << ans << endl;  
  
  return 0;
}


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

//#pragma GCC optimize("ffast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

using namespace std;

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len)
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    if (pos == len)
        return -1;
    return buf[pos++];
}

inline int readChar() {
    int c = getChar();
    while (c <= 32)
        c = getChar();
    return c;
}

template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
    if (x < 0)
        writeChar('-'), x = -x;

    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}

inline void writeWord( const char *s ) {
    while (*s)
        writeChar(*s++);
}

struct Flusher {
    ~Flusher() {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;

typedef long long ll;
typedef long double ld;

const ld EPS = 1e-9;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    for (ll a = 1; a <= 3500; ++a) {
        for (ll b = a; b <= 3500; ++b) {
            ll t1 = 4 * a * b - (a + b) * n;
            ll t2 = n * a * b;
            if (t1 > 0 && t2 % t1 == 0) {
                cout << a << ' ' << b << ' ' << t2 / t1;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int r, c, i, j;
	int elements[101][101] = { 0 };

	scanf("%d %d", &r, &c);
	for (j = 0; j < r; j++){
		for (i = 0; i < c; i++){
			scanf("%d", &elements[j][i]);
			elements[j][c] += elements[j][i];
			elements[r][i] += elements[j][i];
		}
	}
	for (i = 0; i < c; i++){
		elements[r][c] += elements[r][i];
	}
	for (j = 0; j <= r; j++){
		for (i = 0; i <= c; i++){
			printf("%d", elements[j][i]);
			if (i < c){
				printf(" ");
			}else{
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, next[10001];
bool ok[10001];

int main(){
	while(cin >> n, n){
		vi ans;
		map<string, int> m;
		rep(i, n) next[i] = -1, ok[i] = 0;
		rep(i, n){
			bool skip = 0;
			string s;
			cin >> s;
			if(s[s.size() - 1] == 'v'){
				next[i + 1] = i;
				s.erase(s.end() - 1);
				skip = 1;
			}
			if(s != "-"){
				int d = 0, ten = 1;
				while(s.size() && isdigit(s[s.size() - 1])){
					d += (s[s.size() - 1] - '0') * ten;
					s.erase(s.end() - 1);
					ten *= 10;
				}
				if(m.count(s)) next[i] = m[s];
				m[s] = i;
				if(d > 1) skip = 1;
				else m.erase(s);
			}
			if(!skip) for(int j = i; j >= 0 && !ok[j]; j = next[j]){
				ans.pb(j);
				ok[j] = 1;
			}
		}
		rep(i, n) cout << ans[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1800
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
    int n,i,j,k;
    long long s1,s2,sum,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
            x=a[0];
            s1=0;
            if(a[0]<=0)
            {
                s1=1-a[0];
                x=1;
            }
            for(i=1;i<n;i++)
            {
                y=x;
                x=x+a[i];
                if(x*y<0)
                    continue;
                if(y<0)
                {
                    s1=s1-x+1;
                    x=1;
                }
                else
                if(y>0)
                {
                    s1=s1+x+1;
                    x=-1;
                }
            }
            x=a[0];
            s2=0;
            if(a[0]>=0)
            {
                s2=s2+a[0]+1;
                x=-1;
            }
            for(i=1;i<n;i++)
            {
                y=x;
                x=x+a[i];
                if(x*y<0)
                    continue;
                if(y<0)
                {
                    s2=s2-x+1;
                    x=1;
                }
                else
                if(y>0)
                {
                    s2=s2+x+1;
                    x=-1;
                }
            }
            sum=min(s1,s2);
            printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 0;
const int M=1e9+7;

V<int> fact;

void euclid(int a, int b, int &x, int &y, int &d) {
    if (b == 0) x=1, y=0, d=a;
    else euclid(b, a%b, y, x, d), y -= a/b*x;
}

int inv(int a, int m=M) { // a^-1 (mod m)
    int x,y,d; euclid(a,m,x,y,d);
    return (x + m) % m;
}
int ipow(int a, int b) {
    if (b == 0) return 1;
    int rt = ipow(a, b/2);
    (rt *= rt) %= M;
    return b%2 ? (rt*a)%M : rt;
}
int safeMod(int n) {
    return (n%M+M)%M;
}
int prob(int n, int k, int p) {
    return fact[n] * inv(fact[k] * fact[n-k] % M) % M * ipow(p, k) % M * ipow(safeMod(1-p), n-k) % M;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b,c; cin>>n>>a>>b>>c;
    int N = 2*n+5;
    fact.resize(N);
    fact[0] = 1;
    FR(i,1,N) fact[i] = fact[i-1] * i % M;//(fact[i-1] * inv(i)) % M;
    H(fact)
    int ans = 2*n-1;
    int pp = (a * inv(a+b))%M, qq = (b * inv(a+b))%M;
    for (int p : {pp,qq}) {
        H(p)
        int exc = 0, cur = 0;
        FR(k,n,2*n-1) {
            H((p * prob(k-1, n-1, p) % M * ipow(2,k) % M))
            (cur += p * prob(k-1, n-1, p)) %= M;
            H((cur * ipow(2, k)) % M)
            (exc += cur) %= M;
            H((exc * ipow(2, k)) % M)
        }
        ans = safeMod(ans - exc);
    }
    (ans *= 100 * inv(100 - c) % M) %= M;
    cout<<ans<<"\n";
}

Measured memory_bytes: 1792
l,r=map(int,input().split())

sho_l = l // 2019
sho_r = r // 2019

if sho_r-sho_l >= 1:
  print(0)
else:
  ans = 2018
  flg_end = 0
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min((i*j)%2019,ans)
      if ans == 0:
        flg_end = 1
    if flg_end == 1:
      break
  print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        print((n + m) / 2);
    }
}



Measured memory_bytes: 3224
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let x: Vec<u64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut ans = 1;
    let mut cnt = 0;
    const MOD: u64 = 1_000_000_007;
    for x in x {
        cnt += 1;
        if 2 * cnt - 1 > x {
            ans = ans * cnt % MOD;
            cnt -= 1;
        }
    }
    while cnt > 1 {
        ans = ans * cnt % MOD;
        cnt -= 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 50;

void solve() {
	int h, n;
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << (sum >= h ? "Yes" : "No");
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	v := n
	for {
		sum += v % 10
		v /= 10
		if v == 0 {
			break
		}
	}
	if n%sum == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll s,w;
	cin>>s>>w;
	
	if(w>=s)
		cout<<"unsafe \n";
	else cout<<"safe \n";
	
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> cnt(m+1);
    rep(i,n) {
        int k; cin>>k;
        rep(j,k) {
            int x; cin>>x;
            cnt[x]++;
        }
    }

    int ans = 0;
    rep(i,m+1) {
        if (cnt[i] == n) ans++;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
	int i,j;
	int n,k;
	int c[100];
	
	int sensei;
	int temp;
	
	int cmin=10;
	int cmax=1;
	int tempEX;
	int student;
	int studentresult;
	int studentmax;
	
	for(;;){
		sensei=0;
		studentmax=0;
		///////////////////////////////////////入力
		scanf("%d %d",&n,&k);
		if(n==0 && k==0) break;
		
		for(i=0;i<n;i++){
			scanf("%d",&c[i]);
		}
		
		///////////////////////////////////////先生の最大値senseiを出す
		for(i=0;i<n-k+1;i++){
			temp=1;
			
			for(j=i;j<k+i;j++){
				temp = temp * c[j];
			}
			if(temp > sensei) sensei = temp;
			
		}
		/////////////////////////////////////
		
		for(i=0;i<n-k+1;i++){
			temp=1;
			cmin=10;
			cmax=1;
			
			for(j=i;j<k+i;j++){
				temp = temp * c[j];
				if(cmin>c[j]) cmin=c[j];
			}
			
			tempEX = temp / cmin;
			
			//////////////////////////////1番大きい数を見つける
			for(j=0;j<i;j++){
				if(cmax<c[j])cmax=c[j];
			}
			for(j=k+i;j<n;j++){
				if(cmax<c[j])cmax=c[j];
			}
			//////////////////////////////
			student = tempEX * cmax;
			
			studentresult = student - sensei;
			
			if(studentresult>studentmax) studentmax = studentresult;
			
		}
		///////////////////////////////////
		if(studentmax<0) printf("NO GAME\n");
		else printf("%d\n",studentmax);
	}
	
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String[] args)
    {
        //変数
        int count=0;
        boolean sw=false;
        int max=Integer.MIN_VALUE;
        int min=Integer.MAX_VALUE;
        int answer=0;
        List<Integer> a=new ArrayList<>();
        int tmp=0;
        //入力
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int D=sc.nextInt();
        int E=sc.nextInt();
        //処理
        a.add(10-A%10);
        a.add(10-B%10);
        a.add(10-C%10);
        a.add(10-D%10);
        a.add(10-E%10);
        for(int i=0;i<5;i++)
        {
            tmp=a.get(i);
            if(tmp==10)
            {
                a.set(i,0);
            }
        }
        for(int i=0;i<5;i++)
        {
            if(max<a.get(i))
            {
                max=a.get(i);
            }
        }
        //System.out.println(Arrays.toString(a.toArray()));
        A+=a.get(0);
        B+=a.get(1);
        C+=a.get(2);
        D+=a.get(3);
        E+=a.get(4);
        //System.out.println(max);
        answer=A+B+C+D+E-max;
        /*
        Collections.sort(a);
        System.out.println(Arrays.toString(a.toArray()));
        System.out.println(A);
        System.out.println(B);
        System.out.println(C);
        System.out.println(D);
        System.out.println(E);
        */
        System.out.println(answer);
    }
}

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


using namespace std;
#define ll long long

int N;
ll A[100010];

class Number{
public:
	ll high, low;
	Number(ll n)
	{
		high = n / (ll)(1e9);
		low = n % (ll)(1e9);
	}
	bool mult(const Number& b)
	{
		if(high * b.high > 1 || (high * b.high == 1 && low + b.low != 0))
		{
			return false;
		}
		ll tmp = low * b.low;
		high = (high * b.low + low * b.high) + tmp / (ll)(1e9) + (high * b.high * 1e9);
		low = tmp % (ll)(1e9);
		if(high > (ll)(1e9) || (high == (ll)(1e9) && low != 0))
		{
			return false;
		}
		return true;
	}
	ll val()
	{
		return high * (ll)(1e9) + low;
		
	}
	
};

int main()
{
	cin>>N;
	for(int i = 1; i <= N; ++i)
	{
		cin>>A[i];
		if(A[i] == 0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	Number res(1);
	bool ok = true;
	for(int i = 1; i <= N; ++i)
	{
		bool ret = res.mult(Number(A[i]));
		if(!ret)
		{
			ok = false;
			break;
		}
	}
	if(ok)
		cout<<res.val()<<endl;
	else
		cout<<-1<<endl;
}


Measured memory_bytes: 4364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace ABC135
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInts();
            var a = s[0];
            var b = s[1];
            int k = 0;

            k = (a + b);
            if (k % 2 == 1)
            {
                WriteLine("IMPOSSIBLE");
            }
            else
            {
                k /= 2;
                WriteLine("{0}", k);
            }
            Read();
        }
        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    }
}


Measured memory_bytes: 13268
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int A,B;
	cin>>A>>B;
	cout<<6-A-B<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF int(1e-6)
#define MAX int(1e9)
typedef long long ll;
typedef long l;




int main (){
	int n,x;
	string s;
	cin >> n;
	int maximo = 0;
	map<string,int>m;
	for(int i = 0; i<n ; i++){
		cin >> s;
		if(m.count(s)){
			m[s]+=1;
		}else{
			m.insert(make_pair(s,1));
		}
	}
	for (std::map<string,int>::iterator it=m.begin(); it!=m.end(); ++it){
		maximo = max(maximo,it->second);
	}
	
	vector<string>v;
	for (std::map<string,int>::iterator it=m.begin(); it!=m.end(); ++it){
		if(it->second == maximo){
			v.push_back(it->first);
		}
	}
	sort(v.begin(),v.end());
	for(int i = 0; i<v.size(); i++){
		cout << v[i] << "\n";
	}
	return 0;
}



Measured memory_bytes: 26996
N, M = list(map(int, input().split()))
lst = [input().split() for lst in range(M)]
pn = 0
lst_pn = []
lst_cr = []
for _ in range(N):
  lst_pn.append(0)
  lst_cr.append(0)
cr = 0
for i in lst:
  a = int(i[0])
  if lst_cr[a-1] == 1:
    continue
  elif i[1] == "WA":
    lst_pn[a-1] += 1
  elif i[1] == "AC":
    cr += 1
    lst_cr[a-1] += 1
    pn += lst_pn[a-1]
print(cr, pn)

Measured memory_bytes: 33852
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

bool comp(const pair_t &a, const pair_t &b) {
    return a.second < b.second;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair_t> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end(), comp);
    int ans = 0;
    int pos = 0;
    rep(i, m) {
        if (p[i].first >= pos) {
            ans += 1;
            pos = p[i].second;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int now = 0;
    ll cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(a <= now) continue;
        if(a == now+1) now++;
        else {
            cnt += (a-1)/(now+1);
            if(!now) now++;
        }
    }

    cout << cnt << endl;
}

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

void swap_elements(int &a, int &b)
{
    int temp = b;
    b = a;
    a = temp;
}
int main()
{
    string S;

    cin >> S;
    deque<char> mydeque(S.begin(), S.end());
    int Q;

    cin >> Q;
    int start = 0; 
    int end = 1;
    // int i = 0;
    while(Q--)
    {
        int que_num ; char que_val;

        cin >> que_num ;

        int Fi; char Ci; 

        if(que_num  == 1)
        {
            swap_elements(start, end);
        }
        if(que_num == 2)
        {
            cin >> Fi >> Ci;
            if(Fi == 1)
            {
                if(start == 0)
                {
                    mydeque.push_front(Ci);
                }
                else
                {
                    mydeque.push_back(Ci);  
                }
            }
            if(Fi == 2)
            {
                // int starting_elem = end ? end == 1: start;
                if(end == 1 )
                {
                    mydeque.push_back(Ci);
                }
                else
                {
                    mydeque.push_front(Ci);  
                }

            }
        }

    }

    // int starting_elem = end ? end == 1: start;
    string string_to_return = "";
    for(auto val : mydeque)
    {
        string_to_return += val;
    }
    if(start == 0)
    {
        cout << string_to_return << endl;
    }
    else
    {
        reverse(string_to_return.begin(), string_to_return.end());
        cout << string_to_return << endl;
    }

    return 0;
}

Measured memory_bytes: 1412
import sys
from heapq import heappop, heappush

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    V = list(map(int, input().split()))

    ans = 0
    for left in range(min(N, K) + 1):
        for right in range(min(N, K) - left + 1):
            heap = []
            for v in V[:left]:
                heappush(heap, v)

            for v in V[N - right:]:
                heappush(heap, v)

            cnt = left + right
            while cnt < K and len(heap) > 0:
                v = heappop(heap)
                if v > 0:
                    heappush(heap, v)
                    break

                cnt += 1

            ans = max(ans, sum(heap))

    return ans


if __name__ == '__main__':
    print(main())


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

int main() {
	// your code goes here
	int n,k,t;
	cin>>n>>k>>t;
	//cout<<n%k;
	int x = n/k + (n%k==0 ? 0 : 1);
	cout<<x*t;
	return 0;
}

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

bool f(pair<int,int> x,pair<int,int> y){
	if(x.first<y.first)return true;
	if(x.first>y.first)return false;
	if(x.second>y.second)return false;
	return true;
}

int main(){
while(1){
	int a,b,n,k=0,sum[20][20];
	pair<int,int> p;
	vector<pair<int,int>> c;
	scanf("%d%d",&a,&b);
	if(a==0&&b==0)break;
	scanf("%d",&n);
	p.first=100; p.second=100;
	c.push_back(p);
	for(int i=0;i<n;i++){
		scanf("%d%d",&p.first,&p.second);
		c.push_back(p);
	}
	sum[0][0]=1;
	sort(c.begin(),c.end());
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(!(i==0&&j==0))sum[i][j]=0;
			if(i!=0)sum[i][j]+=sum[i-1][j];
			if(j!=0)sum[i][j]+=sum[i][j-1];
			p.first=i+1; p.second=j+1;
			if(c[k]==p){sum[i][j]=0; k++;}
		}
	}
	printf("%d\n",sum[a-1][b-1]);
}
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(H);
    scanInt(W);
    vector<vector<char>> board(H, vector<char>(W, true));
    int white_count = 0;
    REP(i, H){
        REP(j, W){
            if (getchar() == '#'){
                board[i][j] = false;
            }else{
                ++white_count;
            }
        }
        getchar();
    }
    // function<int(int, int, int, int)> search = [&](int i, int j, int n, int max_n){
    //     if (i == H - 1 && j == W - 1) return n;
    //     int min_n = max_n;
    //     vector<pair<int, int>> nexts = {{i + 1, j}, {i, j + 1}, {i - 1, j}, {i, j - 1}};
    //     for (auto& next : nexts){
    //         auto& ni = next.first;
    //         auto& nj = next.second;
    //         if (ni < 0 || H <= ni || nj < 0 || W <= nj || board[ni][nj] != 0) continue;
    //         if (n < max_n){
    //             board[ni][nj] = 2;
    //             min_n = min(min_n, search(ni, nj, n + 1, min_n));
    //             board[ni][nj] = 0;
    //         }
    //     }
    //     return min_n;
    // };
    // const int result = search(0, 0, 0, INT_MAX);
    vector<vector<int>> score(H, vector<int>(W, -1));
    score[0][0] = 0;
    function<void(int, int)> search = [&](int i, int j){
        if (i == H - 1 && j == W - 1) return;
        vector<pair<int, int>> nexts = {{i + 1, j}, {i, j + 1}, {i - 1, j}, {i, j - 1}};
        for (auto& next : nexts){
            auto& ni = next.first;
            auto& nj = next.second;
            if (ni < 0 || H <= ni || nj < 0 || W <= nj || !board[ni][nj]) continue;
            const int s = score[i][j];
            if (score[ni][nj] == -1 || s + 1 < score[ni][nj]){
                score[ni][nj] = s + 1;
                search(ni, nj);
            }
        }
        return;
    };
    search(0, 0);
    const int result = score[H - 1][W - 1];
    if (result == -1){
        cout << -1 << endl;
    }else{
        cout << (white_count - result - 1) << endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  deque<char> v;
  rep(i,S.size()){
    v.push_back(S[i]);
  }

  bool isrev = false;
  
  int Q;
  cin >> Q;
  rep(i,Q){
    int t;
    cin >> t;
    if(t == 1){
      isrev = !isrev;
    }else{
      int f;
      char c;
      cin >> f >> c;

      if(f == 1){
        if(!isrev) v.push_front(c);
        else v.push_back(c);
      }else{
        if(!isrev) v.push_back(c);
        else v.push_front(c);        
      }
    }
  }

  if(isrev) reverse(ALLOF(v));
  rep(i,v.size()){
    cout << v[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 896
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int A, B; cin >> A >> B;
  if (A % 2 == 0 || B % 2 == 0) cout << "No" << endl;
  else                          cout << "Yes" << endl;
}


Measured memory_bytes: 3544
def main():
    import sys
    A,B,C,D=map(int,input().split())
    for i in range(100):
        A=A-D
        C=C-B
        if C<=0:
            print("Yes")
            sys.exit()
        elif A<=0:
            print("No")
            sys.exit()
        

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 61700
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> A;
    for (auto it = m.begin(); it != m.end(); ++it) A.push_back(it->second);
    sort(A.begin(), A.end());
    int M = A.size();

    vector<int> S(M + 1, 0);
    for (int i = 0; i < M; ++i) {
        S[i+1] = S[i] + A[i];
    }

    for (int k = 1; k <= N; ++k) {
        int lb = 0;
        int ub = N + 1;

        while (ub - lb > 1) {
            int mid = (ub + lb) / 2;

            auto it = lower_bound(A.begin(), A.end(), mid);
            int i = it - A.begin();
            int sum = (M - i) * mid + S[i];
            if (sum >= k * mid) {
                lb = mid;
            } else {
                ub = mid;
            }
        }

        cout << lb << endl;
    }

    return 0;
}

Measured memory_bytes: 24044
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int N,K;
int main(){
	scanf("%d %d",&N,&K);
	if((N+1)/2>=K){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 128