akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	int sum = 0;
	int mv = inf, at = -1;
	rep(i, 0, N) {
		cin >> A[i];
		sum += A[i];
	}
	rep(i, 0, N) {
		if(mv > abs(N * A[i] - sum)) {
			mv = abs(N * A[i] - sum); at = i;
		}
	}
	cout << at << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

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

Measured memory_bytes: 1732
#include <stdio.h>

main()
{
  int K,d;

  scanf("%d",&K);
  if(K%2==0)
    {
      K = K/2;
      printf("%d\n",K*K);
    }
  else
    {
      K = K/2+1;
      printf("%d\n",K*(K-1));
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <cmath>
 

using namespace std;

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

    int n;
    cin >> n;
    
    vector<int64_t> as(n);
    for(auto& a : as)
        cin >> a;

    int64_t final_cost = numeric_limits<int64_t>::max();
    
    for(int initial_sgn = -1; initial_sgn <= 1; initial_sgn += 2)
    {
        int64_t cost = 0;
        int64_t s = 0;
    
        for(int i = 0; i < n; ++i)
        {
            s += as[i];
            const int sgn = i % 2 == 0 ? initial_sgn : -initial_sgn;
            if(s * sgn > 0)
                continue;
            const auto d = abs(s) + 1;
            cost += d;
            s += sgn * d;
        }
        
        final_cost = min(final_cost, cost);
    }
    
    cout << final_cost << '\n';
    
    return 0;
}


Measured memory_bytes: 1024
using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int mx=0,mn=1000,s=0;
		for(int i=0;i<n;i++){
			cin>>t,s+=t;
			if(t>mx)mx=t;
			if(t<mn)mn=t;
		}
		cout<<(s-mx-mn)/(n-2)<<endl;
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int e[10][10];

//[lx, rx] [ty, dy]
int getCap(int lx, int rx, int ty, int dy) {
    int out = iINF, inside = 0;
    for (int i = lx; i <= rx; i++) {
        out = min(out, e[ty][i]);
        out = min(out, e[dy][i]);
    }
    for (int i = ty; i <= dy; i++) {
        out = min(out, e[i][lx]);
        out = min(out, e[i][rx]);
    }

    for (int x = lx + 1; x < rx; x++) {
        for (int y = ty + 1; y < dy; y++) {
            inside = max(inside, e[y][x]);
        }
    }

    if (out > inside) {
        int res = 0;
        for (int x = lx + 1; x < rx; x++) {
            for (int y = ty + 1; y < dy; y++) {
                res += (out - e[y][x]);
            }
        }
        return res;
    } else {
        return 0;
    }
}

void solve(int height, int width) {
    REP(i, height) { REP(j, width) cin >> e[i][j]; }
    int ans = 0;
    for (int lx = 0; lx < width - 2; lx++) {
        for (int rx = lx + 2; rx < width; rx++) {
            for (int ty = 0; ty < height - 2; ty++) {
                for (int dy = ty + 2; dy < height; dy++) {
                    ans = max(ans, getCap(lx, rx, ty, dy));
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    int d, w;
    while (cin >> d >> w && d) {
        solve(d, w);
    }
}


Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <string>

using namespace std;

int main(){
  long long int n,m,i,j,k;
  cin >> n;
  bool flag=false;
  for(i=0;i<n;i++){
    cin >> m;
    if(m%2==1)flag = true;
  }
  if(flag)cout << "first"  << endl;
  else cout << "second" << endl;
  return 0;
}


Measured memory_bytes: 256
def fact(n):
  if n==1:
    return 1
  else:
    c=1
    for i in range(1,n+1):
      c=(c*i)%(10**9+7)
    return c
n,m=map(int,input().split())
if n==m:
  print((2*(fact(n)**2))%(10**9+7))
elif abs(n-m)==1:
  print(fact(n)*fact(m)%(10**9+7))
else:
  print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	vector<vector<ll> > arr(n,vector<ll>(3));
	for(int i=0;i<n;i++)
	{
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	vector<vector<ll> > dp(n,vector<ll>(3,0));
	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					dp[i][k] = max(dp[i][k],dp[i-1][j]+arr[i][k]);
				}
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;;
	
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
    int X ;
    cin >>X;
    vector < bool > expo (X +1);
    expo [1] = 1;
    for ( int b =2; b <= X; b ++)
    {
        int v = b*b ;
        while (v <= X )
        {
            expo [v] = 1;
            v *= b ;
        }
    }
    for ( int i =X; i >=1; i --)
        if ( expo [i])
        {
            cout <<i << endl ;
            return 0;
        }
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int n, m; cin >> n >> m;
    vector<P> key;
    rep(i, m) {
        int a, b; cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c; cin >> c;
            --c;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }
    vector<int> dp(1 << n, inf/2);
    dp[0] = 0;
    rep(s, 1 << n) {
        rep(i, m) {
            int t = s | key[i].fi;
            int cost = dp[s] + key[i].se;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == inf/2) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
int main(){
 string s,w;
 cin>>s>>w;
 reverse(s.begin(),s.end());
 reverse(w.begin(),w.end());
 int ls=s.length();
 int lw=w.length();
 for(int i=1;i<=ls;i++){
   for(int j=1;j<=lw;j++){
       if(s[i-1]==w[j-1])
       dp[i][j]=dp[i-1][j-1]+1;
       else
       dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
   }
}
int len=dp[ls][lw];
for(int i=lw;i>=1;i--){
	for(int j=ls;j>=1;j--)
	if(s[j-1]==w[i-1]&&dp[j][i]==len){
		cout<<s[j-1];
		len--;
		break;
	}
}
cout<<endl;
return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; else return gcd(b, a % b); }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
template <class T> bool amax(T &x, T y) { if (x < y) { x = y; return 1; } else return 0; }
template <class T> bool amin(T &x, T y) { if (x > y) { x = y; return 1; } else return 0; }
template <class T> i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template <class T> i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }

int main() {
  ioinit();
  int a, b, q;
  cin >> a >> b >> q;
  vi64 s(a + 2), t(b + 2);
  s[0] = t[0] = -1e18, s[a + 1] = t[b + 1] = 1e18;
  reps(i, a) cin >> s[i];
  reps(i, b) cin >> t[i];
  rep(i, q) {
    i64 x;
    cin >> x;
    int sr = ubi(s, x), sl = sr - 1;
    int tr = ubi(t, x), tl = tr - 1;
    i64 ans = 1e18;
    amin(ans, abs(x - s[sl]) + abs(s[sl] - t[tl]));
    amin(ans, abs(x - t[tl]) + abs(t[tl] - s[sl]));
    amin(ans, abs(x - s[sr]) + abs(s[sr] - t[tr]));
    amin(ans, abs(x - t[tr]) + abs(t[tr] - s[sr]));
    amin(ans, abs(x - s[sl]) + abs(x - t[tr]) * 2);
    amin(ans, abs(x - s[sr]) + abs(x - t[tl]) * 2);
    amin(ans, abs(x - t[tl]) + abs(x - s[sr]) * 2);
    amin(ans, abs(x - t[tr]) + abs(x - s[sl]) * 2);
    cout << ans << '\n';
  }
  return 0;
}


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


int main()
{
	ll Q,H,S,D;
	cin>>Q>>H>>S>>D;
	ll N;
	cin>>N;
	vector<ll> bottle(3);
	bottle[0]=min(Q*2,H);
	bottle[1]=min(bottle[0]*2,S);
	bottle[2]=min(bottle[1]*2,D);
	cout<<N/2*bottle[2]+(N%2)*bottle[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	N = s.size() - 1;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)puts("Yes");
	else {
		if (abs(a - b) <= d&&abs(c - b) <= d)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))


tmpxor = 0
tmpadd = 0
ans = 0
minindex = 0
maxindex = 0
for e,i in enumerate(A):
    tmpadd += i
    tmpxor ^= i
    maxindex = e
    if tmpxor != tmpadd:
        while tmpxor != tmpadd and minindex < e:
            tmpxor ^= A[minindex]
            tmpadd -= A[minindex]
            minindex += 1
            # ans += 1
    ans += maxindex - minindex + 1


        # if tmpxor != tmpadd:
        #     maxindex -= 1
    # ans += maxindex - minindex + 1
print(ans)

Measured memory_bytes: 25684
n = int(input())
p = list(map(int, input().split()))
x = [False for i in range(n+1)]

for i in range(n):
    if p[i] == i+1:
        x[i] = True

cnt = 0
i = 0
while i<n:
    if x[i]:
        cnt += 1
        i += 1
    i += 1
print(cnt)


Measured memory_bytes: 14008
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,W;
  cin >> N >> W;
  ll N_MAX=110;
  ll V_MAX=100100;
  ll w[N_MAX],v[N_MAX];
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  ll weight_MAX=1000000111;
  ll dp[N_MAX][V_MAX];
  for(int i=0;i<N_MAX;i++){
    for(int j=0;j<=V_MAX;j++){
       dp[i][j]=weight_MAX;
    }
  }
  //for(int j=0;j<=100000;j++){
    dp[0][0]=0;
  //}
  for(int i=0;i<N;i++){
    for(int j=0;j<V_MAX;j++){
      if(dp[i][j]>weight_MAX){
        dp[i][j]=weight_MAX;
        continue;
      }
      if(j-v[i]<0)dp[i+1][j]=min(dp[i][j],dp[i][0]+w[i]);
      else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
    }
  }
  ll ans=0;
  /*for(int i=0;i<V_MAX;i++){
    if(dp[N][i]<=W) ans=i;
  }*/

  for(ll j=V_MAX;j>=0;j--){
    if(dp[N][j]<=W){
      if(j<=ans)break;
      ans=max(j,ans);
    }
  }
  cout << ans << endl;
  return 0;
}



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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 2e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
string next(string s){
    int i = s.size() - 1;
    bool parsi = false;
    for(; i>0; i--){
        if(s[i] == '9') continue;
        if( abs( (s[i-1] - '0') -  (s[i] - '0' + 1) ) <=  1){
            s[i]++;
            parsi = true;
            break;
        }
    }
    string ret;
    if(!parsi){
        if(s[0] != '9'){
            s[0]++;
            for(int i=1; i<s.size(); i++) s[i] = max(char(s[i-1] - 1), '0');
            return s;
        }
        ret.pb('1');
        for(i=0; i<s.size(); i++) ret.pb('0');
    }
    else{
        ret = s;
        i++;
        for(; i<s.size(); i++) ret[i] = max(char(ret[i-1] - 1), '0');
    }
    return ret;
}

int main(){

    fastio;
    int k;
    cin>>k;
    if(k == 1) cout<<1<<"\n";
    else{
        k--;
        string num = "1";
        while(k--) num = next(num);
        cout<<num<<"\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m;
	int x[20],y[20],l;
	bool d[20];
	char e;
	while(true){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i];
			d[i]=true;
		}
		int w=10,h=10;
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>e>>l;
			if(e=='N'){
				for(int j=0;j<l;j++){
					h++;
					for(int k=0;k<n;k++)
						if(x[k]==w&&y[k]==h)
							d[k]=false;
				}
			}
			if(e=='E'){
				for(int j=0;j<l;j++){
					w++;
					for(int k=0;k<n;k++)
						if(x[k]==w&&y[k]==h)
							d[k]=false;
				}
			}
			if(e=='S'){
				for(int j=0;j<l;j++){
					h--;
					for(int k=0;k<n;k++)
						if(x[k]==w&&y[k]==h)
							d[k]=false;
				}
			}
			if(e=='W'){
				for(int j=0;j<l;j++){
					w--;
					for(int k=0;k<n;k++)
						if(x[k]==w&&y[k]==h)
							d[k]=false;
				}
			}
		}
		bool nhk=true;
		for(int i=0;i<n;i++)
			if(d[i]==true)
				nhk=false;
		if(nhk==true)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string s,t = "";
    cin >> s >> t;

    t.pop_back();

    if(s == t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        vector<pair<int,int> > v;
        int p, d1, d2;
        for (int i=0; i<n; ++i) {
            cin >> p >> d1 >> d2;
            v.push_back(make_pair(-d1-d2, p));
        }
        partial_sort(v.begin(), v.begin()+1, v.end());
        cout << v[0].second << " " << -v[0].first << endl;
    }
    return 0;
}

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

bool ACGT(char a){
    if(a == 'A' or a == 'T' or a == 'G' or a == 'C'){
        return true;
    }else{
        return false;
    }
}

int main(void){
    string s;
    cin >> s;
    s = s+'q';
    int ans = 0,tmp = 0;
    for(int i=0;i<s.length();i++){
        if(ACGT(s[i]) == true){
            tmp++;
        }else{
            if(ans < tmp){
                ans = tmp;
            }
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int number[6];
int diceTable[101], checkTable[101];

class Dice4 {
public:
	void setLabel(int index, int num) {
		number[index] = num;
		diceTable[num]++;
	}
	void roll(char dst) {
		if (dst == 'E') setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
		else if (dst == 'N') setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
		else if (dst == 'S') setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
		else if (dst == 'W') setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
	}
	bool isValidMember(int inputed[]) {
		for (int i = 0; i < 6; i++) checkTable[inputed[i]]++;
        for (int i = 0; i < 101; i++) {
		    if(diceTable[i] != checkTable[i]) return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]) {
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for (int i = 0; i < 24; i++) {
			roll(order[i]);
			for (int j = 0; j < 6; j++) {
				if (inputed[j] != number[j])
					break;
				if (j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0, int n1, int n2, int n3, int n4, int n5) {
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}
};

int main() {
	Dice4 dice4;
	int N;
    cin >> N;
    int inputTable[N][6];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 6; j++) cin >> inputTable[i][j];
    }

    bool flag = true;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = 0; k < 101; k++) {
                diceTable[k] = 0;
                checkTable[k] = 0;
            }
            int inputed[6];
            for (int k = 0; k < 6; k++) {
                dice4.setLabel(k, inputTable[i][k]);
                inputed[k] = inputTable[j][k];
            }
            if (dice4.isValidMember(inputed) && dice4.isSameDice(inputed)) flag = false;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
int sum(int x,int y,int b,int p){
  return x*b+y*p;
}
int sum2(int x,int y,int b,int p){
  return (x*b+y*p)*4/5;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    int x,y,b,p;
    cin>>x>>y>>b>>p;
    int ans2=2e9;
    int bx,px;
    int ans=sum(x,y,b,p);
    if(b<5||p<2){
      bx=max(5,b);
      px=max(2,p);
      ans2=sum2(x,y,bx,px);
      cout<<min(ans2,ans)<<endl;
      continue;
    }
    int ans3=sum2(x,y,b,p);
    cout<<ans3<<endl;
  }
  return 0;
}

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

int main() {
    int r, g, b, n;
    ll ans = 0;
    cin >> r >> g >> b >> n;
    for (int i = 0; i * r <= n; i++) {
        for (int j = 0; i * r + j * g <= n; j++) {
            if ((n - (i * r + j * g)) % b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

struct task_info
{
	char name[ 11 ];
	int rest_time;
	task_info* next_task;
};
task_info task_data[ 100000 ];

int main( int argc , char** argv )
{
	int task_count;
	int quantum;

	//read n and q
	scanf( "%d %d" , &task_count , &quantum );

	//read name and time
	for( int i = 0 ; i < task_count ; i++ )
	{
		scanf( "%s %d" , &task_data[ i ].name , &task_data[ i ].rest_time );
	}

	//initialize next_task member
	for( int i = 0 ; i < task_count - 1 ; i++ )
	{
		task_data[ i ].next_task = &task_data[ i + 1 ];
	}
	task_data[ task_count - 1 ].next_task = &task_data[ 0 ];

	//first state
	task_info* current_task = &task_data[ 0 ];
	task_info* prev_task = &task_data[ task_count - 1 ];

	//execute!
	int current_time = 0;
	while( 1 )
	{
		//check if current_task complete
		if( current_task->rest_time <= quantum )
		{
			//completed
			current_time += current_task->rest_time;
			printf( "%s %d\n" , current_task->name , current_time );
			if( current_task->next_task == current_task )
			{
				break;
			}
			else
			{
				prev_task->next_task = current_task->next_task;
			}
		}
		else
		{
			//not completed
			current_time += quantum;
			current_task->rest_time -= quantum;
			prev_task = current_task;
		}
		current_task = current_task->next_task;
	}

	return 0;
}

Measured memory_bytes: 2196
#!/usr/bin/env python3

import collections
n = int(input())
d = collections.Counter([int(x) for x in input().split()])
m = int(input())
t = collections.Counter([int(x) for x in input().split()])
for k, v in t.items():
    if d[k] < v:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 55264
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int f[n][10];
    int p[n][11];
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];
    int ans = -10000000000;
    for (int bit = 1; bit < (1 << 10);bit++){//1<<10 = 1024
        int c = 0;
        rep(i,n){
            int d = 0;
            rep(j,10){
                if(f[i][j]&&(bit>>j&1))
                    d++;
            }
            c += p[i][d];
        }
        ans = max(ans, c);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    string takahashi;
    while(true){
        C -= B;
        if(C <= 0){
            takahashi = "Yes";
            break;
        } 
        A -= D;
        if(A <= 0){
            takahashi = "No";
            break;
        }
    }
    cout << takahashi << endl;
}

Measured memory_bytes: 3564
m,k=map(int,input().split())
if k>=2**m or m==k==1:
	print(-1)
elif m==1:
	print("1 1 0 0")
else:
	l=list(range(k))+list(range(k+1,2**m))
	print(*(l+[k]+l[::-1]+[k]))

Measured memory_bytes: 15984
package main

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

func main() {
	O := nextString()
	E := nextString()

	if len(O)-len(E) == 1 {
		E = E + " "
	}

	var pw []byte
	for i := 0; i < len(O); i++ {
		pw = append(pw, O[i], E[i])
	}

	fmt.Printf("%s\n", pw)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 640
while True:
    
    H, W = map(int, input().split())
    
    if H == W == 0:
        break
    
    for i in range(H):
        for j in range(W):
            if i == 0 or i == (H - 1):
                print("#", end = "")
                
            else:
                if j == 0 or j == (W - 1):
                    print("#", end = "")
                    
                else:
                    print(".", end = "")
        
        print("")
        
    print("")


Measured memory_bytes: 7012
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


typedef  long long ll;
int main(){

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    ll X=0,ans = 1000000000000000LL, x = 0;
    vector <ll> a(N);
    REP(i,N){
        cin >> a[i];
        X += a[i];
    }
    REP(i,N-1){
        x+=a[i];
        ans = min(ans,abs(X-2*x));
    }
    cout << ans <<endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PriorityQueue<Long> q = new PriorityQueue<Long>();
        int n = sc.nextInt();
        int max = 1 << n;
        for(int i = 0; i < max; i++){
            q.add(-sc.nextLong());
        }
        ArrayList<Long> now = new ArrayList<Long>();
        Deque<Long> dq = new ArrayDeque<Long>();
        now.add(q.poll());
        for(int i = 0; i < n; i++){
            int roops = 1 << i;
            for(int j = 0; j < roops; j++){
                while(q.size() > 0 && now.get(j) >= q.peek()){
                    dq.add(q.poll());
                }
                if(q.isEmpty()){
                    System.out.println("No");
                    return;
                }
                now.add(q.poll());
            }
            
            while(dq.size() > 0){
                q.add(dq.pollLast());
            }
            Collections.sort(now);
        }
        System.out.println("Yes");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 63368
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int x = in(), y = in(), n = in();
    vector<bool> yoko(x + 1), tate(y + 1);
    yoko[0] = true;
    tate[0] = true;
    int i;
    REP(j, n){
        int a = in(), b = in(), f = in();
        if(f == 1) for(i = 0; i <= a; i++) yoko[i] = true;
        else if(f == 2) for(i = a + 1; i <= x; i++) yoko[i] = true;
        else if(f == 3) for(i = 0; i <= b; i++) tate[i] = true;
        else for(i = b + 1; i <= y; i++) tate[i] = true;
    }

    /*
    int ans_yoko = whole(count_if, yoko, [](bool x){return x == false;});
    if(ans_yoko != 0) ans_yoko += (yoko[0] and yoko[x] ? 1 : 0);
    int ans_tate = whole(count_if, tate, [](bool x){return x == false;});
    if(ans_tate != 0) ans_tate += (tate[0] and tate[y] ? 1 : 0);
    */

    cout <<  whole(count_if, yoko, [](bool x){return x == false;}) * whole(count_if, tate, [](bool x){return x == false;}) << endl;
}

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

int main(){
   string S;
   cin >> S;
   int s_f, s_r;
   s_f = atoi(S.substr(0, 2).c_str());
   s_r = atoi(S.substr(2, 2).c_str());

   if (s_f > 0 && s_f <= 12 && s_r > 0 && s_r <= 12){
      cout << "AMBIGUOUS" << endl;
   } else if (s_f > 0 && s_f <= 12){
      cout << "MMYY" << endl;
   } else if (s_r > 0 && s_r <= 12){
      cout << "YYMM" << endl;
   } else{
      cout << "NA" << endl;
   }
}



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

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

const long long MOD = 1000000007;

int main(){
  int n,mw;
  cin >> n >> mw;
  vector<int> w(n),v(n);
  vector<vector<int>> dp(n+1,vector<int>(mw+1,0));
  rep(i,n) cin >> v.at(i) >> w.at(i);

  rep(i,n){
      rep(j,mw+1){
          if(w.at(i)>j) dp.at(i+1).at(j) = dp.at(i).at(j);
          else{
              dp.at(i+1).at(j) = max(dp.at(i).at(j),dp.at(i+1).at(j-w.at(i))+v.at(i));
          }
      }
  }
  cout << dp.at(n).at(mw) << endl;
}



Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
int a[15];
int main(){
	int n;
	scanf("%d", &n);
	int sum = 0;
	for(int i = 0 ; i < n ; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	for(int i = 0 ; i < n - 1 ; i++)
		sum += a[i];	
	if(sum > a[n - 1])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


// void solve()
// {
//     ll r;
//     cin>>r;
//     // cout<<r<<"\n";
//     ld ans=2.0*3.14159*r;
//     cout<<ans<<"\n"; 
// }

void solve()
{
    ll n,m;
    cin>>m>>n;
    ll i;
    ll a[n];
    ll sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>m)
    {
        cout<<"-1\n";
    }
    else{
        cout<<m-sum<<"\n";
    }
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int N; cin >> N; int cnt[202020] = {};
  rep(i, N-1){
      int a; cin >> a; a--;
      cnt[a]++;
  }
  rep(i, N){
      cout << cnt[i] << endl;
  }
}

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

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            int N = Integer.parseInt(reader.readLine());
            List<Integer> numbers = new ArrayList<>();
            for (int i=0; i<N; i++) {
                numbers.add(i, Integer.parseInt(reader.readLine()));
            }
            List<Integer> sortedNums = new ArrayList<>(numbers);
            Collections.sort(sortedNums, Collections.reverseOrder());
            for (int i=0; i<N; i++) {
                if (numbers.get(i) == sortedNums.get(0)) {
                    System.out.println(sortedNums.get(1));
                }
                else {
                    System.out.println(sortedNums.get(0));
                }
            }
            reader.close();
        }
        catch(Exception e) {}
    }
}

Measured memory_bytes: 64212
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
lim = 10**18
if A[-1] == 0:
    print("0")
    exit(0)
ans = 1
for a in A:
    ans *= a
    if (ans > lim):
        print("-1")
        exit(0)
print(ans)


Measured memory_bytes: 21792
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=min(r[a]/vr[a],r[b]/vr[b]),M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4444
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>

#define MAXE 500000
#define MAXV 100000
#define INF 999999999

using namespace std;

struct edge {
  int to;
  int wt;
  int next;
} E[MAXE];

int LE[MAXV];
int dist[MAXV];
bool known[MAXV];

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

  int n, m, start;
  cin >> n >> m >> start;

  fill(LE, LE + MAXV, -1);
  fill(dist, dist + MAXV, INF);
  fill(known, known + MAXV, false);

  for (int i = 0, src, dst, cost; i < m; ++i) {
    cin >> src >> dst >> cost;
    E[i] = {dst, cost, LE[src]};
    LE[src] = i;
  }

  priority_queue<pair<int, int>> q;

  q.push({0, start});
  dist[start] = 0;

  int u, cost;
  while (!q.empty()) {
    tie(cost, u) = q.top();
    q.pop();
    if (known[u])
      continue;
    known[u] = true;
    for (int i = LE[u]; i != -1; i = E[i].next) {
      if (dist[E[i].to] > dist[u] + E[i].wt) {
        dist[E[i].to] = dist[u] + E[i].wt;
        q.push({-dist[E[i].to], E[i].to});
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    if (dist[i] == INF) {
      cout << "INF\n";
    } else {
      cout << dist[i] << endl;
    }
  }
}


Measured memory_bytes: 10516
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[][] list = new int[N][100];
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			for(int j = 1; j <= 100; j++) {
				list[i][j-1] = (j-a)*(j-a);
			}
		}
		int ans = listCheck(list);
		pw.print(ans);
		pw.close();
	}
	
	public static int listCheck(int[][] list) {
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < 100; i++) {
			int check = 0;
			for(int j = 0; j < list.length; j++) {
				check += list[j][i];
			}
			if(ans > check) {
				ans = check;
			}
		}
		return ans;
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#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(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int V[100010];

void _main() {
    cin >> N;
    int ans = 0;
    REP (i, N) {
        cin >> V[i];
        ans += V[i] - (i + 1);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<double, double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a) int((a).size())
#define pb push_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n)                 \
    for (int vari = 0; vari < (n)-1; ++vari) \
        for (int varj = vari + 1; varj < (n); ++varj)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define found(s, e) ((s).find(e) != (s).end())
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
#define cons make_pair

vector<int> num_to_vec(int x, int base = 10) {
    if (x == 0) return vector<int>{0};
    vector<int> v;
    while (x) {
        int q = x / base, r = x % base;
        v.push_back(r);
        x = q;
    }
    reverse(v.begin(), v.end());
    return v;
}

int solve(int N) {
    vi a = num_to_vec(N, 10);
    int K = a.size();

    int dp[K + 1][2][2][2][2][2][2];
    mset(dp, 0);

    dp[0][0][0][0][0][0][0] = 1;

    rep(i, K) rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(n, 2) rep(o, 2) {
        int lim = j ? 9 : a[i];
        rep(d, lim + 1) {
            bool non357 = n ? (d != 3 && d != 5 && d != 7)
                            : (d != 0 && d != 3 && d != 5 && d != 7);
            dp[i + 1][j || d < lim][k || d == 7][l || d == 5][m || d == 3][n || d][o || non357]
               += dp[i][j][k][l][m][n][o];
        }
    }

    int ans = 0;
    rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) rep(n, 2) rep(o, 2) {
        if (k == 1 && l == 1 && m == 1 && o == 0) ans += dp[K][j][k][l][m][n][o];
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,K = map(int,input().split())

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

T = 0

###Aだけなら何冊読めるか
a = 0
for i in range(N):
    if T + A[i] > K:
        break
    T += A[i]
    a += 1

m = a
count = a
num = 0

while a >= 0 and num < M:
    #print(m,a,T)
    while num < M and K-T >= B[num]:
        T += B[num]
        count += 1
        num += 1
    
    m = max(m,count)

    if a == 0:
        break
    T -= A[a-1]
    a -= 1
    count -= 1

print(m)
    

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

def sumn(x):
    return int((1/2)*x*(x+1))

K3 = N - N%3
K5 = N - N%5
K15 = N- N%15

print(sumn(N)-sumn(K3/3)*3-sumn(K5/5)*5+sumn(K15/15)*15)

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

const int INF = 1000000;

int main(){
    int n;
    cin >> n;
    int b[n + 1];
    b[0] = INF; b[n] = INF;
    for (int i = 1; i < n; i++){
        cin >> b[i];
    }

    long long ans = 0;
    for (int i = 0; i < n; i++){
        ans += min(b[i], b[i + 1]);
    }

    cout << ans << endl;
}

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

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

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==1){
        	System.out.println("Hello World");
        }
        else{
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	System.out.println(a+b);
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[1000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		sort(a,a+i+1);
		for(int i=0;i<n;i++){
			if(i) cout<<" ";
			cout<<a[i];
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int cc = 0;
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        cc += a;
    }
    cc -= n;
    cout << cc << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll e;
int main(){
	while(1) {
		cin >> e;
		if(e == 0) 
			break;


		ll ans = 1000000000000;
		for(ll z = 0;z * z * z <= e;z++) {
			for(ll y = 0; y * y <= e - z * z * z;y++) {
				ll x = e - z * z * z - y * y;
				if(x >= 0) {
					ans = min(ans,x + y + z);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 2988
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(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 > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,m;
  cin>>n>>m;
  cout << (m * 1900 + (n-m) * 100) * (int)pow(2, m) << endl;

  return 0;
}


Measured memory_bytes: 256