akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;
int main (void) {
    int N;
    map<string, int> mp;

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

    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        string t;
        cin >> t;
        auto itr = mp.find(t);
        if (itr != mp.end()) {
            mp[t]--;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans = max(ans, mp[s[i]]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll A, B, C;

int main(int argc, char **argv) {
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else if (A >= B && A >= C) {
		cout << (B * C) << endl;
	}
	else if (B >= C && B >= A) {
		cout << (A * C) << endl;
	}
	else {
		cout << (A * B) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
function main(input) {
    const reverse = (s) => {
        return s.split('').reverse().join('');
    };

    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    var index = 0;

    while(true) {
        var w = WORDS.find((w) => S.startsWith(w, index));
        if (!w) break;
        index += w.length;
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll NMAX = 1e2;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod_pow(ll base, ll index, ll mod) {
    if(index == 0) return 1LL;
    ll res = mod_pow((base * base) % mod, index / 2, mod);
    if(index & 1) (res *= base) %= mod;
    return res;
}

int N, p;
V A;

int main() {
    cin >> N >> p;
    A.resize(N);
    cominit();
    int odd = 0, even = 0;
    REP(i, N) {
        A[i] = IN();
        if(A[i] % 2)
            odd++;
        else
            even++;
    }
    ll ans = 0;
    if(p) {
        // odd
        for(int i = 0; 2 * i + 1 <= odd; i++) {
            ans += comb(odd, 2 * i + 1);
        }
        ans *= mod_pow(2LL, even, LINF);
    } else {
        // even
        for(int i = 0; 2 * i <= odd; i++) {
            ans += comb(odd, 2 * i);
        }
        ans *= mod_pow(2LL, even, LINF);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b, c; cin >> a >> b >> c;
  set<ll> ss;
  ss.insert(a); ss.insert(b); ss.insert(c);
  cout << ss.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

vector<int> X(5);
vector<bool> used(5, false);
int res = 1000;
void dst(int pos, int acc) {
    if (pos == 5) {
        amin(res, acc);
    }
    REP(i, 5) {
        if (used[i]) {
            continue;
        }
        used[i] = true;
        if (pos != 4) {
            dst(pos + 1, acc + ceil(X[i], 10) * 10);
        } else {
            dst(pos + 1, acc + X[i]);
        }
        used[i] = false;
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 5) {
        cin >> X[i];
    }
    dst(0, 0);
    cout << res << endl;
    return 0;
}


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

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vp v(1,P(0,-1));vi u;
    rep(i,n){
        ll a;cin>>a;
        if(a>v.back().fi)v.pb(a,i);
        else u.pb(a);
    }
    sort(all(u));reverse(all(u));
    reverse(all(v));
    vi ans(n);
    ll num=0,w=0;
    rep(i,v.size()-1){
        num++;
        ans[v[i].se]+=num*(v[i].fi-v[i+1].fi);
        while(w<u.size()){
            if(u[w]<v[i+1].fi)break;
            ans[v[i].se]+=u[w]-v[i+1].fi;
            num++;w++;
        }
    }
    for(ll x:ans)out(x);
}

Measured memory_bytes: 5708
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = (sc.nextLong() - (long)(i + 1));
    }
    Arrays.sort(a);
    long ans = 0;
    long b = a[n / 2];
    for(int i = 0; i < n; i++) {
      ans += (long)Math.abs(a[i] - b);
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n;
  while(cin >> n , n) {
    int mass[20][20]={0};
    int nowx = n / 2;
    int nowy = nowx + 1;
    int limit = n * n + 1;
    int cou = 2;
    mass[nowy][nowx] = 1;
    while(cou != limit) {
      if(mass[(nowy+1)%n][(nowx+1)%n] == 0){
	nowy = (nowy + 1) % n;
	nowx = (nowx + 1) % n;
	mass[nowy][nowx] = cou;
      }
      else {
	nowy = (nowy + 1) % n;
	nowx = (nowx + 1) % n;
	nowy = (nowy + 1) % n;
	if(nowx - 1 == -1) nowx = n - 1;
	else nowx = nowx - 1;
	mass[nowy][nowx] = cou;
      }
      cou++;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	printf("%4d",mass[i][j]);
      }
      cout << endl;
    }
  }
}
    

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

int main(){

 
  ll X;
  cin>>X;
  
  if(X==1){cout<<0<<" "<<-1<<endl;return 0;}
  
 
  ll s=0;
  while(1){
    s++;
    if(s*s*s*s*s==X){cout<<s<<" "<<0<<endl;return 0;}
    else if(-1*s*s*s*s*s==X){cout<<0<<" "<<-s<<endl;return 0;}
    if(s*s*s*s*s>X)break;
  
  }
  

  ll s2=0;
  vector<ll> v;
  while(1){

    s2++;
    if(X%s2==0)v.push_back(s2);
    if(s2*s2>X)break;
    
  }
  
  for(ll a=0;a<X;a++){

    for(auto itr = v.begin(); itr != v.end(); ++itr) {  
      ll b=*itr;
      b=a-b;
      if(a*a*a*a*a-b*b*b*b*b==X){cout<<a<<" "<<b<<endl;return 0;}
      else if(-1*a*a*a*a*a-b*b*b*b*b==X){cout<<-a<<" "<<b<<endl;return 0;}
      else if(-1*a*a*a*a*a+b*b*b*b*b==X){cout<<-a<<" "<<-b<<endl;return 0;}
      else if(a*a*a*a*a+b*b*b*b*b==X){cout<<a<<" "<<b<<endl;return 0;}
    
    }
    if(a*a>X)break;

  }
  
}

Measured memory_bytes: 3600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	l := strings.Split(line, " ")
	N, _ := strconv.Atoi(l[0])
	K, _ := strconv.Atoi(l[1])
	M := uint64(1000000007)
	C := make([][]uint64, N+3)
	for i := 0; i < N+3; i++ {
		C[i] = make([]uint64, N+3)
	}
	C[1][1] = 1
	for i := 2; i < N+2; i++ {
		for j := 1; j < i+2; j++ {
			C[i][j] = C[i-1][j] + C[i-1][j-1]%M
		}
	}
	for i := 1; i <= K; i++ {
		fmt.Println((C[N-K+2][i+1] % M) * (C[K][i] % M) % M)
	}
}


Measured memory_bytes: 21760
#include <iostream>

using namespace std;

int n, heap[500001];

void maxHeapify(int i) {
    int l = i * 2;
    int r = i * 2 + 1;
    int maxi = i;
    if (l <= n && heap[l] > heap[maxi])
        maxi = l;
    if (r <= n && heap[r] > heap[maxi])
        maxi = r;
    if (maxi != i) {
        swap(heap[i], heap[maxi]);
        maxHeapify(maxi);
    }
}

void buildMaxHeap() {
    for (int i = n / 2; i >= 1; --i) {
        maxHeapify(i);
    }
}

int main() {
    int v;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v;
        heap[i] = v;
    }
    buildMaxHeap();
    for (int i = 1; i <= n; ++i)
        cout << " " << heap[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 5044
// AtCoder Grand Contest 012
// B - Splatter Painting

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#define MAX_N 100000
#define MAX_Q 100000
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;


int N, M, Q;
vector<int> G[MAX_N];
int nc[MAX_N], nq[MAX_N];
int v[MAX_Q], d[MAX_Q], c[MAX_Q];
int cnt;
queue<PII> q;

int main() {

  int a, b, cv, cd;

  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d%d", &a, &b);
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    scanf("%d%d%d", &v[i], &d[i], &c[i]);
    v[i]--;
  }
  memset(nc, 0, sizeof(nc));
  memset(nq, -1, sizeof(nq));

  cnt = 0;
  for (int j = Q - 1; j >= 0; j--) {
    q.push(PII(v[j], d[j]));
    while (!q.empty()) {
      cv = q.front().first;
      cd = q.front().second;
      q.pop();
      if (nq[cv] == j) {
        continue;
      }
      if (nc[cv] == 0) {
        cnt++;
      }
      if (nq[cv] < j) {
        nc[cv] = c[j];
      }
      nq[cv] = j;
      if (cd > 0) {
        for (int &to: G[cv]) {
          q.push(PII(to, cd - 1));
        }
      }
    }
    if (cnt >= N) {
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    printf("%d\n", nc[i]);
  }

  return 0;

}




Measured memory_bytes: 9336
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
AB = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        a, b = AB[j][0], AB[j][1]
        if i == j:
            continue
        uf.union(a, b)
    if uf.group_count() > 1:
        ans += 1
print(ans)

Measured memory_bytes: 9276
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) 
{
    int N, k, i = 0, s = 0;
    int a[100];
    cin >> N;
    while (cin >> k)
    {
        a[i] = k;
        //printf("%d\n", a[i]);
        i++;
        
    }
    for (int i = 0; i <= N; i++) 
    {
        if ((i+1) % 2 == 1 && a[i] % 2 == 1) 
        {
           // printf("%d\n", a[i]);
            s += 1;
        }
    }
    printf("%d\n", s);
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);
  int cnt = 0;
  int tmp_a = 0;
  rep(i, N) {
    tmp_a = a.at(tmp_a) - 1;
    ++cnt;
    if (tmp_a == 1) break;
  }
  if (tmp_a == 1) cout << cnt << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 2010
typedef long long ll;
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
const int P = 1e9 + 7;
inline ll quickpow(ll x, int k) {
	ll res = 1;
	while (k) {
		if (k & 1)	res = res * x % P;
		x = x * x % P;
		k >>= 1;
	}
	return res;
}
int n, m;
ll X;
struct Edge{
	int u, v, w;
}E[N];
bool cmp(const Edge &a, const Edge &b) {
	return a.w < b.w;
}
int cnt, Cnt;
int fa[N];
int find(int cur) {
	return fa[cur] == cur ? cur : fa[cur] = find(fa[cur]);
}
inline ll calc(int id) {
	ll res = E[id].w;
	for (int i = 1; i <= n; ++i)	fa[i] = i;
	fa[E[id].u] = E[id].v;
	for (int i = 1, ct = 0; i <= m && ct < n - 1; ++i) if (i != id) {
		int u = E[i].u, v = E[i].v, w = E[i].w;
		u = find(u), v = find(v);
		if (u == v)	continue;
		fa[u] = v; res += w; ++ct;
	}
	return res;
}
int main() {
	read(n), read(m), read(X);
	for (int i = 1; i <= m; ++i) {
		int u, v, w; read(u), read(v), read(w);
		E[i] = (Edge){u, v, w};
	}
	sort(E + 1, E + 1 + m, cmp);
	ll mn = calc(0);
	if (mn > X) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= m; ++i) {
		ll tmp = calc(i);
		if (tmp > X)	++Cnt;
		else if (tmp == X)	++cnt;
	}
	if (mn == X) {
		printf("%lld\n", ((quickpow(2, cnt) - 2) * quickpow(2, Cnt) % P + P) % P);
		return 0;
	}
	ll ans = 2ll * (quickpow(2, cnt) - 1) * quickpow(2, Cnt) % P;
	printf("%lld\n", (ans % P + P) % P);
	return 0;
}


Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int main() {
  int a,b,n,i,s;
  while(cin>>a>>b>>n){
    s=0;
    for(i=1;i<n+1;i++){
      a=a%b*10;
      s+=(int)a/b;
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int nums[1000001];

int sc[1001];
int a[100001];
int b[100001];
int data[1002][1002];
bool mov[1002][1002];
bool used[1002][1002];

int height;

void use(int h, int w){
	if(h == height) return;
	used[h][w] = true;
	if(mov[h][w]){
		use(h+1, w+1);
	}else if(mov[h][w-1]){
		use(h+1, w-1);
	}else{
		use(h+1, w);
	}
}

int cost(int h, int w){
	int d;
	if(h == height) return sc[w];
	if(mov[h][w]){
		d = cost(h+1, w+1);
	}else if(mov[h][w-1]){
		d = cost(h+1, w-1);
	}else{
		d = cost(h+1, w);
	}
	return data[h][w] = d;
}

int main(){
	int n, m, h, k;
	while(cin >> n >> m >> h >> k && (n || m || h || k)){
		for(int i = 1; i <= n; i++) cin >> sc[i];
		height = h;
		memset(mov, false, sizeof(mov));
		memset(used, false, sizeof(used));
		for(int i = 0; i < m; i++){
			cin >> a[i] >> b[i];
			mov[b[i]][a[i]] = true;
		}
		int res = 0;
		for(int i = 1; i <= n; i++){
			int c = cost(0, i);
			if(i <= k) res += c;
		}
		for(int i = 1; i <= k; i++){
			use(0, i);
		}
		int dec = 0;
		for(int i = 0; i < m; i++){
			if(used[b[i]][a[i]]){
				if(!used[b[i]][a[i]+1]){
					dec = max(data[b[i]][a[i]] - data[b[i]][a[i]+1], dec);
				}
			}else{
				if(used[b[i]][a[i]+1]){
					dec = max(data[b[i]][a[i]+1] - data[b[i]][a[i]+1], dec);
				}
			}
		}
		cout << res - dec << endl;
	}
	return 0;
}

Measured memory_bytes: 7556
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(0, A+1, 1):
  for j in range(0, B+1, 1):
    for k in range(0, C+1, 1):
      if 500 * i + 100 * j + 50 * k == X:
        ans += 1
        
print(ans)

Measured memory_bytes: 9184
def main():
    n, m = map(int, input().split())
    left = 1
    right = n
    for _ in range(m):
        l, r = map(int, input().split())
        left = max(left, l)
        right = min(right, r)
        
    print(max(0, right - left + 1))
   
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

string A, B;

int main() {
  cin >> A >> B;
  if (A.size() > B.size()) {
    cout << "GREATER";
  } else if (A.size() < B.size()) {
    cout << "LESS";
  } else {
    rep(i, 0, A.size()) {
      if (A[i] > B[i]) {
        cout << "GREATER";
        return 0;
      } else if (A[i] < B[i]) {
        cout << "LESS";
        return 0;
      }
    }

    cout << "EQUAL";
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    long long count =0;
    for(int i=0;i<N;i++){
        long long a;
        cin >>a;
        for(;;){
            if(a%2==1){
                break;
            }
            else {
                a/=2;
                count++;
            }
        }
    }
    cout <<count<<endl;
}

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

const int x1[]={1, 0, -1, 0};
const int y1[]={0, -1, 0, 1};
const int x2[]={1,  1, -1, -1};
const int y2[]={1, -1, -1,  1};
const int x3[]={2, 0, -2, 0};
const int y3[]={0, -2, 0, 2};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int paper[10][10]={};
    int x, y, s;
    while(cin>>x){
        cin.ignore();
        cin>>y;
        cin.ignore();
        cin>>s;
        ++paper[y][x];
        int nx, ny;
        for(int i=0; i<4; i++){
            nx=x+x1[i];
            ny=y+y1[i];
            if(0<=nx&&nx<10&&0<=ny&&ny<10) ++paper[ny][nx];
            if(s>=2){
                nx=x+x2[i];
                ny=y+y2[i];
                if(0<=nx&&nx<10&&0<=ny&&ny<10) ++paper[ny][nx];
            }
            if(s>=3){
                nx=x+x3[i];
                ny=y+y3[i];
                if(0<=nx&&nx<10&&0<=ny&&ny<10) ++paper[ny][nx];
            }
        }
    }
    int max=0, count=0;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            if(paper[i][j]==0) ++count;
            else if(max<paper[i][j]) max=paper[i][j];
        }
    }
    cout<<count<<'\n'<<max<<'\n';
    return 0;
}

Measured memory_bytes: 3052
def ans(a):
    limit = 10**18
    acm=1
    if 0 in a:
        return 0

    for i in a:
        acm *= i
        if acm > limit:
            return -1
    return acm
    
n = int(input())
a = input()
a = list(map(int,a.split()))

print(ans(a))


Measured memory_bytes: 23544
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;




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

string W[] = {"maerd","remaerd","esare","resare"};

int main() {
    string s; cin >> s;
    reverse(ALL(s));
    rep(i, 0, s.size()){
        bool ff = false;
        rep(j, 0, 4){
            string u1 = s.substr(i, 5);
            string u2 = s.substr(i, 6);
            string u3 = s.substr(i, 7);
            // co(u1);
            // co(u2);
            // co(u3);
            bool f = false;
            if(u1 == W[0] || u1 == W[2]){
                ff = true;
                i += 4; 
                break;
            }
            if(u2 == W[3]){
                ff = true;
                i += 5;
                break;
            }
            if(u3 == W[1]){
                ff = true;
                i += 6;
                break;
            }
        }
        if(!ff){
            co("NO");
            return 0;
        }
    }
    co("YES");

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int mtrx[n][m];
	int vctr[m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> mtrx[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		cin >> vctr[i];
	}
	int ans[n];
	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			sum += mtrx[i][j] * vctr[j];
		}
		ans[i] = sum;
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] << "\n";
	}
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(){
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	int count,count2;
	
	count = 0;
	count2 = 0;
	
	for(count = a ; count <= b ; count++){
	
		if(c % count == 0){
			count2 = count2 + 1;
			//count2 += 1;
			//count2++;
		}
	}
	
	
	printf("%d\n",count2);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;
const double PI = acos(-1.0);

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

    double a,b,x,ans;
    cin >> a >> b >> x;
    double s = x*1.0/a;
    if (a*b/2>=s) {
         ans = atan((b*b)/(2*s));
    }else {
         ans = atan((2*a*b-2*s)/(a*a));
    }
    ans = ans/PI*180;
    printf("%.15f\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    vector<int> one;
    set<int> ene;
    rep(i,m){
        cin >> a >> b;
        if(a==1) one.push_back(b);
        if(b==n) ene.insert(a);
    }
    rep(i,one.size()){
        if(ene.count(one[i])==1){
            cout << "POSSIBLE" << endl;
            return 0;
        } 
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

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



int main(){
    sonic();
    string a;
    R a;
    co(int(a[0]=='1')+int(a[1]=='1')+int(a[2]=='1'));
}


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

template<class T, typename F> struct SparseTable {
private :
    F f;
    T id;
    vector<vector<T>> st;
    vector<int> index;
public :
    SparseTable (const vector<T> &v, const F &f, const T &id) : f(f), id(id) {
        int b = 0;
        while ((1<<b) <= (int)v.size()) b++;
        st.resize(b, vector<T>(1<<b, id));
        for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
        for (int i = 1; i < b; i++) {
            for (int j = 0; j + (1<<i) <= (1<<b); j++) {
                st[i][j] = f(st[i-1][j], st[i-1][j+(1<<(i-1))]);
            }
        }
        index.resize((int)v.size() + 1);
        for (int i = 2; i < (int)index.size(); i++) {
            index[i] = index[i>>1] + 1;
        }
    }

    inline T query (int l, int r) {
        assert(l <= r);
        if (l == r) return id;
        int b = index[r-l];
        return f(st[b][l], st[b][r-(1<<b)]);
    }

};

template<typename T> inline T GCD(T a, T b) {
    if (b == 0) return a;
    if (a % b == 0) return b;
    return (GCD(b, a % b));
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    auto f = [] (int a, int b) { return GCD(a, b); };
    SparseTable<int, decltype(f)> st(a, f, 0);
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, GCD(st.query(0, i), st.query(i+1, n+1)));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9856
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(N):
  x = x-a[i]
  if x>=0:
    ans+=1
  else:
    break
if x>0:
  print(ans-1)
else:
  print(ans)

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

#define ll long long
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define rfo(i,n,a) for(ll i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t,n,i,j;
cin>>t>>n;
  cout<<t*n<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
#define MOD 1000000007
ll cnt[100010];
int main() {
  int N; cin >> N;
  int A[100010];
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    cnt[A[i]]++;
  }

  if ( N == 1 ) {
    cout << 1 << endl;
    return 0;
  } else if ( N == 2 ) {
    cout << 2 << endl;
    return 0;
  } else if ( N == 3 ) {
    if ( abs(A[0]-A[1]) == A[2] ||
	 abs(A[1]-A[2]) == A[0] ||
	 abs(A[2]-A[0]) == A[1]  ) 
      cout << 2 << endl;
    else cout << 0 << endl;
    return 0;
  }

  if ( N % 2 == 0 ) {
    bool f = true;
    for ( int i = 0; i < 100000; i++ ) {
      if ( cnt[i] % 2 == 1 ) f = false;
    }
    int ans = 1;
    if(f) {
      for ( int i = 0; i < 100000; i++ ) {
	if ( cnt[i] >=2 ) {
	ans *= cnt[i];
	ans %= MOD;
	}
      }
      cout << ans << endl;
      return 0;
    }
  } else {
    bool f = true;
    if ( cnt[0] % 2 == 0 ) f = false;
    for ( int i = 1; i < 100000; i++ ) {
      if ( cnt[i] > 0 && cnt[i] % 2 == 1 ) f = false;
    }
    int ans= 1;
    if(f) {
      for ( int i = 0; i < 100000; i++ ) {
	if ( cnt[i] > 0 ) {
	  ans *= cnt[i];
	  ans %= MOD;
	}
      }
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1408
n, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    w, v = list(map(int, input().split()))
    for j in range(W + 1):
        if w > j:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])
print(dp[n][W])


Measured memory_bytes: 119916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    s = r.readLine();
    // int t = Integer.parseInt(sl[1]);
    //
    // for(int i = 0; i < n; i++)
    // {
    // s = r.readLine();
    // sl = s.split(" ");
    // time[i] = Integer.parseInt(sl[0]);
    // deli[i] = Integer.parseInt(sl[1]);
    // }
    //
    // int dp[][] = new int[3001][3001];
    //
    // for(int i = 1; i <= t; i++)
    // {
    // dp[i][0] = deli[0];
    // }
    //
    // for(int j = 0; j <= n; j++)
    // {
    // for(int i = time[j]; i <= t; i++)
    // {
    // dp[i][j] = Math.max(dp[i - time[j]][j - 1] + deli[j], dp[i - 1][j]);
    // }
    // }

    int d[] = new int[n];
    for (int i = 0; i < n; i++)
    {
      d[i] = s.charAt(i) - '0';
    }

    boolean b[] = new boolean[10];
    boolean b2[] = new boolean[100];
    boolean f[] = new boolean[1000];

    b[d[0]] = true;
    for (int i = 1; i < n; i++)
    {
      for (int j = 0; j < 100; j++)
      {
        f[j * 10 + d[i]] |= b2[j];
      }

      for (int j = 0; j < 10; j++)
      {
        b2[j * 10 + d[i]] |= b[j];
      }
      b[d[i]] = true;
    }

    int c = 0;
    for (int j = 0; j < 1000; j++)
    {
      if (f[j])
        c++;
    }

//    for (int j = 0; j < 100; j++)
//    {
//      System.out.println(Integer.valueOf(j).toString() + ": " +  b2[j]);
//    }

    System.out.println(c);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 27804
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()

    val pq: PriorityQueue<Long> = PriorityQueue(n, Collections.reverseOrder())
    sc.asSequence().take(n).map(String::toLong).toCollection(pq)

    (1..m).asSequence().forEach {
        val x = pq.poll()
        pq.add(x / 2)
    }
    println(pq.asSequence().sum())
}


Measured memory_bytes: 54920
#include<stdio.h>

int main(void){
	
	int n,i;
	int A[1000];
	
	scanf("%d",&n );
	
	for(i=0;i<n;i++){
		
		scanf("%d",&A[i]);
	
	}
	
	for(i=n-1;i>=0;i--){
		if(i>0){
			printf("%d ",A[i]);
		}else{
			printf("%d",A[i]);
		}
	}
		
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>

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

long long lcm(long long x,long long y){
  return x/gcd(x,y)*y;
}

int main(void){
  long long a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

  a--;

  printf("%lld\n",b-a-(b/c+b/d-b/lcm(c,d)-(a/c+a/d-a/lcm(c,d))));

  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int ans = 0;
	int t = INF;
	int H;
	int c = 0;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> H;
		if (H > t)
		{
			chmax(ans, c - 1);
			c = 0;
		}
		c++;
		t = H;
		if (i == N - 1)
		{
			chmax(ans, c - 1);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
r = [0] * 10001
for x in range(100):
    x += 1
    for y in range(100):
        y += 1
        for z in range(100):
            z += 1
            i = x*x+y*y+z*z+x*y+y*z+z*x
            if i <= 10000:
                r[i] += 1

for i in range(N):
    i += 1
    print(r[i])

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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}
template<typename T>
int UBS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}

	if (mas[l] >= val)
		return l;
	if (mas[r] >= val)
		return r;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

vector<ll> dp(1000000 + 100,-1);

ll f(ll n){
	if(n%2 == 0){
		if(dp[n/2] == -1)
		{
			dp[n / 2] = 1;
			return n / 2;
		} else return -1;
	} else
	{
		if(dp[3 * n + 1] == -1)
		{	dp[3 * n + 1] = 1;
			return 3 * n + 1;
		} else return -1;
	}

}

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

	ll n;
	cin >> n;
	dp[n] = 1;
	ll count = 1;
	ll last = n;
	while((last = f(last))!= -1){
		++count;
	}
	cout << count + 1;

	return 0;
}

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

int main() {
    int n,m;
    cin>>n;
    map<string,int> mp;
    string s;
    for (int i=0;i<n;i++) {
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    for (int i=0;i<m;i++) {
        cin>>s;
        mp[s]--;
    }
    int mx=0;
    for (auto p:mp) {
        mx=max(mx,p.second);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
vector<string> ans;
map<string,int> m_p;
int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		string s;
		cin>>s;
		m_p[s]++;
	}
	int best=0;
	int cnt=0;
	for(map<string,int>::iterator iter=m_p.begin();iter!=m_p.end();iter++)
	{
		if(iter->nd>best)
		{
			ans.clear();
			ans.pb(iter->st);
			cnt=1;
			best=iter->nd;
		}
		if(iter->nd==best)
		{
			ans.pb(iter->st);
			cnt++;
		}
	}
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	rep(i,ans.size())
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	cout << max(0LL, A - 2 * B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
//ll number[20],used[20];
int main()
{
    ll n,i,a[100000],count,sum=0;
    cin>> n >> count ;
    for(i=0;i<count;i++)
    {
        cin>> a[i];
        sum+=a[i];
    }
    if(sum>=n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 4348
x, y = map(int, input().split())
group = {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1, 4:2, 6:2, 9:2, 11:2, 2:3}
print("Yes" if group[x] == group[y] else "No")

Measured memory_bytes: 3060