akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// using namespace std;
typedef long long ll;
const int mod=1e9+9;
const int N=2e5+5;

int n;
ll a[N];
std::map<ll,ll> mp;

int main()
{
    // ios::sync_with_stdio(false);std::cin.tie(0);cout.tie(0);                           
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);while(T--){
    // while(~scanf("%d%d%d",&n,&p,&c)){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;
    }
    printf("%lld\n",ans);
    // }
    return 0;
}

Measured memory_bytes: 28132
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  REV(A);
  ll count=0;
  ll ans=0;
  FOR(i,1,n){
    if(A[i-1]<=A[i]){
      count++;
    }
    else{
      chmax(ans,count);
      count=0;
    }
  }
  chmax(ans,count);
  co(ans)
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    int n;
    cin >> n;
   
    map<string,int> m;
    
    rep(i,0,n){
	string s;
	cin >> s;
	m[s]++;
    }
    
    cout << "AC x " <<  m["AC"] << endl;
    cout << "WA x " <<  m["WA"] << endl;
    cout << "TLE x " <<  m["TLE"] << endl;
    cout << "RE x " <<  m["RE"] << endl;
    
    return  0;
}


Measured memory_bytes: 3600
w,h,n=map(int,input().split())
tatemax=[h]
tatemin=[0]
yokomax=[w]
yokomin=[0]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        yokomin.append(x)      
    elif a==2:
        yokomax.append(x)       
    elif a==3:
        tatemin.append(y)    
    elif a==4:
        tatemax.append(y)
        
tate_max=min(tatemax)
tate_min=max(tatemin)
yoko_max=min(yokomax)
yoko_min=max(yokomin)
if tate_max<=tate_min or yoko_max<=yoko_min:
    print(0)
else:
    print((tate_max-tate_min)*(yoko_max-yoko_min))

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

class UnionFind {
public:
    vector<int> par;
    int N;
    UnionFind(int n) {
        par.resize(n, -1);
        N = n;
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] < -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        N--;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
    int size() {
        return N;
    }
};

#include <array>
template<typename T>
class RollingHash {
    constexpr static int N = 3;
    array<ll, N> MOD;
    array<ll, N> Base;
    vector<ll> hash[N], pw[N];

public:
    RollingHash(T &s) {
        MOD = {{1000000007, 1000000009, 1234567891}};
        Base = {{1007, 1009, 1013}};
        int n = static_cast<int>(s.size());
        REP(i, 0, N) {
            hash[i].resize(n + 1, 0);
            pw[i].resize(n + 1, 1);
            REP(j, 0, n) {
                hash[i][j + 1] = (hash[i][j] * Base[i] + s[j]) % MOD[i];
                pw[i][j + 1] = (pw[i][j] * Base[i]) % MOD[i];
            }
        }
    }
    array<ll, N> getHash(int l, int r) {
        array<ll, N> res;
        REP(i, 0, N) {
            res[i] = (((hash[i][r] - pw[i][r - l] * hash[i][l]) % MOD[i]) + MOD[i]) % MOD[i];
        }
        return res;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    do {
        s += s;
    } while (s.size() < 3 * t.size());

    UnionFind uf(n);
    bool loop = false;
    {
        RollingHash<string> RHs(s), RHt(t);
        auto hst = RHt.getHash(0, t.size());
        REP(i, 0, n) {
            if (RHs.getHash(i, i + t.size()) == hst) {
                loop |= !uf.Union(i, (i + t.size()) % n);
            }
        }
    }

    if (loop) {
        cout << -1 << endl;
    } else {
        int ans = 0;
        REP(i, 0, n) {
            ans = max(ans, uf.size(i) - 1);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 128092
#include <iostream>
using namespace std;
int main() 
{
	int S, h, m, s, amari;
	cin >> S;
	h = S / 3600;
	amari = S % 3600;
	m = amari / 60;
	s = amari % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k;
    cin >> n;
    if (n == 1)
    {
        cout << "Yes\n2\n1 1\n1 1\n";
        return;
    }
    for (k = 1; k <= n; k++)
    {
        if (k * (k - 1) == 2 * n)
        {
            break;
        }
    }
    if (k > n)
    {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl
         << k << endl;
    int cur = 1;
    yukari<int> as(k);
    for (int i = 0; i < k - 1; i++)
    {
        for (int j = i + 1; j < k; j++)
        {
            as[i].push_back(cur);
            as[j].push_back(cur);
            cur++;
        }
    }
    for (auto &v : as)
    {
        cout << k - 1 << ' ';
        for (int x : v)
        {
            cout << x << ' ';
        }
        cout << endl;
    }
}

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


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

using namespace std;
using ll = long long;
constexpr int MOD = 2019;
constexpr int NMAX = 200010;

char num[NMAX];

int main() {
	scanf("%s", num);
	int n = strlen(num);
	map<int, ll> places;
	places[0]++;
	ll ans = 0;
	ll cpow10 = 1, cNumVal = 0;
	for (int i = n - 1; i >= 0; --i) {
		cNumVal = (cNumVal + cpow10 * (num[i] - '0')) % MOD;
		ans += places[cNumVal];
		cpow10 = (cpow10 * 10) % MOD;
		places[cNumVal]++;
	}
	printf("%lld\n", ans);
	return 0;
}


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

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, K, Q, A;
int B[100010];

int main() {
    cin >> N >> K >> Q;
    for (int i = 0; i < N; ++i) B[i] = 0;
    for (int i = 0; i < Q; ++i) {
        cin >> A;
        B[A-1]++;
    }
    for (int i = 0; i < N; ++i) {
        if (B[i] > Q - K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

using namespace std;

const long long inf=1LL<<60;
long long memo[256],memo2[256];

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int c[16];
		static int x[20001];
		for(int i=0;i<m;i++)	scanf("%d",c+i);
		for(int i=0;i<n;i++)	scanf("%d",x+i);

		for(int j=0;j<256;j++)	memo[j]=memo2[j]=inf;

		memo[128]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<256;j++){
				if(memo[j]==inf)	continue;
				for(int k=0;k<m;k++){
					int next=min(255,max(0,j+c[k]));
					memo2[next]=min(memo2[next],memo[j]+(next-x[i])*(next-x[i]));
				}
			}
			for(int j=0;j<256;j++)	memo[j]=memo2[j],memo2[j]=inf;
		}

		long long emin=inf;
		for(int j=0;j<256;j++)	emin=min(emin,memo[j]);
		printf("%lld\n",emin);
	}

	return 0;
}

Measured memory_bytes: 840
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define bigint int64_t
#define vll vector<ll>
#define pll ar<ll,2>
#define vpll vector<pll>
#define pb push_back
#define MOD 1000000007
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define en cout<<"\n"
#define LCM(a,b) (a*(b/__gcd(a,b)))
#define all(v) v.begin(),v.end()
#define maxqueue    priority_queue<int>
#define minqueue    priority_queue<int,vector<int>,greater<int> >
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
#define INF (ll)(1e18)
#define ini(a,b) memset(a,b,sizeof(a))
#define vvll vector<vector<ll>>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define prec(n) fixed<<setprecision(n)
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define forn(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define deb1(x)                cerr<<#x<<": "<<x<<endl
#define deb2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define GET5(a, b, c, d, e, ...) e
#define D_EBC(...) GET5(__VA_ARGS__, deb4, deb3, deb2, deb1)
#define deb(...) D_EBC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x: a)

using namespace std;

template <typename T>
void read(T &x) {
    cin >> x;
}
template <typename T , typename T0>
void read(T &x, T0 &y) {
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x, T0 &y, T1 &z) {
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
    cin >> x >> y >> z >> w;
}

template <typename T>
void read(vector< T > &oneD, ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }

}

template <typename T>
void read(T oneD[] , ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }
}

const ll N=1e5;
ll dp[N+1];
void solve(){
    ll n,w;
    read(n,w);
    vpll arr;
    forn(i,n)
    {
        ll a,b;
        read(a,b);
        arr.pb({a,b});
    }
    forn(i,n){
        forn(j,w,-1,-1){
            if(j-arr[i][0]>=0)
            dp[j]=max(dp[j],dp[j-arr[i][0]]+arr[i][1]);
        }
    }
    cout<<dp[w];
}

int main() {
    fast;
    int t=1;
    // read(t);
    forn(t) {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}


Measured memory_bytes: 4332
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _002_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            var xys = new int[nm[1]][];
            for(int i = 0; i < nm[1]; i++)
            {
                xys[i] = ReadInts();
            }
            var cnts = new int[nm[0]];
            var inRed = new bool[nm[0]];
            inRed[0] = true;

            for (int i = 0; i < nm[1]; i++)
            {
                int x = xys[i][0] - 1;
                int y = xys[i][1] - 1;

                if (inRed[x])
                {
                    if (cnts[x] == 0)
                    {
                        inRed[x] = false;
                    }
                    inRed[y] = true;
                }
                cnts[x]--;
                cnts[y]++;
            }

            int cnt = 0;
            for(int i = 0; i < nm[0]; i++)
            {
                if (inRed[i]) cnt++;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        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: 22096
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    Rep(i,n) cin >> a[i] >> b[i];
    ll ans = 0;
    RRep(i,n){
        ll x = (a[i]+ans+b[i]-1)/b[i];
        ans += b[i]*x - a[i] -ans;
    }
    cout << ans << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int a,b,c; cin >> a >> b >> c;
  ll res = min(a+b,min(b+c,c+a));
  out(res);
}

Measured memory_bytes: 256
//AtCoder ABC086 B - 1 21
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string a,b;
    cin>>a>>b;
    string c=a+b;
    const ll v=stoi(c);
    bool ans=false;
    for(ll i=1;i*i<=v;++i){
        if(i*i==v){
            ans=true;
            break;
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_a
//A - CODEFESTIVAL 2016
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    string s; cin>>s;
    string ans;
    REP(i,s.size()){
        ans.push_back(s.at(i));
        if(i==3)ans.push_back(' ');
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(void){
  ll n;

  cin >> n;

  if (n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }

  ll five = 5;
  ll sum = 0;

  while (five < n){
    sum += n / five / 2;

    five *= 5;
  }


  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = [[] for i in range(m)]
for i in range(m):
    s[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
count = 0
for i in range(2**n):
    light = bin(i)[2:].zfill(n)
    flag = True
    for j in range(m):
        work = 0
        for el in s[j]:
            if light[el-1] == '1':
                work += 1
        if work%2 != p[j]:
            flag = False
            break
    if flag:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

  int i;
  if(N > 81) //9*9が最大
    cout << "No" << endl;
  else{
    for(i=9; i>0; i--)
      if(N%i == 0){ //Nがiを因数として表される
	if(N/i <= 9){ //商が10を超えなければよい 
	  cout << "Yes" << endl;
	  break;
	}
      }
      else
	continue;
    //上の判定に引っかからなければiは0まで下がる
    if(i == 0)
      cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import collections
import itertools
t=[]
while True:
    try:
        k=int(input())
        t.append(k)
    except EOFError:
        break
counter=collections.Counter(t)
mode_v=counter.most_common()[0][-1]
it=itertools.takewhile(lambda kv:kv[-1]==mode_v,counter.most_common())
m=(k for k,v in it)
[print(i) for i in m]


Measured memory_bytes: 6020
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		List<Long> cityEnemy = new ArrayList<>();
		List<Long> hero = new ArrayList<>();

		for(int i = 0;i < n + 1;i++) {
			cityEnemy.add(sc.nextLong());
		}

		for(int i = 0;i < n;i++) {
			hero.add(sc.nextLong());
		}

		long killEnemyCnt = 0;
		for(int i = 0; i < n;i++) {
			if(cityEnemy.get(i) < hero.get(i)) {
				//i番目の街の処理
				killEnemyCnt += cityEnemy.get(i);
				hero.set(i, hero.get(i) - cityEnemy.get(i));

				if(cityEnemy.get(i + 1) > hero.get(i) ) {
					killEnemyCnt += hero.get(i);
					cityEnemy.set(i + 1, cityEnemy.get(i + 1) - hero.get(i));

				}else {
					killEnemyCnt += cityEnemy.get(i + 1);
					cityEnemy.set(i + 1, 0L);
				}

			}else {
				killEnemyCnt += hero.get(i);
			}
		}

		System.out.println(killEnemyCnt);
	}
}


Measured memory_bytes: 93792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, k;
  cin>>n>>k;
  ll ans = 0;
  rep(i,n){
    ll m;
    cin >> m;
    ans += min(abs(m), abs(m - k));
  }
  print(ans * 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	string s;
  	cin>>s;
  	string r="keyence";
  	int i=0,j=6;
  	int l=s.size();
  	if(l<7)cout<<"NO\n";
  	else
  	{
  		int k=0;
  		while(k<7 && r[k]==s[k])k++;
  		int m=l-1;
  		while(j>=0 && s[m]==r[j])m--,j--;
  		if(j<k)cout<<"YES\n";
  		else cout<<"NO\n";
	  }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


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

    ll dp[101][10010];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= s; j++){
            dp[i][j] = 0;
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++){
            if(j+w[i] <= s){
                dp[i][j+w[i]] = max(dp[i-1][j+w[i]], dp[i-1][j]+v[i]);
            }
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }

    cout << dp[n][s] << endl;
    
    return 0;
}


Measured memory_bytes: 10980
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
typedef long long ll;
using namespace std;

int main(){
	ll n,ans=0,a,com=1;cin>>n;
	f(i,0,n){
		cin>>a;
		if(a==com) {ans++;com++;}
	}
	if(ans==0) {cout<<"-1\n";return 0;}
	ans=n-ans;
	cout<<ans<<"\n";
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W== 0) break;
			
			for(int i =1; i <= H; i++) {
				for(int j = 1; j <= W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			
			System.out.println();
		}
		

	}

}



Measured memory_bytes: 32572
from itertools import permutations
def main():
    N, M = map(int, input().split())
    l = [[0] * N for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        l[a][b] = 1
        l[b][a] = 1
    r = 0
    for x in permutations(range(1, N)):
        if l[0][x[0]] == 0:
            continue
        for i in range(N-2):
            if l[x[i]][x[i+1]] == 0:
                break
        else:
            r += 1
    return r
print(main())
    


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

a = []
for i in range(n):
    b = int(input())
    a.append(b)

a.sort()
sum = sum(a)
if sum % 10 != 0:
    print(sum)
    exit()
else:
    for i in range(n):
        if a[i] % 10 != 0:
            sum -= a[i]
            print(sum)
            exit()

print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    
    int len = s.size();
    int tmp1, tmp2;
    int a[26];
    bool b[26];
    memset(b, true, 26);
    bool judge = true;
    rep(i, len){
        tmp1 = s[i] - 'a';
        tmp2 = t[i] - 'a';
        if(b[tmp1]){
            a[tmp1] = tmp2;
            b[tmp1] = false;
        }else{
            if(a[tmp1] != tmp2){
                judge = false;
                break;
            }
        }
    }
    
    int c[26];
    bool d[26];
    memset(d, true, 26);
    rep(i, len){
        tmp1 = s[i] - 'a';
        tmp2 = t[i] - 'a';
        if(d[tmp2]){
            c[tmp2] = tmp1;
            d[tmp2] = false;
        }else{
            if(c[tmp2] != tmp1){
                judge = false;
                break;
            }
        }
    }
    
    if(judge)   cout << "Yes" << endl;
    else    cout << "No" << endl;
}

Measured memory_bytes: 916
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            string buf = Console.ReadLine();
            char[] sentence = buf.ToCharArray();
            int n = sentence.Length;

            if (n % 2 == 0) {
                Console.WriteLine("No");
                return;
            }

/*            if ((n - 1) / 2 % 2 == 0) {
                Console.WriteLine("No");
                return;
            }*/

            char[] test1 = new char[n / 2];
            char[] test2 = new char[n / 2];

            Array.Copy(sentence, 0, test1, 0, n / 2);
            Array.Copy(sentence, n / 2 + 1, test2, 0, n / 2);

            Array.Reverse(test2);

            //Console.WriteLine(new string(test1));
            //Console.WriteLine(new string(test2));


            string test1Str = new string(test1);
            string test2Str = new string(test2);

            //1. Sは回文かどうか
            if (test1Str != test2Str) {
                Console.WriteLine("No");
                return;
            }

            char[] test3 = test1;
            Array.Reverse(test3);
            string test3Str = new string(test3);

            //2. 前半分が回分かどうか
            if (test1Str != test3Str) {
                Console.WriteLine("No");
                return;
            }

            char[] test4 = test2;
            char[] test5 = test4;
            Array.Reverse(test5);

            string test4Str = new string(test4);
            string test5Str = new string(test5);

            //Console.WriteLine(new string(test4));

            if (test4Str != test5Str) {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
        }

    }

}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a+b)<(c+d)){
    cout<<"Right"<<endl;
  }else if((a+b)==(c+d)){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Left"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<string>
#include<utility>
#define INF 2<<29
using namespace std;
	int n;
	double price [3] = { 850,550,380 };
	double discount[3] = { 0.88,0.85,0.8 };
	double  group[3] = { 3.0,4.0,5.0 };
	double gram[3] = { 500.0,300.0,200.0 };
	vector<int> dp(5001, INF);
	int memo;
	int ans = 0;
	int amount = 0;
int main() {
		for (int i = 0; i <= 10; ++i) {
			for (int j = 0; j <= 17; ++j) {
				for (int k = 0; k <= 25; ++k) {
					amount = i*gram[0] + j*gram[1] + k*gram[2];
					if (amount > 5000)break;
					int warihukuro[3] = { (int)(i / 3) * 3,(int)(j / 4) * 4,(int)(k / 5) * 5 };
					memo = warihukuro[0] * price[0] * discount[0] + (i - warihukuro[0])*price[0] +
						warihukuro[1] * price[1] * discount[1] + (j - warihukuro[1])*price[1] +
						warihukuro[2] * price[2] * discount[2] + (k - warihukuro[2])*price[2];
					//cout << amount << " " << memo << endl;
					dp[amount] = min(memo, dp[amount]);
				}
			}
		}
		while(cin>>n&&n)
		cout << dp[n] << endl;
	
	return 0;
}


Measured memory_bytes: 3148
/**
 *	@file: B.cpp
 *	@author: Huy Le
 *	@created: 2020-09-13 19:24
**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << argc;
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int ts;
ll a,b,c,d;

void solve() {
    cin >> a >> b >> c >> d;
    ll res1 = a*c;
    ll res2 = a*d;
    ll res3 = b*c;
    ll res4 = b*d;
    cout << max(max(res1, res2), max(res3,res4)) << newl;
    //if(b>0 && d>0)
        //cout << (b*d) << newl;
    //else if((b==0 && d>0) || (d==0 && b>0))
        //cout << 0 << newl;
    //else if(a>0) {
        //cout << (a*d) << newl;
    //} else if(c>0)
        //cout << (c*b) << newl;
    //else
        //cout << (a*c) << newl;
}

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

		solve();
}


Measured memory_bytes: 3648
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
S = list(input())[: -1]
N = len(S)
cs = [0] * (N + 1)
a = ord("a")
table = [1 << x for x in range(27)]
for i in range(N):
  cs[i + 1] = cs[i] ^ table[(ord(S[i]) - a)]
d = dd(lambda: N + 1)

dp = [N] * (N + 1)
dp[0] = 0
d[0] = 0
for i in range(N):
  for j in range(26):
    x = d[cs[i + 1] ^ table[j]]
    #print(cs[i + 1], table[j], d[x])
    if x >= N + 1: continue
    dp[i + 1] = min(dp[i + 1], x + 1)
  x = d[cs[i + 1]]
  if x <= N: dp[i + 1] = min(dp[i + 1], x + 1)
  d[cs[i + 1]] = min(x, dp[i + 1])
print(dp[-1])

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

int main()
{
  int n;
  cin >> n;
  vector<int> h(n+1);
  for (int i = 0; i < n; ++i)
    cin >> h[i];
  h[n] = 0;

  int count = 0;
  for (int i = 0; i < n; ++i)
    if (h[i+1] < h[i]) count += h[i] - h[i+1];
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
int n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=0;
	for(int l=1;l<=n;l++){
		int r=l;
		for(;r<=n;r++) if(a[r]!=r) break;
		if(l!=r) ans+=(int)ceil((r-l)/2.0);
		l=r;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  string s;
  int n;
  cin >> n;
  cin >> s;
  
  int mn = 1000000;
  int Enum[s.size()] = {};
  int wnum[s.size()] = {};
  REP(i,s.size()){
    if(s[i] == 'E'){
      Enum[i]++;
    }
    else{
      wnum[i]++;
    }
    if(i > 0){
      wnum[i] += wnum[i-1];
      Enum[i] += Enum[i-1];
    }
  }
  REP(i,s.size()){
    if(i == 0){
      mn = min(mn,Enum[s.size()-1]-Enum[0]);
    }
    else if(i == s.size()-1){
      mn = min(mn,wnum[i-1]);
    }
    else{
      mn = min(mn,wnum[i-1]+Enum[s.size()-1]-Enum[i-1]);
    }
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 3972
n, a, b = map(int, input().split(" "))

wholeSum = 0

def digitSum(n):
  basis = 10
  transDigit = list()
  while n > 0:
    transDigit.append(n % basis)
    n = int(n / basis)
  result = sum(transDigit)
  return result

for pivot in range(n+1):
  target = digitSum(pivot)
  if target <= b\
  and a <= target:
    wholeSum += pivot

print(wholeSum)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

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

int main() {
    ll N, L;
    cin >> N >> L;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int j = -1;
    for (int i = 0; i < N - 1; i++) {
        if (A[i + 1] + A[i] >= L) {
            j = i;
        }
    }
    if (j == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int k = N - 2; k >= j + 1; k--) {
        cout << k + 1 << endl;
    }
    for (int k = 0; k < j; k++) {
        cout << k + 1 << endl;
    }
    cout << j + 1 << endl;
    return 0;
}


Measured memory_bytes: 1664
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, int> to[200000];
int he[100001], jisuu[100001], A[100001], saidai[100001];
ll goukei[100001];

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


	int N = getint();
	rep1(i, N) A[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		jisuu[a]++;
		jisuu[b]++;
		to[k] = mp(b, he[a]);
		he[a] = k++;
		to[k] = mp(a, he[b]);
		he[b] = k++;
	}

	if (N == 2) {
		if (A[1] == A[2]) printf("YES");
		else printf("NO");
		return 0;
	}

	queue<int> q;
	rep1(i, N) if (jisuu[i] == 1) jisuu[i] = 0;
	rep1(i, N) if (jisuu[i] == 0) {
		int p = to[he[i]].first;
		goukei[p] += A[i];
		chmax(saidai[p], A[i]);
		jisuu[p]--;
		if (jisuu[p] == 1) q.push(p);
	}

	bool OK = 1;

	while (q.size()) {
		int i = q.front();
		q.pop();

		if (jisuu[i]) {
			for (int j = he[i]; j; j = to[j].second) {
				int p = to[j].first;
				if (jisuu[p]) {
					jisuu[p]--;
					if (jisuu[p] == 1) q.push(p);

					ll tmp = A[i] * 2 - goukei[i];
					chmax(saidai[i], int(tmp));
					goukei[p] += tmp;
					chmax(saidai[p], int(tmp));
					if (tmp < 0 || saidai[i] > A[i]) OK = 0;
				}
			}
			jisuu[i] = 0;
		}
		else if (saidai[i] > A[i] || goukei[i] != A[i] * 2) OK = 0;
	}

	if (OK) printf("YES");
	else printf("NO");

	Would you please return 0;
}

Measured memory_bytes: 4352
import Data.List
main = do
  nk <- map (read :: String -> Int) . words <$> getLine
  card <- reverse . sort . map (read :: String -> Int) . words <$> getLine
  putStrLn . show . length $ solve 0 0 (last nk) card

solve :: Int -> Int -> Int -> [Int] -> [Int]
solve n x k []      = []
solve n x k s@(y:ys)
  | n >= k        = solve (n-x) 0 k s
  | n + sum s < k = s
  | otherwise     = solve (n+y) y k ys


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll gcd(ll x,ll y){
    if(x<y) return gcd(y,x);
    if(y==0) return x;
    return gcd(y,x%y);
}
ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

int main(){fastio
    ll n;cin>>n;
    map<l_l,l_l> mp;
    ll a[n],b[n];
    ll hogehoge=0;
    rep(i,0,n-1){
        cin>>a[i]>>b[i];
        if(a[i]!=0 && b[i]!=0){
            ll g=gcd(abs(a[i]),abs(b[i]));
            a[i]/=g;
            b[i]/=g;
        }
        ll flag=0;
        if(a[i]>=0 && b[i]>0){
            flag=0;
        }else if(a[i]>0 && b[i]<=0){
            ll aa=a[i];
            ll bb=b[i];
            a[i]=-1*bb;
            b[i]=aa;
            flag=1;
        }else if(a[i]<=0 && b[i]<0){
            a[i]=-a[i];
            b[i]=-b[i];
            flag=0;
        }else{
            ll aa=a[i];
            ll bb=b[i];
            a[i]=bb;
            b[i]=-1*aa;
            flag=1;
        }
        if(a[i]==0){
            if(b[i]==0){
                mp[l_l(a[i],b[i])].first=0;
                mp[l_l(a[i],b[i])].second=0;
                hogehoge++;
                continue;
            }else{
                b[i]=1;
            }
        }
        if(mp.find(l_l(a[i],b[i]))==mp.end()){
            if(flag==0){
                mp[l_l(a[i],b[i])].first=1;
                mp[l_l(a[i],b[i])].second=0;
            }else{
                mp[l_l(a[i],b[i])].first=0;
                mp[l_l(a[i],b[i])].second=1;
            }
        }else{
            if(flag==0){
                mp[l_l(a[i],b[i])].first++;
            }else{
                mp[l_l(a[i],b[i])].second++;
            }
        }
        
    }
    ll ans=1;
    //cout<<endl;
    for(auto i=mp.begin();i!=mp.end();++i){
        l_l value;
        value.first=i->second.first;
        value.second=i->second.second;
        //cout<<x<<' '<<y<<endl;
        ans=mod(ans*(hpow(2,value.first)+hpow(2,value.second)-1));
        //cout<<value.val[0]<<' '<<value.val[1]<<endl;
        //cout<<max(value.val[0],value.val[1])+1<<endl;
    }
    cout<<mod(ans-1+hogehoge)<<endl;
    
    return 0;
}




Measured memory_bytes: 22252
#include<stdio.h>
int main(void){
    int N,A,B,x,y;
    scanf("%d %d %d",&N,&A,&B);
    if(A>B){
        x=B;
    }else{
        x=A;
    }
    if(A+B-N<0){
        y=0;
    }else{
        y=A+B-N;
    }
    printf("%d %d\n",x,y);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
// auto itr=lower_bound(a.begin(),a.end(),

int main(){
    ll n,d,a;
    cin >> n >> d >> a;
    vector<Pll> m(n);
    rep(i,n){
        cin >> m[i].fi >> m[i].se;
        if(m[i].se%a==0) m[i].se/=a;
        else{
            m[i].se/=a;
            m[i].se++;
        }
    }
    //座標と回数をpairで持つ
    sort(ALL(m));
    ll dam[n];
    rep(i,n){
        if(i==0){
            dam[0]=m[0].se;
            continue;
        }
        auto itr=lower_bound(ALL(m),P(m[i].fi-2*d,0));
        ll d;
        if(itr==m.begin()) d=dam[i-1];
        else{
            itr--; d=dam[i-1]-dam[itr-m.begin()];
        }
        dam[i]=dam[i-1]+max(0LL,m[i].se-d);
    }
    cout << dam[n-1] << endl;
}



Measured memory_bytes: 4992
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd(a, b)

if __name__ == "__main__":
	A, B = map(int, input().split())
	if A < B:
		A, B = B, A
	print(lcm(A, B))

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


int main() {
    unsigned long x;
    cin >> x;
    
    unsigned long sum = 100;
    unsigned long i = 0;
    
    while (true) {
        sum += long(sum*0.01);
        
        i++;
        if (sum >= x) {
            cout << i << endl;
            break;   
        }
    }
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
P = 10**9+7

dp = [-1 for _ in range(n+1)]
dp[0] = 1
dp[1] = 1
for _ in range(m):
  dp[int(input())] = 0

for i in range(2, n+1):
  if not dp[i] == 0:
    dp[i] = (dp[i-2] + dp[i-1]) % P

print(dp[-1])


Measured memory_bytes: 45040