akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	long long k,n,m;
	cin>>n>>m>>k;
	vector<long long> v1(n+2,0);
	vector<long long> v2(m+2,0);
	for(int i=1;i<=n;i++){
	    cin>>v1[i];
	    v1[i]+=v1[i-1];
	}
	for(int i=1;i<=m;i++){
	    cin>>v2[i];
	    v2[i]+=v2[i-1];
	}
	int j=m,ans=0;
	for(int i=0;i<=n;i++)
	{
	    if(v1[i]>k) break;
	    while(v2[j]>(k-v1[i]))  j--;
	    ans=max(ans,(i+j));
	}
	cout<<ans;
	return 0;
}

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

int harmony(int A, int B) {
    if ((A + B) % 2 == 1) {
        return 0;
    }

    return (A + B) / 2;
}

int main() {
    int A, B;
    cin >> A >> B;
    
    int ans = harmony(A, B);
    if (ans == 0) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


char str[1024];

int main(void) {
  cin >> str;

  for(int i = 0; str[i] != '\0'; i++) {
    str[i] = str[i] - 3;
    if(str[i] < 'A') str[i] += 'Z' - 'A' + 1;
  }

  cout << str << endl;

  return 0;
}

Measured memory_bytes: 1144
let h, w, c = Scanf.scanf " %d %d" @@ fun a b -> a, b, ref 0
let _ = for i = 0 to h - 1 do for j = 0 to w - 1 do Scanf.scanf " %c" @@ fun a -> if a = '#' then incr c done done; print_endline @@ if !c = h + w - 1 then "Possible" else "Impossible"

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,pos=1,s=0;
struct euphoria{
	int a,b;
}x[100005];
bool cmp(euphoria f,euphoria l){
	return f.a<l.a;
}
priority_queue<int>q;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d%d",&x[i].a,&x[i].b);
	sort(x+1,x+n+1,cmp);
	for(int i=1;i<=m;++i){
		for(;x[pos].a==i&&pos<=n;++pos) q.push(x[pos].b);
		if(!q.empty()) {
			s+=q.top();
			q.pop();
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 1660
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define inf 1e9
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, ll, hash<ll> > ht;

// find_by_order()  // order_of_key
typedef tree<
    int,
    null_type,
    less<long long int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c=c%mod;if(b%2==1) c*=a;c=c%mod;
        return c;
   }
  /* ll mi(ll a,ll m)
   { ll c= power1(a,m-2,mod);

     return c;
   }
*/


  int main()
{    fast;
     ll n,k;cin>>n>>k;
      vector<ll> v(n);
       for(auto &x:v)cin>>x;
        vector<ll> visited(n,-1);
         ll t=0, times=0;
          visited[0]=0;
         while(k>0)
         {
              t=v[t]-1;times++;k--;
              if(visited[t]>=0){break;}

               visited[t]=times;
         }
          if(k<=0){
               cout<<t+1<<endl;return 0;
          }
         times=times-visited[t];
         times=k%times;
         while(times--)
         {
             t=v[t]-1;
         }
         cout<<t+1<<endl;

      return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

struct Edge
{
    int to;
};

using Graph = vector<vector<Edge>>;
using P = pair<long, long>;

/* Lowlink: グラフの関節点・橋を列挙する構造体
    作成 : O(E+V)
    関節点の集合 : vector<int> aps
    橋の集合 : vector<P> bridges
    */
struct Lowlink
{
    const Graph &G;
    vector<int> used, ord, low;
    vector<int> aps; // articlation points
    vector<P> bridges;

    Lowlink(const Graph &G_) : G(G_)
    {
        used.assign(G.size(), 0);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < (int)G.size(); i++)
        {
            if (!used[i])
                k = dfs(i, k, -1);
        }
        sort(aps.begin(), aps.end());
        sort(bridges.begin(), bridges.end());
    }

    int dfs(int id, int k, int par)
    { // id:探索中の頂点, k:dfsで何番目に探索するか, par:idの親
        used[id] = true;
        ord[id] = k++;
        low[id] = ord[id];
        bool is_aps = false;
        int count = 0; //子の数
        for (auto &e : G[id])
        {
            if (!used[e.to])
            { // 子が探索済みかチェック
                count++;
                k = dfs(e.to, k, id);
                low[id] = min(low[id], low[e.to]); // 先と同じlow
                if (par != -1 && ord[id] <= low[e.to])
                    is_aps = true;
                if (ord[id] < low[e.to])
                    bridges.emplace_back(min(id, e.to), max(id, e.to));
            }
            else if (e.to != par) // さっき通ったところとかだと弾かれる
            {                     // eが後退辺の時(dfsでさきっぽまで到達)
                low[id] = min(low[id], ord[e.to]);
            }
        }
        if (par == -1 && count >= -2)
            is_aps = true;
        if (is_aps)
            aps.push_back(id);
        return k;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    Graph G(n);
    int a, b;
    Edge ea, eb;
    rep(i, m)
    {
        cin >> a >> b;
        a--;
        b--;
        ea.to = a;
        eb.to = b;
        G[a].push_back(eb);
        G[b].push_back(ea);
    }
    Lowlink out(G);
    cout << out.bridges.size() << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
dp=[0]*(n+3)
dp[0]=1
for i in range(m):
    dp[int(input())]=-1

for i in range(1,n+1):
    if dp[i]==-1:
        continue 
    else:
        if dp[i-1]!=-1:
            dp[i]+=dp[i-1]
        if dp[i-2]!=-1:
            dp[i]+=dp[i-2]

print(dp[n]%1000000007)

Measured memory_bytes: 462708
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int N;
lint A, B;

int main()
{
    lint now;
    cin >> N >> A >> B >> now;
    lint ans = 0;
    for (int i = 1; i < N; i++)
    {
        lint prev = now;
        cin >> now;
        ans += min(B, A * (now - prev));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n;
ll a[100100], e = 1e18;
int main() {
	ll mul = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", a + i);
	for (int i = 0; i < n; i++)
		if (!a[i])
			mul = 0;

	for (int i = 0; i < n && 0 < mul; i++) {
		if (e / mul < a[i]) {
			mul = -1;
			continue;
		}
		mul *= a[i];
	}
	printf("%lld\n", mul);
}

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

int main(){

    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int csum = 0;
    int psum = 0;
    vector<int> t(m, 0);
    int ans = INT_MAX;
    for (int bit = 0; bit < (1<<n); ++bit) {
        csum = 0;
        for (int ii = 0; ii < m; ++ii) {
            t[ii] = 0;
        }
        for (int i = 0; i < n; ++i) {
            if ((bit>>i) & 1) {
                csum += c[i];
                for (int j = 0; j < m; ++j) {
                    t[j] += a[i][j];
                }
            }
        }
        bool f = true;
        for (int j = 0; j < m; ++j) {
            if (t[j] < x) {
                f = false;
            }
        }

        if (f) {
            ans = min(ans, csum);
        }
    }

    if (ans == INT_MAX) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
} 


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

int s(int n)
{
    int res = 0;
    while (n > 0)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}


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

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

Measured memory_bytes: 256
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
 
int main()
{

	int n;
	scf(n);

	ll ctr=0;

	map<int,int>m;


	rep(i,1,n+1)
	{
		int a;
		scf(a);

		if(i-a>=0)
		ctr+=(m[i-a]);

		m[a+i]++;

	}

	lprin(ctr);
    
}

Measured memory_bytes: 14108
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	
	int m,d;
	cin>>m>>d;
	
	int ans=((d==day[m])?1:0);
	
	cout<<ans<<endl;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  int a[x][y], b[y];
  for (int i = 0; i < x; i++) {
    for (int o = 0; o < y; o++) {
      cin >> a[i][o];
    }
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < x; i++) {
    int p = 0;
    for (int o = 0; o < y; o++) {
      p += a[i][o] * b[o];
    }
    cout << p << endl;
  }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    cout<<n*n*n<<"\n";
}


Measured memory_bytes: 256
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
B = [0 for i in range(N)]
for i in range(N-1):
  B[i] = A[i + 1] - A[i]
B[N - 1] = K - A[N - 1] + A[0]
ans = K - max(B)
print(ans)

Measured memory_bytes: 87372
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	string S[120];
	int P[120] = { 0 };
	int tmp;
	string tmpt;
	int count[120];
	int tmp2;

	for (int i = 1;i < N+1;i++) {
		cin >> S[i];
		cin >> P[i];
		count[i] = i;
	}
	for(int q=0;q<100;q++){
		for (int i = 1;i < N;i++) {
			if (S[i] > S[i + 1]||(S[i]==S[i+1]&&P[i]<P[i+1])) {
				tmpt = S[i];
				tmp = P[i];
				S[i] = S[i + 1];
				P[i] = P[i + 1];
				S[i + 1] = tmpt;
				P[i + 1] = tmp;
				tmp = count[i];
				count[i] = count[i + 1];
				count[i + 1] = tmp;
			}
		}
	}
	for (int i = 1;i < N+1;i++) {
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        int cnt = 1;

        int ans = 0;

        while (cnt < y) {
            cnt--;
            cnt += x;
            ans++;
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 23892
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int A, B;
    scanf("%d %d", &A, &B);
    /* ====================================== */

    if (B % A == 0) {
        cout << A + B;
    } else {
        cout << B - A;
    }

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 760
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int M=100005,N=4*M;
typedef long long LL;
template<class T>void Min(T &x,T y){
	if(x>y)x=y;
}
LL cnt[N],val[N];
int n,m,beg,x;
void update(int L,int R,int p,int l,int r,int v){
	if(L==l&&R==r){
		val[p]+=v;
		return;
	}int mid=(L+R)>>1;
	if(mid>=r)update(L,mid,p<<1,l,r,v);
	else if(mid<l)update(mid+1,R,p<<1|1,l,r,v);
	else update(L,mid,p<<1,l,mid,v),update(mid+1,R,p<<1|1,mid+1,r,v);
}
void update_(int L,int R,int p,int l,int r,int v){
	if(L==l&&R==r){
//		printf("---%d %d %d %d %d\n",L,R,l,r,v);
		val[p]+=v;
		cnt[p]++;
		return;
	}int mid=(L+R)>>1;
	if(mid>=r)update_(L,mid,p<<1,l,r,v);
	else if(mid<l)update_(mid+1,R,p<<1|1,l,r,v);
	else update_(L,mid,p<<1,l,mid,v),update_(mid+1,R,p<<1|1,mid+1,r,v);
}
LL query(int L,int R,int p,int x){
//	printf("%lld %lld %lld %d %d\n",val[p]-(LL)cnt[p]*x,val[p],cnt[p],L,R);
	if(L==R)return val[p]-(LL)cnt[p]*x;
	int mid=(L+R)>>1;
	if(mid>=x)return query(L,mid,p<<1,x)+val[p]-(LL)cnt[p]*x;
	else return query(mid+1,R,p<<1|1,x)+val[p]-(LL)cnt[p]*x;
}
int main(){
	scanf("%d %d",&n,&m),n--;
	scanf("%d",&x);
	for(int i=1;i<=n;i++){
//		puts("--------");
		scanf("%d",&beg);
		if(beg>x){
			update(1,m,1,1,x,beg-x);
			if(beg<m)update(1,m,1,beg+1,m,beg-x);
			if(x+1<=beg)update_(1,m,1,x+1,beg,1+beg);
		}else {
			update(1,m,1,beg+1,x,m-x+beg);
			if(x<m)update_(1,m,1,x+1,m,1+m+beg);
			update_(1,m,1,1,beg,1+beg);
		}x=beg;
	}
//	for(int i=1;i<=m;i++)printf("----%lld \n",query(1,m,1,i));putchar('\n');
	LL ans=query(1,m,1,1);
	for(int i=2;i<=m;i++)Min(ans,query(1,m,1,i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include<stdio.h>
#define M 10000
int d[100];
int dp[2][3][2];
int main(){
	int n,p;
	int i,j,k,l;
	scanf("%d %d",&n,&p);
	for(i=0;i<n;i++)d[i]=-1;
	for(i=0;i<p;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		d[a-1]=b-1;
	}
	for(i=0;i<3;i++)for(j=0;j<2;j++)dp[0][i][j]=0;
	if(d[0]!=-1)dp[0][d[0]][0]=1;
	else{
		dp[0][0][0]=1;
		dp[0][1][0]=1;
		dp[0][2][0]=1;
	}
	for(i=1;i<n;i++){
		for(j=0;j<3;j++)for(k=0;k<2;k++)dp[i%2][j][k]=0;
		if(d[i]!=-1){
			for(j=0;j<3;j++)if(j!=d[i])for(k=0;k<2;k++)dp[i%2][d[i]][0]=(dp[i%2][d[i]][0]+dp[(i+1)%2][j][k])%M;
			dp[i%2][d[i]][1]=dp[(i+1)%2][d[i]][0];
		}else{
			for(j=0;j<3;j++){
				for(k=0;k<3;k++)if(k!=j)for(l=0;l<2;l++)dp[i%2][j][0]=(dp[i%2][j][0]+dp[(i+1)%2][k][l])%M;
				dp[i%2][j][1]=dp[(i+1)%2][j][0];
			}
		}
	}
	int ans=0;
	for(i=0;i<3;i++)for(j=0;j<2;j++)ans=(ans+dp[(n+1)%2][i][j])%M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
/**************************************************************
	File name: C.cpp
	Author: huhao
	Email: 826538400@qq.com
	Create time: 2019/8/24 下午8:17:08
**************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=200010,mod=1000000007;
int n,t;
long long ans;
char s[N];
int main()
{
	n=read();
	scanf("%s",s+1);
	ans=1;
	fr(i,1,n*2)
		s[i]=s[i]=='B';
	fr(i,1,n)
		ans=ans*i%mod;
	fr(i,1,n*2)
	{
		s[i]=(s[i]^t)&1;
		if(s[i])
			t++;
		else
		{
			ans=ans*t%mod;
			t--;
			if(t<0)
			{
				printf("0\n");
				return 0;
			}
		}
	}
	printf("%lld\n",t==0?ans:0);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int N = 0; 
  for (int i = 0; i <= A; i++) {
   for (int j = 0; j <= B; j++) {
    for (int k = 0; k <= C; k++) {
  if(500 * i + 100 * j + 50 * k == X)
  N++;  
    }
   }
  }
  cout << N << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int  main()
{
	int n,m;
	cin >> n >> m;
	cout << (((100*n)+(1800*m))*(1<<m));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line printf("-----------------------------\n")
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int   main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a-b+1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k, fa[N], f[N], d[N];
vector<int> g[N];
void dfs(int u) {
  for (auto v : g[u]) {
    dfs(v);
    d[u] = max(d[u], d[v] + 1);
    f[u] += f[v];
  }
  if (d[u] == k - 1 && u != 1 && fa[u] != 1) {
    d[u] = -1;
    ++f[u];
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &fa[i]);   
    if (i > 1) {
      g[fa[i]].push_back(i);
    }
  }
  dfs(1);
  printf("%d\n", (fa[1] != 1) + f[1]);
  return 0;
}

Measured memory_bytes: 18244
import heapq
N, M = [int(_) for _ in input().split()]
H = [-int(_) for _ in input().split()]
heapq.heapify(H)
ans = 0
for _ in range(M):
    a = heapq.heappop(H)
    heapq.heappush(H, a / 2)
print(-sum(int(a) for a in H))


Measured memory_bytes: 14276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  for(int i=0;i<N;i++){
    cin >> l.at(i) >> r.at(i);
  }

  int ans=0;
  for(int i=0;i<N;i++){
    ans += r.at(i)-l.at(i)+1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int r,g,b;
    cin >>r>>g>>b;
    YN((r*100+g*10+b)%4==0);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x)%mod , n / 2)%mod);
	else
		return (x * pow(x, n - 1))%mod;
}
int main() {
	int n; cin >> n;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	int count = 0;
	rip(i, n) {
		if (a[a[i] - 1] == i + 1)count++;
	}
	cout << count / 2 << endl;
}

Measured memory_bytes: 3732
#include<stdio.h>

int main(void){
    
    int N,i,j,minj,tmp,count1=0,count2=0;
    int A[100];
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    
    for(i=0;i<N;i++){
        minj=i;
        count1=0;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj=j;
                count1++;
            }
        }
        if(count1>=1){
                count2++;
        }
        tmp=A[i];
        A[i]=A[minj];
        A[minj]=tmp;
    }
        
    for(i=0;i<N;i++){
        printf("%d",A[i]);
        if(i!=N-1){
    		printf(" ");
    	}
    }
    
    printf("\n");
    
    printf("%d\n",count2);
    
    return 0;
}


Measured memory_bytes: 2036
<?php
list($n) = ints();
$sum = 0;
$a = [];
for ($i = 0; $i < $n; ++$i) {
    list($s[$i]) = ints();
    if ($s[$i] % 10) $a[] = $s[$i];
    $sum += $s[$i];
}
if ($sum % 10) {
    echo $sum;
    exit;
}
if (count($a) === 0) exit('0');
echo $sum - min($a);

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	if (k + k > n + 1)
		return cout << -1, 0;
	int a = n, b = 3 * n + 2 >> 1, c = 3 * n;
	for ( ; a > 0; a--)
		cout << --a + k << ' ' << b++ + k - 1 << ' ' << --c + k << endl;
	for (a = n - 1, b = n + 1; a > 0; a--)
		cout << --a + k << ' ' << b++ + k - 1 << ' ' << --c + k << endl;
}


Measured memory_bytes: 2304
n, a, b = map(int, input().split())
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    if n-a <= b-1:
        if n-b+1 < n-a:
            print((n-(a+(n-b+1)))//2+(n-b+1))
        else:
            print(n-a)
    else:
        if a-1+1 < b-1:
            print((b-(a-1+1)-1)//2+(a-1+1))
        else:
            print(b-1)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  bool isprime=false;
  ll ans=x;
  while(!isprime) {
    isprime=true;
    for(ll div=2;div*div<=ans;++div) {
      if(ans%div==0) {
        isprime=false;
        break;
      }
    }
    if(isprime) break;
    else ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    bool flag=true;
    rep(i,n)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3==0 || a%5==0)flag=true;
            else 
            {
                flag=false;
                break;
            }
        }
    }
    if (flag) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    if(S.size()%2==1){
        cout << "No" << endl;
        return 0;
    }
    int H=0;
    for(int i=0; i<S.size(); i=i+2){
        if(S[i]=='h') H++;
    }
    int I=0;
    if(S.size()/2==H){
        for(int i=1; i<S.size(); i=i+2){
            if(S[i]=='i') I++;
        }
        if(S.size()/2==I) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
const int N=2e5+10;
struct star{
    pi pos;
    int light;
    void in(){
        scanf("%d%d%d",&pos.F,&pos.S,&light);
        return ;
    }
};
struct cmp{
    bool operator()(const star &a,const star &b){
        return a.light>b.light;
    }
};
int min(int a,int b){return a>b?b:a;}
long long int max(long long int a,long long int b){return a>b?a:b;}
int main(){
    int n,d,low=0;
    long long int ans=0;
    star temp;
    priority_queue<star,vector<star>,cmp> pq;
    priority_queue<pi,vector<pi>,greater<pi>>l,b;
    priority_queue<pi> u,r;
    scanf("%d%d",&n,&d);
    for(int i=0;i<n;i++){
        temp.in();
        pq.push(temp);
        low=min(low,temp.light);
    }
    low+=d;
    while(!pq.empty()){
        if(!pq.empty())low=pq.top().light;
        while(pq.top().light<=low){
            temp=pq.top();
            pq.pop();
            u.push({temp.pos.F,temp.light});
            b.push({temp.pos.F,temp.light});
            l.push({temp.pos.S,temp.light});
            r.push({temp.pos.S,temp.light});
            if(pq.empty())break;
        }
        while(!u.empty()){
            if(u.top().S<low-d)u.pop();
            else break;
        }
        
        if(u.empty())continue;
        while(!r.empty()){
            if(r.top().S<low-d)r.pop();
            else break;
        }
        if(r.empty())continue;
        while(!l.empty()){
            if(l.top().S<low-d)l.pop();
            else break;
        }
        if(l.empty())continue;
        while(!b.empty()){
            if(b.top().S<low-d)b.pop();
            else break;
        }
        if(b.empty())continue;
        ans=max(ans,(long long int)(u.top().F-b.top().F)*(r.top().F-l.top().F));
        
    }
    printf("%lld\n",ans);
    
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  int ans=0;
  for(int i=0;i<N-1;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N-2;i++){
    int k=0;
    k=min(B.at(i),B.at(i+1));
    ans=ans+k;
  }
  ans=ans+B.at(0)+B.at(N-2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn = 100000;

int fact(int s) {
	int t = 0;
	while (s % 2 == 0) {
		t++;
		s = s / 2;
	}

	return t;
}

int main() {

	int n, num[maxn];
	int f2 = 0, f4 = 0, odd = 0;

	cin >> n;

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

	rep(i, n) {
		int t = fact(num[i]);
		if (t == 0) {
			odd++;
		}
		else if (t == 1) {
			f2++;
		}
		else {
			f4++;
		}
	}

	if (f2 == 0) {
		if (odd - f4 <= 1) {
			Yes;
		}
		else {
			No;
		}
	}
	else if (f4 == 0) {
		if (odd == 0) {
			Yes;
		}
		else {
			No;
		}
	}
	else if (odd == 0) {
		Yes;
	}
	else {
		if (f4 >= odd) {
			Yes;
		}
		else {
			No;
		}
	}

	return 0;
}


Measured memory_bytes: 640
let
  A = parse(Int, readline())
  B = parse(Int, readline())
  C = parse(Int, readline())
  X = parse(Int, readline())
  ans = 0
  for a = 0:A, b = 0:B, c = 0:C
    X == 500a + 100b + 50c && (ans += 1)
  end
  println(ans)
end

Measured memory_bytes: 109208
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d

n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort.reverse

class Stick
  def initialize(length, index)
    @length = length
    @index = index
  end

  attr_reader :length, :index
end

sticks = l.map.with_index(0) { |length, i| Stick.new(length, i) }

# puts sticks.inspect
# puts ""

count = 0
0.upto(n - 3) do |i|
  a = sticks[i]
  (i + 1).upto(n - 2) do |j|
    b = sticks[j]
    candidates = sticks[(j + 1)..(n - 1)]
    t = a.length - b.length
    c_over = candidates.bsearch { |stick| stick.length <= t }
    if c_over.nil?
      c_last_index = n - 1
    else
      c_last_index = c_over.index - 1
    end
    # puts "a: #{a.length}, b: #{b.length} -> #{c_last_index - j}"
    # puts ""
    count += c_last_index - j
  end
end

puts count


Measured memory_bytes: 2168
#include <stdio.h>

const int Field_Size = 12;
const int xdir[4] = {0, -1, 0, 1};
const int ydir[4] = {1, 0, -1, 0};

void dfs_algorithm(char field[Field_Size][Field_Size+2], int cur_x, int cur_y)
{
  int i, next_x, next_y;

  field[cur_y][cur_x] = '0';
  for(i = 0; i < sizeof xdir/ sizeof xdir[0]; ++i){
    next_x = cur_x + xdir[i];
    next_y = cur_y + ydir[i];
    if(0 <= next_x && next_x < Field_Size &&
       0 <= cur_y && cur_y < Field_Size && field[next_y][next_x] == '1')
      dfs_algorithm(field, next_x, next_y);
  }
}

int main()
{
  int i, j, count;
  char field[Field_Size][Field_Size+2];

  do{
    for(i = 0; i < Field_Size; ++i)
      fgets(field[i], sizeof field[i]/sizeof field[i][0], stdin);

    count = 0;
    for(i = 0; i < Field_Size; ++i)
      for(j = 0; j < Field_Size; ++j)
	if(field[i][j] == '1'){
	  dfs_algorithm(field, j, i);
	  ++count;
	}

    printf("%d\n", count);
  } while(fgets(field[0], sizeof field/sizeof field[0][0], stdin)!=NULL);

  return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<stack>
using namespace std;


int main() {

	int x, y, z, X, num = 0;

	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &z);
	X = x;
	while (1) {
		if (z <= X) {
			X -= z;
			if (X >= y + z) {
				X -= y;
				num++;
			}
			else { break; }
		}
		else { break; }
	}
	printf("%d", num);

}

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

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
    ModInt::build(4 * 1e5);
    int n, k;
    cin >> n >> k;
    ModInt ans = 0;
    for (int i = 0; i <= min(n - 1, k); i++) {
        ans += ModInt::comb(n, i) * ModInt::comb(n - 1, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

struct Book {
  LL C;
  vector<LL> A;
};

int main() {
  int N, M, X; cin >> N >> M >> X;
  vector<Book> bs(N);
  for (int i = 0; i < N; ++i) {
    cin >> bs[i].C;
    bs[i].A.resize(M); cin >> bs[i].A;
  }

  int vmin = 1e9;
  for (int i = 0; i < (1 << N); ++i) {
    vector<int> Y(M, 0);
    bitset<14> b(i);
    int c = 0;
    for (int j = 0; j < N; ++j) {
      if (b.test(j)) {
        c += bs[j].C;
        for (int k = 0; k < M; ++k) {
          Y[k] += bs[j].A[k];
        }
      }

      bool ok = true;
      for (int a : Y) {
        if (a < X) {
          ok = false;
          break;
        }
      }

      if(ok) {
        vmin = min(vmin, c);
      }
    }
  }

  if (vmin == 1e9) cout << -1 << endl;
  else cout << vmin << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

ll n, k, d, x;

int main (){
    scanf("%lld %lld%lld", &x, &k, &d);
    if(x > 0){
        if(x/d > k){
            x = x - d*k;
            k = 0;
        }
        else{
            ll nk = k - (x/d);
            x = x - d*(x/d);
            k = nk;
            if(k&1)
                x = x - d;
        }
    }
    else{
        if(abs(x/d) > k){
            x = x + d*k;
            d = 0;
        }
        else{
            ll nk = k - (x/d);
            x = x - d*(x/d);
            k = nk;
            if(k&1)
                x = x + d;
        }
    }
    printf("%lld\n", abs(x));
}



Measured memory_bytes: 3824
n=gets.to_i
a=Array.new(n,0)
m=Math.sqrt(n).ceil

m.times do |i|
  i+=1
  m.times do |j|
    j+=1
    m.times do |k|
      k+=1
      
      b=i*i+j*j+k*k+i*j+i*k+j*k-1
      [i,j,k]
     
   
      if b<n
       a[b]+=1
      end
    end
  end
end
a.map {|n| puts n}

Measured memory_bytes: 14420
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 + 2");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 - 7");
            //-2
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string[] wkArr = InputList[0].Split(' ').ToArray();

        int A = int.Parse(wkArr[0]);
        int B = int.Parse(wkArr[2]);

        if (wkArr[1] == "+") {
            Console.WriteLine(A + B);
        }
        if (wkArr[1] == "-") {
            Console.WriteLine(A - B);
        }
    }
}


Measured memory_bytes: 2904
n,k = map(int,input().split())
p = [0]
a = list(map(int,input().split()))
a = [(1+i)/2 for i in a]
p.extend(a)
s = [0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+p[i+1]
ans = 0
for i in range(n-k+1):
    ans = max(ans,s[i+k]-s[i])
print(ans)

Measured memory_bytes: 25060
# -*- coding: utf-8 -*-
import array
import bisect
import collections
import fractions
import heapq
import itertools
import math
import re
import string

class joshu:

  # stdio
  @staticmethod
  def getInt():
    return int(raw_input().strip())
  @staticmethod
  def getInts():
    return [int(i) for i in raw_input().strip().split()]
  @staticmethod
  def getFloat():
    return float(raw_input().strip())
  @staticmethod
  def getFloats():
    return [float(i) for i in raw_input().strip().split()]
  @staticmethod
  def getStr():
    return str(raw_input().strip())
  @staticmethod
  def getStrs():
    return [str(i) for i in raw_input().strip().split()]

def main():
  n, k = joshu.getInts()
  if (n + 1) / 2 >= k:
    print('YES')
  else:
    print('NO')

if __name__ == '__main__':
  main()


Measured memory_bytes: 34792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{
// #ifndef ONLINE_JUDGE
//    	freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	ll n;
   		cin>>n;
   		n=n%1000;
   		if(n==0)
   			cout<<0;
   		else
   		cout<<1000-n;

    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

int N;
ll W, weight[110], value[110];

// dp[i][j]はi-1番目までの品物を選ぶとき，価値の総和をj以上にするための重さの総和の最小値
ll dp[110][100100];

int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> weight[i] >> value[i];

    for (int i = 0; i < 110; i++) {
        for (int j = 0; j < 100100; j++) {
            dp[i][j] = INF_64;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int sum_value = 0; sum_value < 100100; ++sum_value) {
            // i番目の品物を選ぶ場合
            if (sum_value - value[i] >= 0) {
                chmin(dp[i + 1][sum_value], dp[i][sum_value - value[i]] + weight[i]);
            }

            // i番目の品物を選ばない場合
            chmin(dp[i + 1][sum_value], dp[i][sum_value]);
        }
    }

    int ans = 0;
    for (int sum_value = 0; sum_value < 100100; ++sum_value) {
        if (dp[N][sum_value] <= W) {
            ans = sum_value;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 86272
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '2')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define inf 0x3f3f3f3f
#define db double
using namespace std;
const int maxn=1e6+10;
int d[2][6], cnt1=0,cnt2=0;

int main() {
	string s1,s2;
	cin>>s1>>s2;
	int ans=0,len=s1.length();
	for(int i=0;i<len;i++) if(s1[i]!=s2[i]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3928
N,M=map(int,input().split())
if N%2==1:
    for i in range(0,M):
        print(i+1,2*M-i)
else:
    ans=[]
    for i in range(0,(M+1)//2):
        ans.append([2*i+1,2*((M+1)//2)-2*i])
    for i in range(0,M-(M+1)//2):
        ans.append([2*((M+1)//2)+1+i,2*M+1-i])
    for i in range(len(ans)):
        print(*ans[i])

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

int main(){
    ll N; cin >> N;
    vector <ll> A(N);
    vector <ll> B(N,0);
    rep(i,N){
        cin >> A[i];//何の数字が
        B[A[i]]++;//何個ある？
    }
    
    if(A[0]!=0){
        cout << 0;
        return 0;
    }
    
    if(B[0]!=1){
        cout << 0;
        return 0;
    }
    
    //連続性のチェック
    sort(A.begin(),A.end());
    for (ll i=1; i<N; i++){
        if(!(A[i]-A[i-1]==0 ||  A[i]-A[i-1]==1)){
            cout << 0;
            return 0;
        }
    }
    
    //掛け算の答え
    ll ans=1;
    for (ll i=0; i<A[N-1]; i++){//何を
        for (ll j=0; j<B[i+1]; j++){//何乗
            ans=(ans*B[i])%998244353;
        }
    }
    cout << ans;
}

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

#define MAX 1000000

char prime[MAX];

void search_prime(void)
{
	int i = 0, j = 0;
	
	for (i = 0; i < MAX; i++) prime[i] = 1;
	
	prime[0] = 0;
	prime[1] = 0;
	
	for (i = 2; i <= sqrt( (double)MAX ) + 1; i++)
	{
		if ( prime[i] == 0 ) continue;
		for (j = i * 2; j < MAX; j += i)
		{
			prime[j] = 0;
		}
	}
	
	return;
}

int main (void)
{
	int n = 0;
	
	search_prime();
	
	while ( scanf("%d", &n) != EOF )
	{
		int i = 0;
		int cnt = 0;
		for ( i = 0; i <= n; i++)
		{
			if( prime[i] ) cnt++;
		}
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1572
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll n,tot1,tot2,T;
ll b[N];
struct node
{
    ll a,b;
    bool operator<(const node&o)const
    {
        return (ll)o.a*(b+1)<(ll)a*(o.b+1);
    }
}a[N];
ll dp[N][46];
int main()
{
    scanf("%lld%lld",&n,&T);
    for(ll i=1;i<=n;i++)
    {
        ll x,y;scanf("%lld%lld",&x,&y);
        if(x==0) b[++tot1]=y;
        else a[++tot2]={x,y};
    }
    sort(b+1,b+1+tot1);
    for(ll i=1;i<=tot1;i++) b[i]=b[i-1]+1+b[i];
    sort(a+1,a+1+tot2);
    memset(dp,inf,sizeof(dp));
    dp[0][0]=0;
    for(ll i=0;i<tot2;i++)
        for(ll j=0;j<=min(i,45ll);j++)
        if(dp[i][j]<=T)
    {
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        if(j+1<=45)
            dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+1+a[i+1].a*(dp[i][j]+1)+a[i+1].b);
    }
    ll ans=0;
    int pos=tot1;
    for(ll i=0;i<=45;i++)
        if(dp[tot2][i]<=T)
        {
            while(pos>=1&&b[pos]>T-dp[tot2][i]) pos--;
            ans=max(ans,i+pos);
        }
    printf("%lld\n",ans);
}


Measured memory_bytes: 76800
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];

  bool can = true;
  for (int i = 0; i < N; ++i) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }

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

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
long long n,m,num;
	cin>>n>>m;
	if(n*2>=m)
	{
		num=m/2;
	}
	else{
		num=n+(m-2*n)/4;
	}
	cout<<num;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
char table[4]={'m','c','x','i'};
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int ak[4]={0},bk[4]={0},ansk[4]={0},now=1;
		string a,b,c;
		cin>>a>>b;
		for(int i=0;i<a.size();i++){
			if(a[i]!='m'&&a[i]!='c'&&a[i]!='x'&&a[i]!='i'){
				now=a[i]-'0';
			}
			else {
				
				for(int j=0;j<4;j++){
					if(table[j]==a[i]){ak[j]=now;}
				}
				now=1;
			}
		}
			for(int i=0;i<b.size();i++){
			if(b[i]!='m'&&b[i]!='c'&&b[i]!='x'&&b[i]!='i'){
				now=b[i]-'0';
			}
			else {
			
				for(int j=0;j<4;j++){
					if(table[j]==b[i]){bk[j]=now;}
				}
					now=1;
			}
		}
		bool kuri=false;
		for(int i=3;i>=0;i--){
			int sum=ak[i]+bk[i];
			if(kuri)sum++;
			if(sum>=10)sum-=10,kuri=true;
			else kuri=false;
			ansk[i]=sum;
		}
			for(int i=0;i<4;i++){
		if(ansk[i]!=0&&ansk[i]!=1)c.push_back(ansk[i]+'0');
		if(ansk[i]!=0)c.push_back(table[i]);
		}
		cout<<c<<endl;
	}

	return 0;
}

Measured memory_bytes: 1200