akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  tree_order_statistics_node_update>  ordered_set; 
typedef long long ll;
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ff(i, c, n) for (ll i = c; i < n; i++)
#define fr(i, c, n) for (ll i = c; i >= n; --i)

// DEBUGGING TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const ll mod=1000000007;
const ll mod1=998244353;

ll modpow(ll a, ll b, ll c)
{ //a^b%c in O(logb)
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % c;
		}
		a = (a * a) % c;
		b >>= 1;
	}
	return res;
}
ll modinv(ll m, ll n)
{ //modular inverse of n w.r.t m provided 1<=n<=(m-1) in O(logn) and m is prime
	ll inv[n + 1];
	inv[1] = 1;
	for (int i = 2; i < n + 1; ++i)
		inv[i] = (m - (m / i) * inv[m % i] % m) % m;
	return inv[n];
}

void solve(){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout<< (h2 - h1) * 60 + m2 - m1 - k;

}

//a+b=a^b+2*(a&b)
int main()
{
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t = 1;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3556
// Try M-SOLUTIONS プロコンオープン
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let k = s.len();
    
    let cnt = 15 - k + s
        .iter()
        .filter(|c| **c == b'o')
        .count();
	
    if cnt >= 8 {
        println!("YES");
	} else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
x, y = list(map(int, input().split()))

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
	print('Yes')	
else:
	print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a;cin>>a;int sums=0,sumt=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='S') sums++;
		if(sums&&a[i]=='T') sums--,sumt+=2;
	}
	cout<<a.length()-sumt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lim 1000000000000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(),v.end()
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
const int N = (int)1e5+5;

void solve() {
  int n;
  cin>>n;
  vector<int> a(n);
  ll sum_of_stool_heights = 0;
  for(int i=0;i<n;i++) {
    cin>>a[i];
    if(i>0 && a[i]<a[i-1]) {
      sum_of_stool_heights += a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  cout<<sum_of_stool_heights;
}

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

  int T=1;
  //cin>>T;
  REP(TC,1,T) {
      //cout<<"Case #"<<TC<<": ";
      solve();
      cout<<"\n";
  }
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{

    int N, W;
    cin >> N >> W;
    vector<long> w(N);
    vector<long> v(N);
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    vector<vector<long>> dp(N + 1, vector<long>(W + 1));
    dp[0] = vector<long>(W);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < W + 1; j++)
        {
            if (j < w[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 80256
N,M,X,Y = [int(x) for x in input().split()]

xl = [int(x) for x in input().split()]
yl = [int(x) for x in input().split()]

xl.sort()
yl.sort()

xmax = xl[-1]
ymin = yl[0]

war = 'War'
nowar = 'No War'

isOk = False

if xmax < ymin:
    isOk = True
else:
    print(war)
    exit()


if X < ymin and Y > xmax:
    isOk = True
else:
    print(war)
    exit()

print(nowar)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 2e5 + 9;

namespace SegmentTree {
    int n;

    int t[4 * N];
    int cnt[4 * N];
    int mod[4 * N];

    void apply(int v, int x) {
        t[v] += x;
        mod[v] += x;
    }

    void push(int v) {
        if (mod[v] != 0) {
            apply(2 * v + 1, mod[v]);
            apply(2 * v + 2, mod[v]);
            mod[v] = 0;
        }
    }

    void pull(int v) {
        if (t[2 * v + 1] < t[2 * v + 2]) {
            cnt[v] = cnt[2 * v + 1];
        } else if (t[2 * v + 1] > t[2 * v + 2]) {
            cnt[v] = cnt[2 * v + 2];
        } else {
            cnt[v] = cnt[2 * v + 1] + cnt[2 * v + 2];
        }
        t[v] = min(t[2 * v + 1], t[2 * v + 2]);
    }

    void query(int v, int l, int r, int ql, int qr, int x) {
        if (r <= ql || qr <= l) {
            return;
        } else if (ql <= l && r <= qr) {
            apply(v, x);
        } else {
            push(v);
            int m = (r + l) >> 1;
            query(2 * v + 1, l, m, ql, qr, x);
            query(2 * v + 2, m, r, ql, qr, x);
            pull(v);
        }
    }

    int get_zeros() {
        if (t[0] > 0) {
            return 0;
        } else {
            return cnt[0];
        }
    }

    void add(int l, int r, int x) {
        query(0, 0, n, l, r, x);
    }

    void build(int v, int l, int r) {
        if (l + 1 == r) {
            t[v] = 0;
            cnt[v] = 1;
        } else {
            int m = (r + l) >> 1;
            build(2 * v + 1, l, m);
            build(2 * v + 2, m, r);
            pull(v);
        }
    } 

    void init(int n_) {
        n = n_;
        build(0, 0, n);
    }
}

int c[N];

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

    auto apply = [&](int i, int x) {
        int l = i - c[i] + 1;
        l = max(l, 1);
        SegmentTree::add(l, i + 1, x);
    };

    int n, q;
    cin >> n >> q;
    SegmentTree::init(n + 1);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        c[x]++;
        a[i] = x;
    }
    for (int i = 1; i <= n; i++) {
        apply(i, 1);
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        x--;
        int ws = a[x];
        apply(ws, -1);
        apply(y, -1);
        c[a[x]]--;
        c[y]++;
        a[x] = y;
        apply(ws, 1);
        apply(y, 1);
        cout << SegmentTree::get_zeros() - 1 << '\n';
    }
}       


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    vv<tuple<int, int, int>> graph(N);
    rep(i, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        graph[u].emplace_back(v, a, b);
        graph[v].emplace_back(u, a, b);
    }
    vector<int> C(N), D(N);
    rep(i, N) cin >> C[i] >> D[i];

    S = min(S, 2500);
    vv<ll> dist = vvec(N, 2501, LINF);
    dist[0][S] = 0;
    using T = tuple <ll, int, int>;
    priority_queue<T, vector<T>, greater<T>> pq;
    pq.emplace(0, S, 0);

    while (!pq.empty()) {
        auto [d, s, v] = pq.top();
        pq.pop();
        if (d > dist[v][s]) continue;

        for (; s < 2500; s += C[v], d += D[v]) {
            for (const auto& e : graph[v]) {
                auto [u, a, b] = e;
                if (s < a) continue;
                ll dnext = d + b;
                if (dnext < dist[u][s - a]) {
                    dist[u][s - a] = dnext;
                    pq.emplace(dnext, s - a, u);
                }
            }
        }
        s = min(s, 2500);
        for (const auto& e : graph[v]) {
            auto [u, a, b] = e;
            if (s < a) continue;
            ll dnext = d + b;
            if (dnext < dist[u][s - a]) {
                dist[u][s - a] = dnext;
                pq.emplace(dnext, s - a, u);
            }
        }
    }

    rep(v, 1, N) {
        write(*min_element(all(dist[v])));
    }
}

Measured memory_bytes: 134428
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int A, B;
 
  cin >> A >> B;

  if((A*B)%2 == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

}


Measured memory_bytes: 256
L,R = map(int,input().split(' '))
MIN = 2019
if R - L >= 2019:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      A = i * j
      MIN = min(A%2019,MIN)
  print(MIN)
      


Measured memory_bytes: 2940
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from decimal import getcontext,Decimal
getcontext().prec = 28

A,B = list(map(str, input().split()))
A = int(A)
B = Decimal(B)

print(int(A*B))

Measured memory_bytes: 71308
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;
struct point{
	double x, y;
};
struct circle{
	point p;
	double r;
};

circle circumscribed_circle(point p, point q, point r){
	double a[2],b[2],c[2];
	circle res;
     
    a[0]=2*(q.x-p.x);
    b[0]=2*(q.y-p.y);
    c[0]=p.x*p.x-q.x*q.x+p.y*p.y-q.y*q.y;
     
    a[1]=2*(r.x-p.x);
    b[1]=2*(r.y-p.y);
    c[1]=p.x*p.x-r.x*r.x+p.y*p.y-r.y*r.y;
     
    res.p.x=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    res.p.y=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
  
    res.r=sqrt(pow(fabs(p.x-res.p.x),2)+pow(fabs(p.y-res.p.y),2));
     
    return res;
}

int main(){
	int n;
	point in[3];
	circle ans;
	cin>>n;
	for(;n--;){
		for(int i=0;i<3;i++)
			cin >> in[i].x >> in[i].y;
		ans = circumscribed_circle(in[0], in[1], in[2]);
		printf("%.3f %.3f %.3f\n",ans.p.x,ans.p.y,ans.r);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    char S[3];
    FOR(i,0,3)
        cin >> S[i];
    if (S[0] != S[1] && S[0] != S[2] && S[1] != S[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,C = inputMap()
	K = inputInt()

	if A < B and B < C:
		print("Yes")
		sys.exit()

	for i in range(K):
		if A >= B:
			B *= 2
			continue

		if B >= C:
			C *= 2
			continue

	if A < B and B < C:
		print("Yes")
	else:
		print("No")

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76840
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(15);
    cout << fixed;
    int A,B;
    cin >> A>>B;
    cout<<A*B<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  int N,A;
  cin >> N >> A;
  cout << N*N-A << endl;


    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int N,Q;
string s;
vector<pair<char,char> > v;

int fall(int x){
  if(x<0) return 1;
  else if(x>=N) return 2;
  int i;
  REP(i,v.size()){
    if(v[i].first == s[x]){
      if(v[i].second == 'L') x--;
      else x++;
    }
    if(x<0) return 1;
    else if(x>=N) return 2;
  }
  return 0;
}

//mode 0 落ちない最小値，mode 1 落ちる最小値
int binary_search(int start,int end, int mode){
  while(true){
    int mid = (start+end)/2;
    int f = fall(mid);
    if(end-start<=1) break;
    if(mode){
      if(!f) start=mid;
      else end=mid;
    }else{
      if(!f) end=mid;
      else start=mid;
    }
  }
  return end;
}

int main(void){
  int i,j;
  cin >> N >> Q;
  cin >> s;
  REP(i,Q){
    char x,y;
    cin >> x >> y;
    v.push_back(pair<char,char>(x,y));
  }
  int start=-1,end=N,mid,f,S,E;

  //落ちない最小値を探す(S)
  //落ちないものがない場合は右側に落ちる最小値
  while(true){
    mid = (start + end)/2;
    f = fall(mid);
    if(!f) end = mid;
    else if(f==1) start = mid;
    else end = mid;
    if(end-start <= 1) break;
  }
  S = end;

  start=-1,end=N;
  //右側に落ちる最小値を探す(E)
  while(true){
    mid = (start+end)/2;
    f = fall(mid);
    if(!f)start = mid;
    else if(f==1) start = mid;
    else end = mid;
    if(end-start <= 1) break;
  }
  E = end;
  cout << E-S << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#define Inf 100000000000ll
#define MAXN 100000
#define MAXX 5
#define ll long long
using namespace std;

int A[MAXN+2];
ll dp[MAXN+2][MAXX+2];
int N;

ll Solve(int pos, int left) {
    
    
    if (pos == N) {
        return 0;
    }
    
    ll answer = 0;
    for(int self=0;self<=left/2;self++) {
        // left-2*self
        for(int np=0;np<=min(left-2*self, A[pos+1]);np++) {
            answer = max(answer, self + np + Solve(pos+1, A[pos+1]-np));
        }
    }
    return answer;
    
    
}

int main() {
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>A[i];
    
    ll answer = 0;
    for(int i=0;i<N;i++) {
        if (A[i] >= MAXX) {
            answer += (A[i]-MAXX)/2;
            A[i] -= 2*((A[i]-MAXX)/2);
        }
        
        while(A[i] >= MAXX) {
            A[i]-=2;
            answer++;
        }
    }
    
    for(int pos=N;pos>=0;pos--) {
        for(int left=0;left<=MAXX;left++) {
            if (pos == N) {
                dp[pos][left]=0;
                continue;
            }
            
            ll answer = 0;
            for(int self=0;self<=left/2;self++) {
                // left-2*self
                for(int np=0;np<=min(left-2*self, A[pos+1]);np++) {
                    answer = max(answer, self + np + dp[pos+1][A[pos+1]-np]);
                }
            }
            
            dp[pos][left]=answer;
        }
    }
    
    
    cout << answer + dp[0][A[0]] << endl;
    
 

    
}

Measured memory_bytes: 6144
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()

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

using namespace std;
int main(){
    int N;cin >> N;
    std::vector<int> A(N);
    for(int i=0;i<N;i++)cin >> A[i];
    bool a;a=false;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                a = true;
            }
        }
    }
    if(a){
        cout << "DENIED" <<endl;
    }else{
        cout << "APPROVED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include <string.h>
using namespace std;
int main(void){
    int X,A;
    std::cin >> X>>A;
    if(X<A){
        std::cout << 0 << std::endl;
    }
    else{
        std::cout << 10 << std::endl;
    }
}

Measured memory_bytes: 256
from collections import deque


def main():
    doubly_liked_list = deque()
    n = int(input())
    for i in range(n):
        command = input()
        if command == 'deleteFirst':
            doubly_liked_list.popleft()
        elif command == 'deleteLast':
            doubly_liked_list.pop()
        else:
            command = command.split()
            if command[0] == 'insert':
                doubly_liked_list.appendleft(int(command[1]))
            elif command[0] == 'delete':
                try:
                    doubly_liked_list.remove(int(command[1]))
                except:
                    pass
    print(*doubly_liked_list)


if __name__ == "__main__":
    main()



Measured memory_bytes: 45948
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000005;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    // code here
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> ans(N, 0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i >= j) {
                continue;
            }
            int mi = min(j - i, abs(X - i) + abs(Y - j) + 1);
            ans[mi]++;
        }
    }
    for(int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lambda(res,...) (function<res(__VA_ARGS__)>)[&](__VA_ARGS__) -> res
#define method(name,res,...) function<res(__VA_ARGS__)> name = (function<res(__VA_ARGS__)>)[&](__VA_ARGS__) -> res
#define foreach(i,n) for(auto &i:(n))

using namespace std;

vector<int> fact(int x){
	vector<int> res;
	for(int i=0;i<4;++i){
		int num = x % 10;
		res.emplace_back(num);
		x/=10;
	}
	reverse(res.begin(),res.end());
	return res;
}
int main(){
	vector<vector<int>> table(10,vector<int>(10));
	foreach(i,table){
		foreach(j,i){
			cin >> j;
		}
	}

	method(apply,int,vector<int> line){
		int res = 0;
		foreach(i,line){
			res = table[res][i];
		}
		return res;
	};
	method(func,bool,int x){
		vector<int> line = fact(x);
		int collect = apply(line);
		line.emplace_back(collect);
		//change one digits 
		foreach(i,line){
			for(int j=0;j<10;++j){
				if(i==j)continue;
				swap(i,j);
				int current = apply(line);
				if(current==0)return true;
				swap(i,j);
			}
		}

		//swap two digits
		for(int i=0;i+1<line.size();++i){
			if(line[i]==line[i+1])continue;
			swap(line[i],line[i+1]);
			int current = apply(line);
			if(current==0)return true;
			swap(line[i],line[i+1]);
		};
		return false;
	};

	int ans = 0;
	for(int i=0;i<10000;++i){
		ans +=  func(i);
	}

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




Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
using namespace std;

int main()
{
  int n, a = 0, b = 0;
  cin >> n;

  vector<int> v(n, 0);

  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  for (int i = 0; i < n; i++)
  {
    if (i == 0)
    {
      a += v[i];
    }
    else if (i % 2 == 1)
    {
      b += v[i];
    }
    else if (i % 2 == 0)
    {
      a += v[i];
    }
  }

  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,arr[200002];
bool ada[1000001];
int main(){
	cin>>N;
	for(int i=0; i<N; i++){
		cin>>arr[i];
		ada[arr[i]]=true;
	}
	sort(arr,arr+N);
	int total=0;
	for(int i=0; i<N; i++){
		if(ada[arr[i]]){
			int j=2;
			if(arr[i+1]==arr[i]){
				ada[arr[i]]=false;
			}
			while(arr[i]*j<=1000000){
				ada[arr[i]*j]=false;
				j++;
			}
			if(ada[arr[i]]){
				total++;
			}
		}
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int n;
int B[100];

int main(){
  cin >> n;
  rep(i, n){
    cin >> B[i];
  }
  int ans = B[0] + B[n-2];
  for(int i = 1; i < n-1; i++){
    ans = ans + min(B[i-1], B[i]);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// Structured programing
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	s := ""
	for i := 1; i <= n; i++ {
		if i%3 == 0 {
			s += fmt.Sprintf("%v ", i)
		} else {
			cnt := strings.Count(strconv.Itoa(i), "3")
			if 0 < cnt {
				s += fmt.Sprintf("%v ", i)
			}
		}
	}
	fmt.Println(" " + strings.TrimSpace(s))
}



Measured memory_bytes: 7212
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;

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;
}

// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  cin >> t;
  rep(i, 0, s.size())
  {
    if (s[i] != t[i])
    {
      count++;
    }
  }
  if (count == 0)
  {
    cout << "Yes"
         << "\n";
  }
  else
  {
    cout << "No"
         << "\n";
  }
}

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

int main() {
  // input
  int a, b, k;  cin >> a >> b >> k;
  
  // calc
  int count = 0, ans;
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) count++;
    if (count == k) {
      ans = i;
      break;
    }
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> x;
    if(x%1000==0)
        cout << "0\n";
    else
    {
        y=(x/1000)+1;
        cout << (y*1000)-x << endl;
    }
        
}


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

const int N = 21;
const int P2N = (1 << N);

int n;
bool ar[N][N];
int dp[N][P2N];

int f(int curr, int bmask) {
	if(curr == n)
		return 1;
	if(dp[curr][bmask] != -1)
		return dp[curr][bmask];
	dp[curr][bmask] = 0;
	for( int i = 0 ; i < n ; i++ )
		if( ar[curr][i] && (bmask & (1<<i)) == 0 )
			dp[curr][bmask] = ( dp[curr][bmask] + f( curr+1 , (bmask | (1<<i)) ) ) % mod;
	return dp[curr][bmask];
}

int main() {
	scanf("%d",&n);
	for( int i = 0 ; i < n ; i++ )
		for( int j = 0 ; j < n ; j++ )
			cin >> ar[i][j];
	memset(dp, -1, sizeof(dp));
	printf("%d\n",f(0,0));
	return 0;
}


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

const int MaxN = 100000 + 5;
const int INF = 0x7F7F7F7F;

int N, K;
int H[MaxN];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) scanf("%d", &H[i]);
    sort(H + 1, H + 1 + N);

    int ans = INF;
    for (int i = 1; i + K - 1 <= N; ++i) {
        int hm = H[i], hx = H[i + K - 1];
        ans = min(ans, hx - hm);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
#define ld long double
#define ar array
#define read(A) scanf("%lld",&A);
const ll maxN=1e5+5;
ll n ;
void solve(){
	cin>> n ;
	ll ans = n%1000;
	if(ans==0)cout<<ans<<endl;
	else{
		ans=1000-ans;
		cout<<ans<<endl;
	}
	
}
int main(){
	//mahakal(),fast;
	ll t =1 ;
	// cin>> t ;
	while(t--)solve();

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
        hayami saori = new hayami();
		int ans = 0;
		int N = saori.saori_hayami();
		int M = saori.saori_hayami();
		int[] X = new int[M];
		for(int i=0; i<M; i++){
			X[i] = saori.saori_hayami();
		}
		Arrays.sort(X);
		int[] diff = new int[M-1];
		for(int i=0; i<M-1; i++){
			diff[i] = X[i+1] - X[i];
		}
		Arrays.sort(diff);
		if(N>=M){
			ans = 0;
		}else{
			for(int i=0; i<M-N; i++){
				ans += diff[i];
			}
		}
		System.out.println(ans);
		
	}
	
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


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

int main(void)
{
  int s;
  cin>>s;
  int f=s/100;
  int b=s-f*100;
  if(1<=f&&f<=12){
    if(1<=b&&b<=12)
      cout<<"AMBIGUOUS"<<endl;
    else if(0<=b&&b<=99)
      cout<<"MMYY"<<endl;
  }
  else if(0<=f&&f<=99){
    if(1<=b&&b<=12){
      cout<<"YYMM"<<endl;
    }
    else{
     cout<<"NA"<<endl;
    }
  }
  else
    cout<<"NA"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define ITR(x, c) for(__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
    cin>>n;
    ll wa1=0,wa2=0,teisu=0;
    priority_queue<ll>A1;
    priority_queue<ll,vector<ll>,greater<ll>> A2;

    rep(i,n){
        cin>>x;
        if(x==1){
            cin>>a>>b;
            if(A1.size()==A2.size()){
                A2.push(a);
                x=A2.top();
                A2.pop();
                A1.push(x);
                wa1+=x;
                wa2+=a-x;
            }
            else{
                A1.push(a);
                x = A1.top();
                A1.pop();
                A2.push(x);
                wa1+=a-x;
                wa2+=x;
            }
            teisu+=b;
        }
        else{
            x=A1.top();
            e=A1.size();
            f=A2.size();
            cout<<x<<" "<<x*(e-f)-wa1+wa2+teisu<<endl;
        }
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ab(M);
  vector<int> ans(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ans[a-1]++;
    ans[b-1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int r;
    cin >> r;
    printf("%.5f\n",(double) r * 2 * M_PI);
    return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  for (int i = 0; i < m; ++i) {
    cin >> l[i] >> r[i];
  }
  int ri = r[0], le = l[0];
  for (int i = 1; i < m; ++i) {
    ri = min(ri, r[i]);
    le = max(le, l[i]);
  }
  cout << max(0, ri - le + 1) << endl;
  return 0;
}

Measured memory_bytes: 4056
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);

const int N = 2e5 + 5;
int t;
ll a[N];
ll b[N];
int c[N];
int main()
{
	int n;
	while (cin >> n)
	{
		f(i, 1, n) { scanf("%d", &c[i]);a[c[i]]++; }
		
		ll sum = 0;
		f(i, 1, n)
		{
			b[i] = a[i];
			a[i] = a[i] * (a[i]-1) / 2;
			sum += a[i];
		}
		//f(i, 1, n)cout << c[i] << endl;
		//f(i, 1, n)cout << b[i] << endl;
		//f(i, 1, n)cout << a[i] << endl;
		f(i, 1, n)
		{
			int j = c[i];
			ll now = sum - a[j];
			//debug(now);
			if(i!=n)
			printf("%lld\n", (ll)now +(ll) a[j] * (b[j] - 2) / b[j] );
			else printf("%lld",(ll) now +(ll) a[j] * (b[j] - 2) / b[j]  );
		}
	}
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>

#define INF (int)(1e9+7)

int dp[41][410][410], n, Ma, Mb;
int a[41], b[41], c[41];

int dfs(int x, int A, int B) {
    int tmp, ret = tmp = INF;

    if (dp[x][A][B] != 0) return dp[x][A][B];

    if ((double)A == (double)B * ((double)Ma / (double)Mb)) {
        return c[x];
    }

    for (int i = x+1; i < n; ++i) {
        ret = std::min(ret, dfs(i, A+a[i], B+b[i]) + c[x]);
    }

    return dp[x][A][B] = ret;
}

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

    std::cin >> n >> Ma >> Mb;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }
    int ans = INF;

    for (int i = 0; i < n; ++i) {
        ans = std::min(ans, dfs(i, a[i], b[i]));
    }

    if (ans != INF) std::cout << ans << std::endl;
    else std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 8448
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    sort(all(a));
    a.erase(unique(all(a)), a.end());

    if(a.size() == n){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
bool isEven(string s, int len){
	if(len & 1) return false;
	for(int i=0; i<len/2; i++){
		if(s[len/2 +i]!=s[i]) return false;
	}
	return true;
}
int main() {
	// your code goes here
	string s; 
	cin>>s;
	bool found = false;
	int len;
	for(len = s.length()-1; len>0 and !found;len--){
		if(isEven(s,len)) {
			//for(int i=0;i<len;i++) printf("%c",s[i]);
			//printf("\n");
			found = true; break;
		}
	}
	printf("%d\n",len);
	return 0;
}

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

max_zoro = 0
zoro = 0

for _ in range(N):
  a,b = map(int, input().split())
  if a==b:
    zoro += 1
    max_zoro = max(max_zoro, zoro)
  else:
    zoro = 0

if max_zoro >= 3:
  print('Yes')
else:
  print('No')

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

using namespace std;


const int N = 101000;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vipb(v) int x;cin>>x;v.pb(x);
#define vllpb(v) ll x;cin>>x;v.pb(x);
typedef vector<int> VI;

ll n, m;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	if (n == 2) {
		int x, y;
		cin >> x >> y;
		cout << x + y << endl;
	}
	else {
		cout << "Hello World" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ull unsigned long long int
#define ll long long
#define l long
#define plld(x) printf("%lld",x)
#define pld(x) printf("%ld",x)
#define pllu(x) printf("%llu",x)
#define pd(x) printf("%d",x)
#define sd(x) scanf("%d",x) 
#define sld(x) scanf("%ld",x) 
#define slld(x) scanf("%lld",x) 
#define sllu(x) scanf("%llu",x) 
#define ss(x) scanf("%s",x) 

int main(){
  char S[11],T[12];
  ss(S);
  ss(T);
  int len=strlen(S);
  for(int a=0;a<len;a++){
    if(S[a]!=T[a]){
      printf("No");
      break;
    }
  else if(a==len-1)printf("Yes");
  };
};

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<int>v[28];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s,t;

  int x;
  cin>>s>>t;
  for(int i=0;i<s.size();i++)
  {
    x=s[i]-'a';
    v[x].push_back(i+1);
  }
  int a=0,flag=0;
  ll int len=0,sz=t.size(),sum=0;
  for(int i=0;i<sz;i++)
  {
    x=t[i]-'a';
    if(v[x].size()==0){cout<<"-1\n";return 0;}

    auto sp=*upper_bound(v[x].begin(),v[x].end(),len);
   if(sp==*v[x].end())
   {
     sp=*v[x].begin();
     sum+=s.size();
   }
   sum+=sp-len;
   len=sp;
  }

  cout<<sum<<"\n";
  return 0;

}



Measured memory_bytes: 1228
n = int(input())
a = [round(float(input()) * 10**9) for _ in range(n)]
cs = [[0] * 20 for _ in range(20)]

dc = []
for i in a:
    x = 0
    for _ in range(18):
        if i % 2 == 0:
            i //= 2
            x += 1
    y = 0
    for _ in range(18):
        if i % 5 == 0:
            i //= 5
            y += 1

    cs[18-x][18-y] += 1
    dc.append((x, y))
for i in range(20):
    for j in range(19):
        cs[i][j+1] += cs[i][j]
for i in range(20):
    for j in range(19):
        cs[j+1][i] += cs[j][i]


ans = 0
for x, y in dc:
    ans += cs[x][y]
for i in a:
    if i % 10**9 == 0:
        ans -= 1
ans //= 2

print(ans)


Measured memory_bytes: 93596