akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    int k;
    cin >> k;

    while (a[1] <= a[0]) {
        a[1] *= 2;
        k -= 1;
    }

    while (a[2] <= a[1]) {
        a[2] *= 2;
        k -= 1;
    }

    if (k < 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3648
D, G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]

ans = 1e9
for i in range(1 << D):
  point = 0
  cnt = 0
  for j in range(D):
    if(((i >> j) & 1) == 1):
      point += PC[j][0]*(j+1)*100 + PC[j][1]
      cnt += PC[j][0]
    else:
      tmp = j
  if(point < G):
    x = G - point
    if((PC[tmp][0]-1)*(tmp+1)*100 < x):
      continue
    cnt += -(-x//(100*(tmp+1)))
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private int count2(int v, Map<Integer, Integer> m) {
        if (v % 2 == 1) return 0;
        else if (m.containsKey(v)) return m.get(v);
        else {
            int ret = (count2(v/2, m) + 1);
            m.put(v, ret);
            return ret;
        }
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        Map<Integer, Integer> m = new HashMap<Integer, Integer>();
        m.put(1, 0);
        m.put(2, 1);

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            min = Math.min(min, count2(A[i], m));
        }

        System.out.println(min);

        return;
    }

}

Measured memory_bytes: 21972
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    string S;

    cin >> S;
    for (ll i = 0; i < S.size(); i++)
    {
        cout << "x";
    }
    cout << endl;

    return;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int INF=1e9+10;
int n,a[500010],ans,Q,f[500010],s[500010],cnt,T[2][1000010];
pa q[500010];
void upd(int tp,int l,int r,int rt,int x,int y){
	if (l==r){
		T[tp][rt]=max(T[tp][rt],y);
		return;
	}
	int m=l+r>>1;
	if (x<=m) upd(tp,l,m,rt<<1,x,y);
	else upd(tp,m+1,r,rt<<1|1,x,y);
	T[tp][rt]=max(T[tp][rt<<1],T[tp][rt<<1|1]);
}
int que(int tp,int l,int r,int rt,int L,int R){
	if (l>=L && r<=R) return T[tp][rt];
	int m=l+r>>1,t=-INF;
	if (L<=m) t=max(t,que(tp,l,m,rt<<1,L,R));
	if (R>m) t=max(t,que(tp,m+1,r,rt<<1|1,L,R));
	return t;
}
int main(){
	scanf("%d",&n);
	FOR(i,1,n){
		scanf("%d",&a[i]);
		if (a[i]==0) ++cnt,a[i]=-1;
		s[i]=s[i-1]+a[i];
	}
	scanf("%d",&Q);
	FOR(i,1,Q) scanf("%d%d",&q[i].fi,&q[i].se);
	sort(q+1,q+Q+1);
	FOR(i,0,1) FOR(j,0,1000000) T[i][j]=-INF;
	FOR(j,1,Q){
		f[j]=s[q[j].se]-s[q[j].fi-1];
		if (1<=q[j].fi-1) f[j]=max(f[j],que(0,1,n,1,1,q[j].fi-1)+s[q[j].se]-s[q[j].fi-1]);
		if (q[j].fi<=q[j].se-1) f[j]=max(f[j],que(1,1,n,1,q[j].fi,q[j].se-1)+s[q[j].se]);
		upd(0,1,n,1,q[j].se,f[j]);
		upd(1,1,n,1,q[j].se,f[j]-s[q[j].se]);
		ans=max(ans,f[j]);
	}
	cout<<n-ans-cnt<<endl;
	return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  ll v1 = max(a, b) * max(c, d);
  ll v2 = min(a, b) * max(c, d);
  ll v3 = max(a, b) * min(c, d);
  ll v4 = min(a, b) * min(c, d);

  ll ans = max(max(max(v1, v2), v3), v4);

  if (a <= 0 && b >= 0 || c <= 0 && d >= 0) {
    ans = max(ans, 0LL);
  }

  cout << (ans) << endl;
}


Measured memory_bytes: 3800
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,u,o,a,b,s[200000],t[200000],MAX=2;
vector<ll>v[200000];
queue<ll>que;
int main(void){
    cin>>n>>u>>o;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    s[u-1]=1;
    t[o-1]=1;
    que.push(o-1);
    while(!que.empty()){
        ll q=que.front();
        que.pop();
        for(auto x:v[q]){
            if(t[x]==0){
                t[x]=t[q]+1;
                que.push(x);
            }
        }
    }
    que.push(u-1);
    while(!que.empty()){
        ll q=que.front();
        que.pop();
        for(auto x:v[q]){
            if(s[x]==0){
                s[x]=s[q]+1;
                que.push(x);
            }
        }
    }
    
    for(int i=0;i<n;i++){
        //cout<<s[i]<<" "<<t[i]<<endl;
        if(t[i]>s[i]){
            MAX=max(MAX,t[i]);
        }
    }
    cout<<MAX-2<<endl;
    
    
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}
/* ここからコード開始 */

vector<vector<ll>> ab;
ll D{}, S{};

void distant(ll ko, ll oya, ll distance){
  D = max(distance, D);
  if(D == distance) S = ko;
  for(auto&& mago : ab[ko]){
    if(oya == mago) continue;
    distant(mago, ko, distance + 1);
  }
}

int main(){
  kyopro;
  ll N;
  cin >> N;
  ab.assign(N, vector<ll>(0));
  rep(i, 0, N-1){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    ab[a].push_back(b);
    ab[b].push_back(a);
  }
  distant(0, -1, 0);
  distant(S, -1, 0);
  if(D % 3 == 1) cout << "Second" << rt;
  else cout << "First" << rt;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin>>n>>m;
	ll p[m],y[m];
	vector<ll>py[n+1];
	for(int i=0;i<m;i++)cin>>p[i]>>y[i];


	for(int i=0;i<m;i++)py[p[i]].push_back(y[i]);
	for(int i=0;i<n;i++)sort(py[i+1].begin(),py[i+1].end());
	for(int i=0;i<m;i++){
		printf ("%012lld\n",ll(p[i])*1000000+ int(lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i])-py[p[i]].begin())+1);
	}

/*	for(int i=0;i<m;i++){
		printf("%lld\n",*lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i]));
	}*/
	//	for(int i=0;i<m;i++)num[y[i]]=i;
	//sort(y,y+m);
	 /*for( vector<ll>::iterator i=begin(py);i!=end(py);++i) {
	      std::cout << i << std::endl;
	   }*/
}


Measured memory_bytes: 8576
#include<stdio.h>
int main()
{
   int n,m,i,T[100],P[100],X[100],t[100],sum=0;
   scanf("%d",&n);
   if(1<=n && n<=100)
    {
       for(i=0;i<n;i++) {
        scanf("%d",&T[i]);

       if(1<=T[i] && T[i]<=100000) sum = sum + T[i] ;
       }
    scanf("%d",&m);
    if(1<=m && m<=100)
        {
    for(i=0;i<m;i++)  {
            scanf("%d %d",&P[i],&X[i]);
            if(P[i]>=1 && P[i]<=100 && X[i]>=1 && X[i]<=100000) t[i]=sum - T[P[i]-1] + X[i];
            }
        }
   }
   for(i=0;i<m;i++) printf("\n%d",t[i]);
return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

bool flag =true;

int main(){
  ll n;
  cin >> n;
  string w[200];

  rep(i,n){
    cin >>w[i];
    if(i>0){
      if(w[i][0]!=w[i-1][w[i-1].size()-1])flag=false;
      rep(j,i){
        if(w[i]==w[j])flag=false;
      }
    }
  }
  if(flag)cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	if(b>=a)
      	cout<<a*c;
  	if(b<a)
      	cout<<b*c+(a-b)*d;
  	return 0;
}

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

int main(void)
{

    int n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for (int i = 1; i < n; i++)
    {
        v[i] = (v[i - 1] + v[i]) / 2;
    }
    cout << v[n - 1] << endl;
    ;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

void solve(){
  int n; cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << 2 * n << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
// Problem : B - Digits
// Contest : AtCoder - AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n,b;
	rd(n,b);
	n+=1;
	for(int i=1;;i++)
	{
		if(pow(b,i)>=n)
		{
			pp(i);
			return ;
		}
	}	
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 4084
object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        for(i <- 1 to n) {
            val list = List.fill(10)(sc.nextInt)
            println(solve(list))
        }
    }
    def solve(list: List[Int]): String = {
        var a = 0
        var b = 0
        var f = true
        for(i <- 0 to 9) {
            if(list(i) < a && list(i) < b) {
                f = false
            }
            else if(a < list(i) && list(i) < b) a = list(i)
            else if(list(i) < a && b < list(i)) b = list(i)
            else if (a < b) b = list(i)
            else a = list(i)
        }
        if(f) "YES"
        else "NO"
    }
}

Measured memory_bytes: 44788
#include<stdio.h>
#define MAX 1400
struct rect {
  int height;
  int pos;
};
int buffer[MAX][MAX], table[MAX][MAX];
int large_rectangle(int w, int *t);
int main(void)
{
  int i, j, h, w, max = 0;
  scanf("%d%d", &h, &w);
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      scanf("%d", &buffer[i][j]);
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (buffer[i][j]) table[i][j] = 0;
      else table[i][j] = (i > 0) ? table[i-1][j] + 1 : 1;
    }
  }
  for (i = 0; i < h; i++) {
    int temp = large_rectangle(w, table[i]);
    if (max < temp) max = temp;
  }
  printf("%d\n", max);
}
int large_rectangle(int w, int *t)
{
  int i, sp = 0, max = 0;
  struct rect stack[MAX];
  t[w] = 0;
  for (i = 0; i <= w; i++) {
    struct rect r;
    r.height = t[i];
    r.pos = i;
    if (!sp || stack[sp-1].height < r.height) stack[sp++] = r;
    else if (stack[sp-1].height > r.height){
      int target = i;
        while (sp && stack[sp-1].height >= r.height) {
        struct rect pre = stack[(sp--)-1];
          int area = pre.height * (i - pre.pos);
          if (max < area) max = area;
          target = pre.pos;
        }
        r.pos = target;
        stack[sp++] = r;
    }
  }
  return max;
}


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

const int MAXV = 15;

int d[MAXV][MAXV];
int dp[1<<MAXV][MAXV];
 
int main(){
    
    int V, E;
    cin >> V >> E;

    memset(d,-1,sizeof(d));
    for (int i=0; i<E; i++){
        int s, t, _d;
        cin >> s >> t >> _d;
        d[s][t] = _d;
    }

    for(int i=0; i<V-1; i++){
        if (d[V-1][i] >= 0) dp[1<<i][i] = d[V-1][i];
        else                dp[1<<i][i] = -1;
    }

    for(int i=0; i<(1<<V-1); i++){
        if (!(i&(i-1))) continue;
        
        for(int j=0; j<V-1; j++){
            if(!((i>>j)&1)) continue;
            
            dp[i][j] = -1;
            int p = i^(1<<j);
            for(int k=0; k<V-1; k++){
                if(!(p>>k&1) || d[k][j] < 0 || dp[p][k] == -1) continue;
                
                if (dp[i][j] == -1 || dp[i][j] > dp[p][k] + d[k][j]) dp[i][j] = dp[p][k]+d[k][j];
            }
        }
    }

    int b = -1;
    for(int i=0; i<V-1; i++){
        if(d[i][V-1] < 0 || dp[(1<<V-1)-1][i] == -1) continue;
        
        if (b == -1 || b > dp[(1<<V-1)-1][i] + d[i][V-1]) b=dp[(1<<V-1)-1][i]+d[i][V-1];
    }

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 2124
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
broke = []
for j in range(m):
    broke.append(ii())
if n > 1:
    num = [1]
    if len(broke) and broke[0] == 1:
        num.append(0)
        broke.pop(0)
    else:
        num.append(1)

    for i in range(2,n+1):
        if len(broke) and broke[0] == i:
            num.append(0)
            broke.pop(0)
        else:
            num.append((num[-1]+num[-2])%1000000007)
    print(num[-1])
else:
    print(1)


Measured memory_bytes: 7084
long long S[4000],u;I[4000],p[4000],N;i,c;main(n){for(;scanf("%d",&n),n;memset(p,N=0,16000)){for(;n--;p[i-1]?S[p[i-1]-1]+=u*c:(I[N]=i,S[N]=u*c,p[i-1]=++N))scanf("%d%lld%d",&i,&u,&c);c=0;for(n=-1;++n<N;)S[n]<1e6||printf("%d\n",c=I[n]);c||puts("NA");}exit(0);}

Measured memory_bytes: 0
import java.util.*;
import java.math.BigInteger;

public class Main {
    static BigInteger fact[] = new BigInteger[51];

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int P = sc.nextInt();
        boolean isEven = P % 2 == 0;
        int numEven = 0, numOdd = 0;
        int A[] = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            if (A[i] % 2 == 0) { numEven++; } else {numOdd++;}
        }
        //System.out.println("even, odd=" + numEven + "  "+ numOdd);

        fact[0] = new BigInteger("1");
        for (int i=1; i<=50; i++) {
            fact[i] = fact[i-1].multiply(BigInteger.valueOf(i));
        }
        
        long ans = 0;
        for (int i=0; i<=N; i++) {
            for (int j=0; j<=i; j++) {
                if (j > numOdd || i-j > numEven) { continue; }
                long count = comb(numOdd, j) * comb(numEven, i-j);
                if (j % 2 != 0 ^ isEven) {
                    ans += count;
                }
                //System.out.println("i, j" + i + ", " + j + " = " + ans);
            }
        }
        System.out.println(ans);
    }

    public static long comb(int n, int k) {
        long retVal = fact[n].divide(fact[k].multiply(fact[n-k])).longValue();
        //System.out.println("comb" + n + ", " + k + " = " + retVal);
        return retVal;
    }
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b,k;
  cin >>a>>b>>k;
  int i = 0;
  while(true){
    if((a<=i&&i<a+k)||(max(a,b-k)<i&&i<=b)){
      cout << i << endl;
    }
    i++;
    if(i>b){
      break;
    }
  }
}      
    


Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<functional>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;
typedef pair<int,int> miria;

int N;
int h[102];

bool sum_zero(int m){
  int s=0;
  for(int i=0;i<m;i++){
    s+=h[i];
  }

  return s == 0;
}

int main(){
  int c=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  h[N] = 0;
  int flag = 0;

  if(sum_zero(N)){
    cout << c << endl;
    return 0;
  }

  while(flag==0){
    int left = 0;
    while(h[left]==0){
      left++;
    }
    int right = left;
    while(h[right]!=0){
      right++;
    }
    //cout << left << " " << right << endl;
    for(int i=left;i<right;i++){
      //cout << "miria" << i << endl;
      h[i]--;
    }
    c++;
    //cout << c << endl;
    if(sum_zero(N)){
      flag = 1;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    string s,s1;
    cin>>s;
    s1=s;
    reverse(s.begin(),s.end());
    if(s1==s)
    {
        string a=s.substr(0,(s.size()-1)/2);
        string a1=a;
        reverse(a.begin(),a.end());
        if(a==a1)
        {
            string b=s.substr((s.size()+3)/2-1,s.size());
            string b1=b;
            reverse(b.begin(),b.end());
            if(b==b1)
            {
                printf("Yes\n");
                return 0;
            }

        }
    }

    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main()
{
  queue<int> answer;
  int w,h;
  while(cin >> w >> h && !(w == 0 && h == 0)){
    vector< vector<int> > tatewall(h,vector<int>(w + 1,1)),yokowall(h + 1,vector<int>(w,1));
    for(int j = 1;j <= w - 1;++j) cin >> tatewall[0][j];
    for(int i = 1;i <= h - 1;++i){
      for(int j = 0;j < w;++j) cin >> yokowall[i][j];
      for(int j = 1;j <= w - 1;++j) cin >> tatewall[i][j];
    }
    vector< vector<int> > P(w*h);
    for(int i = 0;i < w*h;++i){
      if(yokowall[(int)(i/w)][i%w] == 0) P[i].push_back(i - w);
      if(tatewall[(int)(i/w)][i%w] == 0) P[i].push_back(i - 1);
      if(tatewall[(int)(i/w)][i%w + 1] == 0) P[i].push_back(i + 1);
      if(yokowall[(int)(i/w) + 1][i%w] == 0) P[i].push_back(i + w);
    }
    queue<int> Q;
    vector<int> check(w*h,0),D(w*h,0);
    int cur,dst;
    Q.push(0);
    D[0] = 1;
    check[0] = 1;
    while(!Q.empty()){
      cur = Q.front();
      for(int i = 0;i < P[cur].size();++i){
	dst = P[cur][i];
	if(check[dst] == 0){
	  Q.push(dst);
	  D[dst] = D[cur] + 1;
	  check[dst] = 1;
	}
      }
      Q.pop();
    }
    answer.push(D[w*h - 1]);
  }
  while(!answer.empty()){
    cout << answer.front() << endl;
    answer.pop();
  }
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a * 100 + b * 10 + c;
  if (ans % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	String str;
	try{
	    InputStreamReader is = new InputStreamReader(System.in);
	    BufferedReader br = new BufferedReader(is);
	    int[] n = new int[6];
	    double x,y;
	    str = br.readLine();
	    while(str !=null){
		String[] strary = str.split(" ");
		for(int i=0;i<6;i++){
		    n[i] = Integer.parseInt(strary[i]);
		}
		x=(n[2]*n[4]-n[1]*n[5])/(double)((n[0]*n[4]-n[1]*n[3]));
		y=(n[0]*n[5]-n[2]*n[3])/(double)((n[0]*n[4]-n[1]*n[3]));
		if(x == -0.0)
		    x = 0.0;
		if(y == -0.0)
		    y = 0.0;
		System.out.printf("%4.3f %4.3f\n",x,y);
		str = br.readLine();
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i < abs(sx - tx); ++i) cout << "R";
	for (int i = 0; i < abs(sy - ty); ++i) cout << "U";
	for (int i = 0; i < abs(sx - tx); ++i) cout << "L";
	for (int i = 0; i < abs(sy - ty); ++i) cout << "D";
	cout << "D";
	for (int i = 0; i < abs(sx - tx) + 1; ++i) cout << "R";
	for (int i = 0; i < abs(sy - ty) + 1; ++i) cout << "U";
	cout << "LU";
	for (int i = 0; i < abs(sx - tx) + 1; ++i) cout << "L";
	for (int i = 0; i < abs(sy - ty) + 1; ++i) cout << "D";
	cout << "R";
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cunbidun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        private InputReader in;
        private PrintWriter out;
        private PrinterUtil printer;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            this.printer = new PrinterUtil(out);
            String s = in.nextString();
            if (s.charAt(0) == s.charAt(1) || s.charAt(1) == s.charAt(2) || s.charAt(2) == s.charAt(3))
                out.print("Bad");
            else out.print("Good");
        }

    }

    static class InputReader extends InputStream {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c;
            while (isSpaceChar(c = read())) ;
            StringBuilder result = new StringBuilder();
            result.appendCodePoint(c);
            while (!isSpaceChar(c = read()))
                result.appendCodePoint(c);
            return result.toString();
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class PrinterUtil {
        private PrintWriter out;

        public PrinterUtil(PrintWriter out) {
            this.out = out;
        }

    }
}



Measured memory_bytes: 23252
#include<iostream>

using namespace std;
int main(){
    int n,a;
    long int max=-1000000,min=1000000,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
        if(max<a){
            max=a;
        }
        if(min>a){
            min=a;
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(){
    int a, b, k;
    int i, cnt = 0, yakusu[100];

    scanf("%d %d %d", &a, &b, &k);

    for(i=1; i<=100; i++){
        if(a % i == 0 && b % i == 0){
            yakusu[cnt] = i;
            cnt++;
        }
    }

    printf("%d\n", yakusu[cnt - k]);

    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(8)]
count = 0
sup = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
        w[i//400] += 1
    elif i >= 3200:
        sup += 1
if count == 0:
    print(1,sup)
elif sup == 0:
    print(count,count)
else:
    b= count+sup
    print(count,b)

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

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

    int n, d;
    cin >> n >> d;

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


    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i+1; j < n; j++) {
            double dist = 0;
            for (int k = 0; k < d; k++) {
            dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if (ceil(sqrt(dist)) == floor(sqrt(dist))) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
arr = [int(x) for x in input().split()]
q = int(input())

d = {}
for x in arr:
    d[x] = d.get(x,0) + 1

tot = sum(arr)

for _ in range(q):
    b,c = [int(x) for x in input().split()]

    if b not in d:
        print(tot)
    else:
        diff = (c-b)*d[b]
        tot+=diff
        print(tot)
        val = d[b]
        del d[b]
        d[c] = d.get(c,0) + val


Measured memory_bytes: 20656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
// Binary Index Treeは長さnの数列に対して
// 1. 区間[a,b)にxを加算する
// 2. 区間[a,b)の総和を求める
// という操作をO(log(n))で処理できる
 
// 区間加算にも対応したBinary Index Tree(1-indexで使うことに気をつける)
template <class Abel> struct BIT {
 
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    BIT(ll n) { 
        init(n);
    }
 
    void init(ll n) { 
        for(ll iter = 0; iter < 2; ++iter) {
            dat[iter].assign(n+1, UNITY_SUM); 
        }
    }
    
    inline void sub_add(ll p, ll a, Abel x) {
        for(ll i = a; i < (ll)dat[p].size(); i += i & -i) {
            dat[p][i] = dat[p][i] + x;
        }
    }
    // 区間[a,b)にxを加算する(a,bは1-index)
    inline void add(ll a, ll b, Abel x) {
        sub_add(0, a, x * -(a - 1)); 
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }
    
    inline Abel sub_sum(ll p, ll a) {
        Abel res = UNITY_SUM;
        for(ll i = a; i > 0; i -= i & -i) {
            res = res + dat[p][i];
        } 
        return res;
    }
    // 区間[a,b)の総和を計算する(a, bは1-index)
    inline Abel getsum(ll a, ll b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};
 
int main() {
    ll n, d, a;
    cin >> n >> d >> a;
 
    vector<P> p(n);
    rep(i, n) {
        ll x, h;
        cin >> x >> h;
        p[i] = make_pair(x, h);
    }
    sort(all(p));
 
    vl x(n), h(n);
    rep(i, n) {
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    
    BIT<ll> biTree(n+10);
    rep(i, n) {
        biTree.add(i+1, i+2, h[i]);  // biTree[i]をh[i]で初期化
    }
    
    ll ans = 0;
    exrep(i, 1, n) {  // BITは1-indexで使う
        ll hp_i = biTree.getsum(i, i+1);  // モンスタiの体力
        if(hp_i <= 0) {  // モンスタiの体力が0以下の場合
            continue;  // モンスタiはおしまい
        }
        ll cnt = (hp_i + a - 1)/a;  // モンスタiを倒すのに必要な操作回数
        //　モンスタiのいる座標を左端とした爆発が届く範囲を求める
        ll right = x[i-1] + 2*d;  // 爆発が届く右端の座標
        ll id = upper_bound(all(x), right) - x.begin();  // 爆発が届かないモンスタの中で最も左にいるモンスタの番号 
        id++;
        biTree.add(i, id, -a*cnt);  // モンスタiからモンスタid-1の体力をa*need減らす
        ans += cnt;
    }
 
    out(ans);
    re0;
}

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

#define up(i,j,k) for (int i = (j); i <= (k); i++)
#define down(i,j,k) for (int i = (j); i >= (k); i--)
#define DEBUG printf("Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) (x).begin(), (x).end()
#define mem(a) memset((a), 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#define int long long

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (int v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

char ch[10000];

signed main () {
    ch[ch['A'] = 'T'] = 'A';
    ch[ch['C'] = 'G'] = 'C';
    putchar(ch[getchar()]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

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

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000009;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T>
vector<vector<T>> dijkstra(const WeightedGraph<T> &G,int source = 0){
	using P = pair<T,pair<int,int>>;
	vector<vector<T>> dist(G.size(),vector<T>(G.size(),INF));
	priority_queue<P,vector<P>,greater<P>> que;
	dist[source][0] = 0;
	que.emplace(dist[source][0],make_pair(source,0));
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second.first,ch = p.second.second;
		if(dist[v][ch] < p.first) continue;
		for(const auto &e : G[v]){
			if(dist[e.to][ch] > dist[v][ch] + e.cost){
				dist[e.to][ch] = dist[v][ch] + e.cost;
				que.emplace(dist[e.to][ch],make_pair(e.to,ch));
			}
			if(ch + 1 < G.size() && dist[e.to][ch + 1] > dist[v][ch]){
				dist[e.to][ch + 1] = dist[v][ch];
				que.emplace(dist[e.to][ch + 1],make_pair(e.to,ch + 1));
			}
		}
	}
	return dist;
}

int n,m,c;

void solve(){
	WeightedGraph<int> G(n);
	for(int i = 0;i < m;i++){
		int a,b,d;
		cin >> a >> b >> d; a--;b--;
		G[a].emplace_back(b,d);
	}
	auto dist = dijkstra(G);
	int ans = INF;
	for(int i = 0;i < n;i++){
		if(dist[n - 1][i] <= c) chmin(ans,i);
	}
	cout << ans << endl;
}

signed main(){
	while(cin >> n >> m >> c,n) solve();
}


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

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if(2*sqrtl(a*b) < c - a - b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n = list(input())

    if (n[0] == n[1] and n[1] == n[2]) or (n[1] == n[2] and n[2] == n[3]):
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
int main(void){
  int i,h,w,flg,x,y;
  int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}},d;
  char m[100][101];

  while(1){
    scanf("%d%d",&h,&w);
    if(!h && !w) break;

    flg=x=y=0;
    for(i=0;i<h;i++){
      scanf("%s",m[i]);
    }

    while(1){
      if(m[y][x]=='.'){
        break;
      }
      else if(m[y][x]==0){
        flg=1;
        break;
      }

      if(m[y][x]=='>') d=1;
      else if(m[y][x]=='<') d=3;
      else if(m[y][x]=='^') d=0;
      else if(m[y][x]=='v') d=2;

      m[y][x]=0;
      y += dir[d][0];
      x += dir[d][1];
    }
    if(!flg) printf("%d %d\n",x,y);
    else printf("LOOP\n");
  }

  return 0;
}

Measured memory_bytes: 0
n = int(input())
aarr = list(map(int, input().split()))
barr = list(map(int, input().split()))

tmparr = aarr[:]
count = 0

for i in range(n):
    if tmparr[i] >= barr[i]:
        count += barr[i]
        tmparr[i] -= barr[i]
    else:
        count += tmparr[i]
#        tmparr[i] = 0
        if tmparr[i+1] >= barr[i] - tmparr[i]:
            tmparr[i+1] -= barr[i] - tmparr[i]
            count += barr[i] - tmparr[i]
        else:
            count += tmparr[i+1]
            tmparr[i+1] = 0

print(count)            

Measured memory_bytes: 18624
n = gets.to_i
a = []
n.times do
  c, num = gets.chomp.split
  case c
  when 'insert'
    a.unshift(num)
  when 'delete'
    idx = a.index(num)
    a.delete_at(idx) if idx
  when 'deleteFirst'
    a.shift
  else
    a.pop
  end
end
puts a.join(" ")


Measured memory_bytes: 78324
/* AOJ 0589 Production */

#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

bool compare_product_name(string a, string b);
void map_test();

typedef bool (*pname_comparator)(string, string);
typedef map<string, int, pname_comparator> mapp;

int
main()
{
    int n;
    mapp production(compare_product_name);
    mapp::iterator it;

    cin >> n;
    cin.ignore();
    while (n--) {
        string line, name;
        int p;
        int delim_pos;

        getline(cin, line);

        delim_pos = line.find_first_of(' ');
        name = line.substr(0, delim_pos);
        p = atoi(line.substr(delim_pos + 1).data());

        if (production.find(name) == production.end())
            production[name] = p;
        else
            production[name] += p;
    }

    for (it = production.begin(); it != production.end(); ++it)
        cout << it->first << ' ' << it->second << endl;

    return 0;
}

bool
compare_product_name(string a, string b)
{
    size_t len_a = a.size();
    size_t len_b = b.size();
    size_t min_len = min(len_a, len_b);
    size_t i;

    if (len_a != len_b)
        return len_a < len_b;

    for (i = 0; i < min_len; i++) {
        if (a[i] != b[i])
            return a[i] < b[i];
    }

    // a == b なので a < b ではない
    return false;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    int sum=0;
    rep(i,n) sum+=a[i];
    if (sum%10!=0){
        cout<<sum<<"\n";
        return 0;
    }
    sort(all(a));
    int idx=0;
    while(idx<n && a[idx]%10==0) idx++;
    if (idx==n){
        cout<<"0\n";
    }else{
        cout<<sum-a[idx]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N;
	cin >> N;

	int A;
	cin >> A;
	int minA = A;
	int maxA = A;
	for (int i = 1; i < N; i++) {
		cin >> A;
		if (A < minA) {
			minA = A;
		}
		else if (A > maxA) {
			maxA = A;
		}
	}

	cout << maxA - minA << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	long long A, B, C, K; std::cin >> A >> B >> C >> K;
	if (K <= A)
		std::cout << K << std::endl;
	else if (A < K && K <= A + B)
		std::cout << A << std::endl;
	else
		std::cout << A - (K - A - B) << std::endl;

	return 0;
}

Measured memory_bytes: 3508
#include<cstdio>
#include<cstdlib>
int n;
long long int sum,min,x;
int a[200000];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	  scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	  sum+=a[i];
	min=labs(sum-2*a[0]);
	for(int i=0;i<n-1;i++)
	{
		x+=a[i];
		if(labs(sum-2*x)<min)
		  min=abs(sum-2*x);
	}
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 896
N = gets.chomp!.to_i
ary = []
sum = 0
actions = []

N.times do |n|
  buf = gets.chomp!.split(' ').map(&:to_i)
  ary.push buf
  actions.push 0
end

# p ary

ary.reverse.each_with_index do |vals, i|
  a = vals[0] + sum
  b = vals[1]

  mod = a % b
  div = a / b
  # p "#{a}(#{vals[0]}) / #{b} = #{div}(#{mod})"
  # p "action is: #{b - mod}"

  if mod != 0
    action = b - mod
    actions[-(i+1)] = action
    sum += action
  end
end

p sum


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

struct Q {
  int a, b, c, d;
};

ll ans = 0;
vector<Q> v;
int n, m, q;

void dfs(int val, int now, vi &a) {
  if(now == n) {
    ll tmpans = 0;
    REP(i, q) {
      if(a[v[i].b] - a[v[i].a] == v[i].c) tmpans += v[i].d;
    }
    chmax(ans, tmpans);
  } else {
    FOR(i, val, m+1) {
      int pre = a[now];
      a[now] = i;
      dfs(a[now], now+1, a);
      a[now] = pre;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n >> m >> q;
  v.resize(q);
  REP(i, q) {
    cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    v[i].a--; v[i].b--;
  }

  vi a(n, 1);

  dfs(1, 0, a);

  cout << ans << endl;


}
























Measured memory_bytes: 3660
<?php
  $line1 = fgets(STDIN);
  $line2 = fgets(STDIN);
  
  $arr1 = str_split($line1);
  $arr2 = str_split($line2);
  
  if($arr1[0]==$arr2[2]&&$arr1[1]==$arr2[1]&&$arr1[2]==$arr2[0]){
   echo "YES";
  }else{
  
  echo "NO";
  }


  ?>

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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
const int dx[4] = { 1,0,-1,0 };
const int sy[4] = { 0,1,0,-1 };

#define atcoder (int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x) x = max(x,y)
#define chmin(x) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int binary(ll a) {
	int cnt = 0;
	while (a) {
		a /= 2;
		cnt++;
	}

	return cnt - 1;
}

int main(){
	
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	if (n <= m/2) {
		ans += n;
		m -= 2 * n;
		ans += m / 4;
	}
	else {
		ans = m / 2;

	}
	pr(ans);

	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
n = int(input())
al = list(map(int,input().split()))

import itertools
ac_al = list(itertools.accumulate(al))

ans = float("inf")  

for a in ac_al[:n-1]:
    tmp = abs((ac_al[-1] - a) - a)
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 23800