akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

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

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

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

#if 1


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

  int N;
  cin >> N;
  set<int> as;
  F0R(i, N) {
    int a;
    cin >> a;
    as.insert(a);
  }
  while (as.size() > 1) {
    set<int> bs;
    int a = -1;
    for (auto n : as) {
      if (a < 0) a = n;
      else {
        int b = n % a;
        if (b) bs.insert(b);
      }
    }
    bs.insert(a);
    as = move(bs);
  }
  cout << *as.begin();
}
#endif


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct N001 {
   long n;
   std::vector<long> parents;
   std::vector<long> numbers;
   N001(long n_) : n(n_), parents(n+1, -1), numbers(n+1, -1) {
   }
};
long find(N001& s, long x) {
   if( s.parents[x] == -1 ) return x;
   return s.parents[x] = find(s, s.parents[x]);
}
bool same(N001& s, long x, long y) {
   return find(s, x) == find(s, y);
}
void unite(N001& s, long x, long y) {
   long x2 = find(s, x);
   long y2 = find(s, y);
   if( x2 == y2 ) return;
   if( not ( s.numbers[x2] <= s.numbers[y2] ) )
      std::swap(x2, y2);
   s.parents[x2] = y2;
   s.numbers[y2] += s.numbers[x2];
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, q;
      scan(n, q);
      N001 u(n);
      for(long i = 0; i < q; ++i) {
         long c, x, y;
         scan(c, x, y);
         if( c == 0 )
            unite(u, x ,y);
         else
            puts(same(u, x, y) ? "1" : "0");
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(int a, int b){
        return a>b;
    }
};

int n,m,q,c[100005],v[100005],d[100005],x,y,z;
vector <int> g[100005],xd;
deque <int> p;
int t[100005][12];


int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=m;i++) cin >> x >> y, g[x].pb(y),g[y].pb(x);
    cin >> q;
    for(int i=1;i<=q;i++) {cin >> x >> d[i] >> c[i]; t[x][d[i]]=i;}
    for(int i=10;i>=0;i--){
        for(int j=1;j<=n;j++){
            v[j]=max(v[j],t[j][i]);
            for(int k : g[j]) t[k][i-1]=max(t[k][i-1],t[j][i]);
        }
    }
    for(int i=1;i<=n;i++) cout << c[v[i]] << '\n';
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;



int64_t R, C;
pair<int64_t, int64_t> vert(int64_t r, int64_t c) {
	int64_t mid = c/2;
	return make_pair(r*mid, r*(mid + c%2));
}

pair<int64_t, int64_t> horz(int64_t r, int64_t c) {
	int64_t mid = r/2;
	return make_pair(c*mid, c*(mid + r%2));
}

int64_t sc(int64_t a, int64_t b, int64_t c) {
	return max(max(a,b), c) - min(min(a,b), c);
}

int main() {
	cin >> R >> C;
	int64_t ans = 1e18;
	for (int64_t i = 0; i < R; ++i) {
		int64_t sz1 = C*(i+1), sz2, sz3;
		tie(sz2, sz3) = vert(R-(i+1), C);
		ans = min(ans, sc(sz1, sz2, sz3));
		tie(sz2, sz3) = horz(R-(i+1), C);
		ans = min(ans, sc(sz1, sz2, sz3));
	}

	for (int64_t i = 0; i < C; ++i) {
		int64_t sz1 = R*(i+1), sz2, sz3;
		tie(sz2, sz3) = vert(R, C-(i+1));
		ans = min(ans, sc(sz1, sz2, sz3));
		tie(sz2, sz3) = horz(R, C-(i+1));
		ans = min(ans, sc(sz1, sz2, sz3));
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,vis[405][405],w,b,ans;
string s[405];
void dfs(ll i,ll j,ll col)
{
	if(i<0||j<0||i>=n||j>=m||vis[i][j])
		return;
	ll c;
	if(s[i][j]=='#')
		c=1;
	else
		c=0;
	if(col==c)
		return;
	vis[i][j]=1;
	if(c==0)
		w++;
	else
		b++;
	dfs(i,j+1,c);
	dfs(i,j-1,c);
	dfs(i+1,j,c);
	dfs(i-1,j,c);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    rep(i,0,n)
    cin>>s[i];
    rep(i,0,n)
    {
    	rep(j,0,m)
    	{
    		if(!vis[i][j])
    		{
    			w=0;
    			b=0;
    			dfs(i,j,-1);
    			ans+=(w*b);
    		}
    	}
    }
    cout<<ans;
}


Measured memory_bytes: 14208
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int n;
    long long X;
    long long D;
    cin >> n >> X >> D;

    vector<long long> M(n, 0);
    vector<long long> P(n, -1);
    for (int i = 0; i < n; ++i) {
        cin >> M[i];
        if (i > 0) {
            cin >> P[i];
            --P[i];
        }
    }

    vector<long long> W(n, 0);
    vector<long long> V(n, 0);
    for (int i = n - 1; i >= 0; --i) {
        int p = P[i];
        W[i] += M[i];
        V[i] += 1;
        if (p >= 0) {
            W[p] += W[i];
            V[p] += V[i];
        }
    }

    vector<long long> cnts(n, 1LL << 40);
    for (int i = 1; i < n; ++i) {
        long long cnt = X / W[i];
        cnt = min(cnt, D);
        cnts[i] = cnt;
    }

    vector<int> ord(n, 0);
    iota(ord.begin(), ord.end(), 0); 
    auto cmp = [&](int l, int r) {
        return V[l] * 1LL * W[r] > V[r] * 1LL * W[l];
    };
    sort(ord.begin(), ord.end(), cmp);

    int N = n * n * n;
    const long long INF = 1LL << 60;
    vector<long long> dp(N + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = N - 1; j >= 0; --j) {
            if (dp[j] >= INF) {
                continue;
            }

            for (int k = 1; k <= n && k <= cnts[i]; ++k) {
                int nj = j + k * V[i];
                if (nj <= N) {
                    dp[nj] = min(dp[nj], dp[j] + k * W[i]);
                }
            }
        }
    }

    long long res = 0;
    for (int i = 0; i <= N; ++i) {
        if (dp[i] > X) {
            continue;
        }
        long long rem = X - dp[i];
        long long ans = i;
        for (auto x : ord) {
            long long cnt = max(0LL, cnts[x] - n);
            cnt = min(cnt, rem / W[x]);
            ans += cnt * V[x];
            rem -= cnt * W[x];
        }
        res = max(res, ans);
    }
    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// mintと併用
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int n, k; cin >> n >> k;
    mint sum = 0;
    mint losum = 0;
    mint upsum = 0;
    for(int i = 0; i <= n; ++i) {
        losum += i;
        upsum += (n-i);
        // cout << losum << " " << upsum << endl;
        if(i >= k-1) {
            mint kasan = upsum - losum;
            // cout << kasan << endl;
            sum += (kasan + mint(1));
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
double ans;
ll n,m,q;
void solve()
{
    cin>>m;double ar[m+1];
    for(ll i=1;i<=m;i++)
    {
        cin>>ar[i];
    }
    sort(ar+1,ar+m+1);
    ans=ar[1];
    for(ll i=2;i<=m;i++)
    {
        ans=(ans+ar[i])/2;
    }
    cout<<ans<<endl;
}   

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<std::vector<long long>> A)
{

    vector<bool> isContain(M, true);
    ll ans = INT16_MAX;
    for (int o = 0; o < M; o++)
    {
        vector<ll> parti(M, 0);
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (isContain[A[i][j]])
                {
                    parti[A[i][j]]++;
                    break;
                }
            }
        }
        ll maximum = -1;
        ll index = -1;
        for (int i = 0; i < M; i++)
        {
            if (maximum < parti[i])
            {
                maximum = max(maximum, parti[i]);
                index = i;
            }
        }

        ans = min(ans, maximum);
        isContain[index] = false;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            ll a;
            cin >> a;
            a--;
            A[i][j] = a;
        }
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
S = input();
str = 'keyence';
ans = 'NO'
if S[:7] == str :
    ans = 'YES';
elif S[-7:] == str :
    ans = 'YES';
else :
    for i in range(1,8) :
        if S[0:i] == str[0:i] and S[-7+i:] == str[-7+i:] :
            ans = 'YES';
            break;

print(ans);


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

int main() {
	string s;
	cin >> s;
	int count = 0;

	if (s[0] == '1') count++;
	if (s[1] == '1') count++;
	if (s[2] == '1') count++;
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int n,a[114514],b[114514];
void qsort(int l,int r)
{
	int i=l,j=r,mid=a[(l+r)/2];
	while(i<=j)
	{
		while(a[i]<mid) i++;
		while(mid<a[j]) j--;
		if(i<=j)
		{
			swap(a[i],a[j]);
			swap(b[i],b[j]);
			i++;j--;
		}
	 } 
	if(i<r) qsort(i,r);
	if(l<j) qsort(l,j);
}
int main()
{
	cin>>n;
	ft(i,1,n) {scanf("%d",&a[i]);b[i]=i;}
	qsort(1,n);
	ft(i,1,n) printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;

int main(){
    string s;
    for(;;){
        cin>>s;
        if(s=="0")break;
        ll ans=0;
        rep(i,s.length()){
            string cs=s.substr(i,1);
            ans+=stol(cs.c_str());
        }
        cout<<ans<<endl;
    }

};


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

int main() {
  int n; cin >> n;
  map<string,int> m;
  int max_cnt = 0;
  rep(i,n) {
    string s; cin >> s;
    m[s]++;
    max_cnt = max(m[s], max_cnt);
  }
  for (auto mi : m) {
    string k = mi.first;
    int v = mi.second;
    if (v == max_cnt) cout << k << endl;
  }
  return 0;
}

Measured memory_bytes: 19200
import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var (a,b,n)=readLongs()
    var x=min(b-1,n)
    var ans=(a*x)/b-a*(x/b)
    printLine("$ans")
    output()
}

Measured memory_bytes: 36532
from collections import deque

n=int(input())
num=["3","5","7"]
a=deque([])
ans=0

def dfs():
  global ans
  if len(a)>0 and int("".join(a))>n:
    return
  if "3" in a and "5" in a and "7" in a:
    ans+=1
  for i in num:
    a.append(i)
    #print("a",a,"".join(a),"ans",ans)
    dfs()
    a.pop()
dfs()
print(ans)

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

int main(){
  int N,sum=0,sum1=0;
  double ave;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum += a[i];
  }
  ave = double(sum)/double(N);
  int c = round(ave);
  for(int i=0;i<N;i++){
    sum1 += pow((a[i]-c),2);
  }
  cout << sum1 << endl;
}

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

int main () {
int X;
cin >> X;
int a;
a = X / 500;
int r;
r = X % 500;
int b;
b = r / 5;
int happy;
happy = 1000*a + 5*b;
cout << happy << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;

int a[100005][3];
int dp[100005][3];

int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i = 1; i < n; i++)
    {
        for(int l = 0; l < 3; l++)
        {
            int m = 0;
            for(int j = 0; j < 3; j++)
                if(j != l)
                    m = max(m, dp[i-1][j]);
            dp[i][l] = m + a[i][l];
        }
    }
    cout << *max_element(dp[n-1], dp[n-1] + n);
}


Measured memory_bytes: 2560
import collections
n = int(input())
v = [int(i) for i in input().split()]
v_even = [v[2*i] for i in range(int(n/2))]
v_odd = [v[2*i-1] for i in range(int(n/2))]
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)
if(c_even.most_common()[0][0]!=c_odd.most_common()[0][0]):
    print(n - c_even.most_common()[0][1] - c_odd.most_common()[0][1])
elif(len(collections.Counter(v))==1):
    print(int(n/2))
else:
    if(c_even.most_common()[0][1]>c_odd.most_common()[0][1]):
        print(n-c_even.most_common()[0][1] - c_odd.most_common()[1][1])
    elif(c_even.most_common()[0][1]<c_odd.most_common()[0][1]):
        print(n - c_odd.most_common()[0][1] - c_even.most_common()[1][1])
    else:
        print(n - c_odd.most_common()[0][1] - max(c_odd.most_common()[1][1],c_even.most_common()[1][1]))

Measured memory_bytes: 21156
import sys
input = sys.stdin.readline
mod = 10**6+3
#mod = 13

Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

T = [1]
for n in range(1, mod+1):
    T.append(T[-1]*n%mod)

for x, d, n in Query:
    start = x*pow(d, mod-2, mod)%mod
    if d == 0:
        ans = pow(x, n, mod)
    elif start == 0 or start + n-1 >= mod:
        ans = 0
    else:
        ans = pow(d, n, mod) * pow(T[start-1], mod-2, mod) * T[start+n-1] % mod
    print(ans)

Measured memory_bytes: 72456
while true do
sougaku = gets.to_i
if sougaku == 0 then
break
end

hon1 = gets.to_i
sougaku = sougaku - hon1

hon2 = gets.to_i
sougaku = sougaku - hon2

hon3 = gets.to_i
sougaku = sougaku - hon3

hon4 = gets.to_i
sougaku = sougaku - hon4

hon5 = gets.to_i
sougaku = sougaku - hon5

hon6 = gets.to_i
sougaku = sougaku - hon6

hon7 = gets.to_i
sougaku = sougaku - hon7

hon8 = gets.to_i
sougaku = sougaku - hon8

hon9 = gets.to_i
sougaku = sougaku - hon9

puts(sougaku)
end

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli n,m;
lli a[100100];
lli sum[100100];

lli getCount(lli num)
{
    lli res=0;
    REP(i,0,n){
        lli ay = num-a[i];
        lli idx = lower_bound(a,a+n,ay)-a;
        res += (n-idx);
    }
    return res;
}

lli getSum(lli num)
{
    lli res = 0;
    REP(i,0,n){
        lli ay = num - a[i];
        lli idx = lower_bound(a,a+n,ay)-a;
        lli cnt = n-idx;
        res += 1LL * a[i]*cnt;
        res += (sum[n]-sum[idx]);
    }
    return res;
}
signed main(){

    cin>>n>>m;
    REP(i,0,n)cin>>a[i];
    sort(a,a+n);

    REP(i,0,n)sum[i+1] += sum[i]+a[i];
    
    REP(i,0,n+1) if(DEBUG)cout<<"i="<<i<<" sum[i]="<<sum[i]<<endl;

    lli small=0,large=INF;

    while(small+1 != large){
        lli middle = (small+large)/2;
        if(DEBUG)cout<<"small="<<small<<" middle="<<middle<<" large="<<large<<endl;

        lli cnt = getCount(middle);
        if(DEBUG)cout<<"cnt="<<cnt<<endl;
        lli target = n*n-m;
        if(m<=cnt)small = middle;
        else large = middle;
    }
    lli ans = (m-getCount(small+1))*(small) + getSum(small+1);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

const int MX = 2e8 + 100;

bitset <MX> vis;


bool check(int x){
	if(x % 2 == 0){
		if(vis[2]) return true;
		vis[2] = 1;
	}
	
	while(x % 2 == 0){
		x /= 2;
	}
	
	for(int i = 3; i <= sqrt(x); i += 2){
		
		if(x % i == 0 && vis[i]) return true;
		
		while(x % i == 0){
			vis[i] = 1;
			x /= i;
		}
	}
	
	if(x > 1){
		if(vis[x]) return true;
		vis[x] = 1;
	}
	
	return false;
}




void solve(){
	int n;
	cin >> n;
	
	VI v(n);
	loop(i, n) cin >> v[i];
	
	bool b = false;
	loop(i, n){
		b |= check(v[i]);
	}
	
	if(!b){
		cout << "pairwise coprime";
		return;
	}
	
	loop(i, n){
		if(i) v[i] = __gcd(v[i], v[i - 1]);
	}
	
	if(v[n - 1] == 1){
		cout << "setwise coprime";
		return;
	}
	
	cout << "not coprime";
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}




Measured memory_bytes: 11200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,m; cin>>n>>m;
	n-=m;
	cout<<((n+m-1-1)/(m-1))+1<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int num;
        char shiritori[100][11];
        char a;
scanf("%d",&num);
scanf("%s",&shiritori[0] );
for (int i = 1; i < num; i++) {
  scanf("%s",&shiritori[i] );
  for (int j = 0; j < 10; j++) {
    if (shiritori[i-1][j]=='\0') {
      break;
    }
    a=shiritori[i-1][j];
  }
if (a!=shiritori[i][0]) {
  printf("No\n" );
  return 0;
  
}
for (int j = 0; j < i; j++) {
  if (strcmp(shiritori[i],shiritori[j])==0) {
    printf("No\n" );
    return 0;
  }
}
}
printf("Yes\n" );
 
        return 0;
}


Measured memory_bytes: 128
for e in iter(input,'0'):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x<=m:
   for u,v in a:
    if(x+u-s,y+v-t)not in b:break
   else:print(x-s,y-t);break


Measured memory_bytes: 6048
N = int(input())
H = list(map(int, input().split()))

updown = ['-' if H[i+1] <= H[i] else '+' for i in range(N-1)]
count = 0
max = 0
for i in updown:
    if i == '-':
        count += 1
    else:
        if count > max:
            max = count
        count = 0
if count > max:
    max = count
print(max)

Measured memory_bytes: 15020
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 3 * 1000 + 1;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);
	LL a, b;
	cin >> a >> b;
	if (a * b <= 0)
	{
		cout << "Zero" << endl;
		return 0;
	}

	if (a > 0)
	{
		cout << "Positive" << endl;
		return 0;
	}

	if ((b - a) % 2 == 0)
	{
		cout << "Negative" << endl;
		return 0;
	}

	cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdlib>
using namespace std;

int main() {
  string str;
  char *e;
  const char *p;
  int a;
  map<int, int> mp1, mp2, mp3;
  
  while(getline(cin, str)) {
    if(str=="") break;
    p = &str[0];
    a = strtol( p, &e, 10 );
    mp1[a] ++; mp3[a] ++;
  }
  
  while(getline(cin, str)) {
    p = &str[0];
    a = strtol( p, &e, 10 );
    mp2[a] ++; mp3[a] ++;
  }

  for( map<int, int>::iterator it = mp3.begin(); it != mp3.end(); it ++ ) {
    if( mp1[it->first] && mp2[it->first] ) {
      cout << it->first << " " << it->second << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int dx[4] = {1,-1,0,0};
const int dy[4] = {0,0,1,-1};
const int NUMC = 6;
int h,w,c;
vector<vector<int> > mp;
 
int dfs(int def_i,int def_j,int depth,int col){
	if(col == mp[def_i][def_j])return 0;
	vector<vector<int> > save_mp;
  int num_panel[NUMC] = {};
	int def_col = mp[def_i][def_j];
	mp[def_i][def_j] = col;
	queue<pair<int,int> > que;
  que.push(make_pair(def_i,def_j));
  while(!que.empty()){
    pair<int,int> P = que.front();
      que.pop();
      REP(i,4){
				int y = P.first + dy[i];
				int x = P.second + dx[i];
				if(x<0 || y<0 || x>=w || y>=h){continue;}
				if(def_col == mp[y][x] ){
					que.push(make_pair(y,x));
					mp[y][x] = col;
				}
      }
	}
	if(depth<5){
		save_mp = mp;
		REP(col_i,NUMC){
			if(depth == 4 && col_i+1 != c || depth == 3 && col_i+1 == c)continue;
			num_panel[col_i] = dfs(def_i,def_j,depth+1,col_i+1);
			mp = save_mp;
		}
		return *max_element(num_panel,num_panel+NUMC);
	}else if(depth == 5){
		que.push(make_pair(def_i,def_j));
		int ct = 1;
		mp[def_i][def_j] = -1;
		while(!que.empty()){
			pair<int,int> P = que.front();
      que.pop();
      REP(i,4){
				int y = P.first + dy[i];
				int x = P.second + dx[i];
				if(x<0 || y<0 || x>=w || y>=h){continue;}
				if(col == mp[y][x] ){
					que.push(make_pair(y,x));
					mp[y][x] = -1;
					ct++;
				}
      }
		}
		return ct;
	}
}
  
int main(){
    while(cin >> h>>w>>c,h||w||c){
        mp.resize(h,vector<int>(w));
        REP(i,h)
            REP(j,w)cin >> mp[i][j];
        int ans = 0;
				vector<vector<int> > save_mp = mp;
        REP(i,1){
            REP(j,1){
                REP(col_i,NUMC){
                    ans = max(ans,dfs(i,j,1,col_i+1));
										mp = save_mp;
                }
								//cout << ans << " ";
            }
						//						cout << endl;
        }
    cout << ans << endl;
		mp.clear();
    }
}

Measured memory_bytes: 3180
def solve(a,b,c,d):
    lst = [(a,"start",),(b,"end"),(c,"start"),(d,"end")]
    lst.sort(key = lambda x:x[0])
    overlap = 0
    time = 0
    temp = 0
    for i in lst:
        if overlap == 2:
            time = i[0] - temp
        if i[1] == "start":
            overlap += 1
            temp = i[0]

        if i[1] == "end":
            overlap -= 1



    return time



if __name__ == "__main__":
    a,b,c,d = map(int,input().split())
    print(solve(a,b,c,d))

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

struct pair_hash {
	template <class T1, class T2>
	std::size_t operator() (const std::pair<T1, T2> &pair) const {
		return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
	}
};

int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;
  if ((a==b) && (b==c)) std::cout << "Yes";
  else std::cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)2e6;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
vi adj[N];
typedef struct  Union_find{
    vi parent;
    vi rank;
    Union_find(int n){
        parent.resize(n+1);
        rank.resize(n+1);
        range(i,1,n)parent[i]=i,rank[i]=1;
    }
    int find_parent(int x){
        if(x==parent[x])return x;
        return parent[x]=find_parent(parent[x]);
    }
    void merge(int x,int y){
        if(rank[x]>rank[y])swap(x,y);
        parent[x]=y;
        rank[y]+=rank[x];
    }
    void unite(int x,int y){
        x = find_parent(x);
        y = find_parent(y);
        if(x!=y){
            merge(x,y);
        }
    }
};


void _run(){
  int n,k;
  scanf("%d%d",&n,&k);
  Union_find uf(n);
  lp(i,k){
       int f,t;
       scanf("%d%d",&f,&t);
       uf.unite(f,t);
   }
   int mx=0,cnt=0;
   range(i,1,n){
       mx = max(uf.rank[i],mx);
   }
   printf("%d",mx);
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 51856
#include <stdio.h>
 
int main(void) {
    int a;
    int h=0,m=0,s=0;
    scanf("%d",&a);
    //3600?§???\???????????°???????????????????????¨??????????????????
    while(a>=3600) a-=3600,h++;
    //60?§???\???????????°????????????????????¨??????????????????
    while(a>=60) a-=60,m++;
    //?????£????§???°
    s=a;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int X, Y, A, B, C;
int red_sum = 0, green_sum = 0;
stack<int> red_q, green_q;
queue<int> white_q;

void solve(){
    while(!white_q.empty()){
        int r = (red_q.empty() ? INT_MAX : red_q.top());
        int g = (green_q.empty() ? INT_MAX : green_q.top());
        if(r==INT_MAX && g==INT_MAX) break;
        if(r < g && r < white_q.front()){
            red_sum = red_sum - r + white_q.front();
            red_q.pop();
        }else if(g < white_q.front()){
            green_sum = green_sum - g + white_q.front();
            green_q.pop();
        }else{
            break;
        }
        white_q.pop();
    }
    cout << red_sum + green_sum << endl;
}

signed main(){
    cin >> X >> Y >> A >> B >> C;
    vector<int> red(A), green(B), white(C);
    rep(i,A) cin >> red[i];
    rep(i,B) cin >> green[i];
    rep(i,C) cin >> white[i];
    sort(rALL(red)); sort(rALL(green)); sort(rALL(white));
    
    rep(i,X){
        red_sum += red[i];
        red_q.push(red[i]);
    }
    rep(i,Y){
        green_q.push(green[i]);
        green_sum += green[i];
    }
    rep(i,C) white_q.push(white[i]);
    
    solve();
}

Measured memory_bytes: 4864
#include <iostream>
	#include <iomanip>
	#include<math.h>
	#include<list>
	#include <algorithm>
	#include<set>
	#include<vector>
	#include<math.h>
	#include<map>
	#include<string>
	#include <numeric>
	#include <queue>
	#include <sstream>
	#include <bitset>
	#include<stack>

	using namespace std;
	using ll = long long;
	using vll = vector<long long>;
	using sll = set<long long>;


	template<typename T>
	T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
	template<typename T>
	T lcm(T a, T b) { return a / gcd(a, b) * b; }

	template<typename T>
	map<T, T> getPrimeFactor(T n) {
		map<T, T> res;
		for (T i = 2; i * i <= n; ++i) {
			while (n % i == 0) {
				res[i] ++;
				n /= i;
			}
		}
		if (n != 1) res[n] = 1;
		return res;
	}

	template<typename T>
	bool IsPrimeNumber(T num)
	{
		if (num <= 2) return true;
		else if (num % 2 == 0) return false;

		double sqrtNum = sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				return false;
			}
		}

		return true;
	}

	long long modinv(long long a, long long m) {
		long long b = m, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= m;
		if (u < 0) u += m;
		return u;
	}

	// 繰り返し二乗法
	ll pow2(ll n, ll p, ll mod) {
		if (p == 0 || n == 1) {
			return 1;
		}
		else {
			ll ret = pow2(n * n % mod, p / 2, mod);
			if (p % 2 == 1) {
				ret *= n;
			}
			return ret % mod;
		}
	}


	#define rep(i,s,e) for(ll i=s;i<e;i++)
	#define repeq(i,s,e) for(ll i=s;i<=e;i++)

	int main() {
		ll N;
		cin >> N;
		vll A(N);
		cin >> A[0];

		ll ans = 1000;
		rep(i, 1, N) {
			cin >> A[i];
			if (A[i] > A[i - 1]) {
				ll num = ans / A[i - 1];
				ans += num * (A[i] - A[i - 1]);
			}
		}
		cout << ans << endl;
	}


Measured memory_bytes: 3628
import copy

n = int(input())
A = [int(x) for x in input().split()]
q = int(input())
M = [int(x) for x in input().split()]

c = [0]
S = [0]

for a in A:
  S = copy.copy(c)
  for  s in S:
    c.append(s+a)

for m in M:
    if m in c:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 47728
#include<stdio.h>

int N,sum;
int s[110];
int dp[110][10010];

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&s[i]);
		sum+=s[i];
	}
	
	dp[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=sum;j++){
			dp[i+1][j]|=dp[i][j];
			if(j>=s[i])dp[i+1][j]|=dp[i][j-s[i]];
		}
	}
	for(int i=sum;i>0;i--){
		if(i%10!=0 && dp[N][i]==1){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("0\n");	
	return 0;
}

Measured memory_bytes: 4224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define sz(x)                       (ll) x.size()
#define PB(x)                       push_back(x)
#define bs(a, x)                   binary_search(a , a + sizeof(a) / sizeof(a[0] , x)
#define ts(x)                       to_string(x)
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define bsv(a, x)                  binary_search(all(a), x)
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll dp[MAXN] , h[MAXN];
int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (ll i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n, m);
	vector<vector<int>> g(n);
	inc(i, m) {
		IN(int, a, b);
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	
	
	vector<int> vis(n), p(n);
	queue<int> q;
	q.push(0); vis[0] = 1;
	until(q.empty()) {
		auto v = q.front(); q.pop();
		RF(e, g[v]) {
			if(vis[e] == 0) { q.push(e); vis[e] = 1; p[e] = v; }
		}
	}
	
	OUT("Yes");
	incID(i, 1, n) { OUT(p[i] + 1); }
 }


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

typedef long long ll;

int l, r;
ll ans = 1 << 29; 

int main()
{
	scanf("%d%d", &l, &r);
	if ((r / 2019) * 2019 >= l)
		printf("0");
	else if (l == r)
	{
		printf("%d", l * r % 2019);
	}
	else
	{
		for (int i = l; i < r; i ++)
			for (int j = i + 1; j <= r; j ++)
				ans = std::min(ans, (1ll * i * j) % 2019);
		printf("%lld", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int c=0,m=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            c++;
        }
        else if(s[i]=='B')
        {
            m++;
        }
    }
    if(m!=0 && c!=0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

vector<ll> a;

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

  a.reserve(n+1);
  REP(i,n) {
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a.begin(), a.begin()+n);
  ll b;
  if(n%2 == 0) {
    b = a[n/2 -1];
  } else {
    b = a[(n-1)/2];
  }

  ll r = 0;

  REP(i,n) {
    r += abs(a[i] - b);
  }

  cout << r << endl;

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[200001],B[200001];
	ll Asum=0,Bmin=INFl;
	int sameflag=1;
	scan(N);
	rep(i,N){
		scan(A[i]);scan(B[i]);
		if(A[i]!=B[i]) sameflag=0;
		Asum+=A[i];
		if(A[i]>B[i]) Bmin=min(Bmin,B[i]);
	}
	if(sameflag) prin(0);
	else prin(Asum-Bmin);
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(void){
    int x,y, i=0, a[3000],b[3000];
    while(cin>>x>>y){
        if(x == 0 && y == 0){
            break;
        }
        a[i] = x;
        b[i] = y;
        if(x < y){
            cout<<a[i]<<" "<<b[i]<<"\n";
        }
        else{
            cout<<b[i]<<" "<<a[i]<<"\n";
        }
        i++;
    }
}


Measured memory_bytes: 3068
n = int(input())
s = [input() for _ in range(n)]
ss = sorted(s)
t = ss
x = 0
maxx = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        x += 1
        if x == maxx:
            maxx = x
            t.append(ss[i])
        elif x > maxx:
            maxx = x
            t = [ss[i]]
    else:
        x = 0
for j in t:
    print(j)

Measured memory_bytes: 25452