akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N;
  cin >> N;
  vector<string> S(N);
  REP(i, N) cin >> S[i];
  set<string> st;
  REP(i, N) { st.insert(S[i]); }

  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 19828
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int n,m;
  cin >>n >>m;
  int x[m];
  for(int i=0;i<m;i++)cin >>x[i];
  
  if (n>=m)cout << 0 <<endl;
  
  else {
  	sort(x,x+m);
    int xa[m-1],ans=0;
    
    for(int i=0;i<m-1;i++){
      xa[i]=x[i+1]-x[i];
    }
    sort(xa,xa+m-1);
    for(int i=m-2;i>m-n-1;i--){
      ans+= xa[i];
    }
    cout <<x[m-1]-x[0]- ans <<endl;
  }
}


Measured memory_bytes: 1024
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2){
        print(1);
    }else{
        print(0);
    }

}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

#define INF 999999
#define MAX_V 999

using namespace std;

int main(){
	long int n, id, val, num;
	vector<long int> ans;
	vector<long long int> com(4000);
	while(cin>>n,n){
		ans.clear();
		rep(i,4000)	com[i]=0;
		rep(i,n){
			cin>>id>>val>>num;
			if(!com[id-1])	ans.push_back(id);
			com[id-1]+=val*num;
		}
		bool flag=true;
		rep(i,ans.size()){
			if(com[ans[i]-1]>=1000000){
				cout<<ans[i]<<endl;
				flag=false;
			}
		}
		if(flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
	
}

Measured memory_bytes: 1260
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    cout << (X/ 500) * 1000 + (X % 500)/5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
//41
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  bool cmp[1000000]={true,true};
  vector<int> v;
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      v.push_back(i);
      for(int j=2;i*j<1000000;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n,p;cin>>n>>p,n!=-1;){
    vector<int> a;
    int x=upper_bound(v.begin(),v.end(),n)-v.begin();
    for(int i=0;i<100;i++){
      for(int j=i;j<i+100;j++){
	a.push_back(v[x+i]+v[x+j]);
      }
    }
    sort(a.begin(),a.end());
    cout<<a[p-1]<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 2572
using System;

namespace ABC048_A_AtCoder_Contest
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			string s = input[1];

			Console.WriteLine("A" + s.Substring(0, 1) + "C"); 
		}
	}
}

Measured memory_bytes: 13140
n,w=map(int,input().split())
W=[]
V=[]
for _ in range(n):
    a,b=map(int,input().split())
    W.append(a)
    V.append(b)
dp=[[0]*(w+1) for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j<W[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-W[i]]+V[i])

print(dp[n][w])

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

int main (){
    
    int a, b, c;
    cin >> a >> b >> c;
    
    if ((a + b) - c >= 0){
       cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
    
}


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

const int MAX=101;
const int INF=(1<<21);

int main(){
  int n, m;
  int s, g1, g2;
  int pipe[MAX][MAX];

  while( cin >> n >> m >> s >> g1 >> g2 ) {

    if( n==0 && m==0 && s==0 && g1==0 && g2==0 ) break;
    
    for(int i=0; i<=n; i++) {
      for(int j=0; j<=n; j++) {
	pipe[i][j] = INF;
      }
      pipe[i][i] = 0;
    }
    
    for(int i=0; i<m; i++) {
      int b1, b2, c; 
      cin >> b1 >> b2 >> c;
      pipe[b1][b2] = c;
    }
    
    for(int i=1; i<=n; i++) {
      for(int j=1; j<=n; j++) {
	for(int k=1; k<=n; k++) {
	  pipe[j][k] = min(pipe[j][k], pipe[j][i]+pipe[i][k]);
	}
      }
    }

    int ans = INF;
    for(int i=1; i<=n; i++) {
      ans = min(ans, pipe[s][i]+pipe[i][g1]+pipe[i][g2]);
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
int read(){
	int x=0,f=1;char c;
	do{c=getchar();if(c=='-')f=-1;}while(!isdigit(c));
	do{x=x*10+c-'0';c=getchar();}while(isdigit(c));
	return x*f;
}
using Int = signed long long int;
const Int mod=Int(1e9)+7LL;
const int N=2000+10;

Int fix(Int x){ return (x%mod+mod)%mod; }
Int qpow(Int a,Int p=mod-2){
	a=fix(a); Int r=1; while(p){
		if(p&1) r=r*a%mod;
		a=a*a%mod; p>>=1;
	} return r;
}

int lim;
struct Poly{
	Int a[N];
	Poly(){ memset(a,0,sizeof(a)); }
	Int operator[](int x)const{return a[x];}
	Int& operator[](int x){return a[x];}
};
Poly operator*(const Poly&a,const Poly&b){
	Poly c;
	for(int i=0;i<=lim;i++) for(int j=0;j<=i;j++) c[i]=(c[i]+a[j]*b[i-j]%mod)%mod;
	return c;
}
Poly inv(const Poly &p){
	Poly q; q[0]=qpow(p[0],mod-2);
	for(int i=1;i<=lim;i++){
		Int tmp=0;
		for(int j=1;j<=lim;j++) tmp=(tmp+p[j]*q[i-j]%mod)%mod;
		// tmp+p[0]*q[i] = 0
		q[i]=fix(-tmp*q[0]%mod);
	}
	return q;
}



int main(){
	int n=read(); ::lim=2000;
	Poly up; up[0]=1; up[1]=fix(-1);
	Poly down; down[0]=1; down[1]=down[3]=fix(-1);

	Poly poly = up*inv(down);
	
	std::cout<<poly[n]<<std::endl;
	return 0;
}
// OGF: F(x)=(1-x)/(1-x-x^3)

Measured memory_bytes: 3560
#include <stdio.h>
#include <math.h>
int main(){

  int n,x[100],y[100],i,pp[100];
  double p,p1=0,p2=0,p3=0,sub=0,sub2=0;
  
  scanf("%d",&n);

  //scan
  for(i = 0; i < n; i++){

    scanf("%d",&x[i]);

  }

  for(i = 0; i < n; i++){
    
    scanf("%d",&y[i]);
    
  }
  
  //p1
  for(i = 0; i < n; i++){

    p=x[i]-y[i];

    if(p < 0) p *= -1;

    p1 += p;

  }

  printf("%.5lf\n",p1);

  //p2
  for(i = 0; i < n; i++){
    
    p=x[i]-y[i];
    
    sub += pow(p,2);

  }
  
  printf("%.5lf\n",pow(sub,0.5));

  //p3

  for(i = 0; i < n; i++){
    
    p=x[i]-y[i];

    if(p < 0) p *= -1;
    
    sub2 += pow(p,3);
    
  }

  printf("%.5lf\n",pow(sub2,1.0/3.0));

  //pMAX
  for(i = 0; i < n; i++){

    pp[i]=x[i]-y[i];

    if(pp[i] < 0) pp[i] *= -1;
    
  }

  for(i = 1; i < n; i++){

    if(pp[i-1] > pp[i]){

      pp[i]=pp[i-1];

    }

  }

  printf("%d\n",pp[n-1]);

  return 0;

}
  
  

Measured memory_bytes: 700
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    val c = (a.toString() + b.toString()).toInt()
    if (pow(floor(sqrt(c.toDouble())), 2.0) == c.toDouble()) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 31136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(1<<10))

using namespace std;

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

int calc(vector<int> curr){
	int res = 0;
	rep (i, 4){
		res += (curr[i] % 10 == 0 ? curr[i] : (curr[i]/10) * 10 + 10);
	} // end rep
	res += curr[4];

	return res;
}


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<int> dishes(5, 0);
	rep (i, 5){
		cin >> dishes[i];
	} // end rep

	sort(ALL(dishes));

	int res = INF;
	do{
		int curr = calc(dishes);
		res = min(res, curr);
	}while(next_permutation(ALL(dishes)));

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int x,y,z;
	int ans=0;
	x=y=z=0;
	char c='\0';
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		bool f=true;
		if(s[i]=='J'){
			if(c=='J')x++;
			else {
				x=1;
				y=z=0;
			}
		}else if(s[i]=='O'){
			if(c=='J' || c=='O')y++;
			else f=false;
		}else{
			if(c=='O' || c=='I'){
				z++;
				if(y<=x && y<=z)ans=max(ans,y);
			}
			else f=false;
		}
		if(f)c=s[i];
		else c='\0';
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 a[MAXN],s[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    int64 tmp = 0,ans = 1e18;
    for(int i = 1 ; i <= N ; ++i) {
	s[i] = s[i - 1] + a[i];
	if(i & 1) {
	    if(s[i] >= 0) {tmp += s[i] + 1;s[i] = -1;}
	}
	else {
	    if(s[i] <= 0) {tmp += 1 - s[i];s[i] = 1;}
	}
    }
    ans = min(ans,tmp);
    tmp = 0;
    for(int i = 1 ; i <= N ; ++i) {
	s[i] = s[i - 1] + a[i];
	if(i & 1) {
	    if(s[i] <= 0) {tmp += 1 - s[i];s[i] = 1;}
	}
	else {
	    if(s[i] >= 0) {tmp += s[i] + 1;s[i] = -1;}
	}
    }
    ans = min(ans,tmp);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1792
H, N = map(int, input().split())
INF = int(1e12)

def l():
    a, b = map(int, input().split())
    return P(a, b)

class P:
    def __init__(self, f, s):
        self.f = f
        self.s = s

    def __lt__(self, other):
        return self.s * other.f < other.s * self.f

AB = [l() for _ in range(N)]
AB = sorted(AB)

HMAX = H + 10000

dp = [INF] * (HMAX + 1)
dp[0] = 0
for i in range(HMAX):
    for p in AB:
        if i + p.f > HMAX:
            continue
        dp[i + p.f] = min(dp[i + p.f], dp[i] + p.s)

for i in range(HMAX - 1, -1, -1):
    dp[i] = min(dp[i + 1], dp[i])

print(dp[H])


Measured memory_bytes: 40944
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 6e5+20;

int n, este, fil, col;
int puntos [N][3];
int mejor [N][3];

void f(int fil, int col)
{
    if(fil == 0) 
    {
        mejor[0][0] = puntos[0][0];
        mejor[0][1] = puntos[0][1];
        mejor[0][2] = puntos[0][2];
    }
    else
    {
        if(col == 0)
        {
            mejor[fil][col] = max( mejor[fil-1][1], mejor[fil-1][2] ) + puntos[fil][col];
        }
        else if(col == 1)
        {
            mejor[fil][col] = max(mejor[fil-1][0], mejor[fil-1][2]) + puntos[fil][col];
        }
        else
        {
            mejor[fil][col] = max(mejor[fil-1][0], mejor[fil-1][1]) + puntos[fil][col];
        }   
    }
}
int main()
{
    cin>>n;
    for(int i = 0; i < n; i++){cin>>este; puntos[i][0] = este; cin>>este; puntos[i][1] = este; cin>>este; puntos[i][2] = este;}
    for(int i = 0; i < n; i++){f(i, 0); f(i, 1); f(i, 2);}
    cout<<max(mejor[n-1][0], max(mejor[n-1][1], mejor[n-1][2]) )<<endl;
    //cout<<mejor[n-1][0]<<" - "<<mejor[n-1][1]<<" - "<<mejor[n-1][2]<<endl;
}

Measured memory_bytes: 5468
n = int(input())

for x in range(1,n+1):
  if x % 3 == 0:
    print(" " + str(x), end ="")
  elif x % 10 == 3:
    print(" " + str(x), end = "")
  else:
    y = int(x /10)
    while y:
      if y % 10 == 3:
        print(" " + str(x), end = "")
        break
      else:
        y = int(y /10)

print("")





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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

int n;
vector<int> h;

int main(){
  cin >> n;
  rep(i,0,n){
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
  }
  int ans = 0;
  int tmp_max = 0;
  for (int i = 0; i < h.size(); i++)
  {
    if(h[i]>= tmp_max){
      ans++;
      tmp_max = h[i];
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;


int n;
int a[100005];

ll go(bool flg){
	ll sum=0;
	ll ans=0;
	FORI(0,n){
		sum+=a[i];
		if(flg){
			if(sum>=0){
				ans+=abs(sum+1);
				sum-=abs(sum+1);
			}
		}
		else{
			if(sum<=0){
				ans+=abs(sum-1);
				sum+=abs(sum-1);
			}
		}
		flg^=1;
	}
	return ans;

}

int main() {

	scanf("%d ",&n);

	FORI(0,n){
		scanf("%d ",&a[i]);
	}
	
	ll ans = go(false);

	ans = min(go(true), ans);

	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int maxn = 1e6+7;
int n;
long long seed;
inline long long rand(long long l, long long r) {
    static long long mo=1e9+7, g=78125;
    return l+((seed*=g)%=mo)%(r-l+1);
}
long long Max[10];
long long Min[10];
int main()
{
	ios::sync_with_stdio(false);
    int t;
    t=1;
    for(int cas=1;cas<=t;cas++)
    {
        cin >> n ;
        for(int i=0;i<10;i++)
            Max[i]=-1e15,Min[i]=1e15;
        long long x,y;
        for (int i = 0; i < n; i++)
        {
            cin>>x>>y;
            Max[0]=max(Max[0],x+y);
            Max[1]=max(Max[1],-x+y);
            Max[2]=max(Max[2],x-y);
            Max[3]=max(Max[3],-x-y);
            Min[0]=min(Min[0],x+y);
            Min[1]=min(Min[1],-x+y);
            Min[2]=min(Min[2],x-y);
            Min[3]=min(Min[3],-x-y);
        }
        long long ans = 0;
        for(int i=0;i<4;i++)
            ans=max(Max[i]-Min[i],ans);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
    int x[4], y[4];

    cin >> x[0] >> y[0] >> x[1] >>  y[1];

    x[3] = -y[1] + y[0] + x[0];
    y[3] =  x[1] - x[0] + y[0];
    x[2] = -y[0] + y[3] + x[3];
    y[2] =  x[0] - x[3] + y[3];

    cout << x[2] << ' ' << y[2] << ' ' << x[3] << ' ' << y[3] << '\n';

}


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

using namespace std;

int main()
{
    double w,h,x,y;
    while(cin >> w >> h >> x >> y)
    {
        printf("%lf ",w*h/2.0);
        if(x==w/2&&y==h/2)
            puts("1");
        else puts("0");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	for (int a = 0; a <= A; ++a) {
		for (int b = 0; b <= B; ++b) {
			for (int c = 0; c <= C; ++c){
				int total = 500 * a + 100 * b + 50 * c; //合計金額
				if (total == X) ++res; //合計金額がXに一致したらカウント
				}
			}
		}
	cout << res <<endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, lim;
  cin >> h >> w >> lim;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];
  int ans = INF;
  rep(i, 1<<(h-1)) {
    vector<int> cut = {0};
    rep(j, h-1) {
      if (i>>j & 1)
        cut.push_back(j+1);
    }
    vector<vector<int>> num(cut.size(), vector<int>(w));
    cut.push_back(h);
    bool flag = true;
    rep(j, w) {
      rep(k, cut.size()-1) {
        for (int l = cut[k]; l < cut[k+1]; l++) {
          if (grid[l][j] == '1')
            num[k][j]++;
        }
        if (num[k][j] > lim) {
          flag = false;
          break;
        }
      }
      if (!flag)
        break;
    }
    if (!flag)
      continue;
    int cnt = __builtin_popcount(i);
    for (int j = 1; j < w; j++) {
      flag = true;
      rep(k, num.size()) {
        if (num[k][j]+num[k][j-1] > lim) {
          flag = false;
          break;
        }
      }
      if (flag) {
        rep(k, num.size())
          num[k][j] += num[k][j-1];
      } else
        cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

flag = 0
for i in range(N):
    if A[i] != B[i]:
        flag = 1
        break

s = sum(A)
if flag == 1:
    mini = 10**9+1
    for i in range(N):
        if A[i] > B[i]:
            mini = min(mini, B[i])
else:
    mini = s
print(s-mini)


Measured memory_bytes: 4852
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(){
	string S;
	cin>>S;
	string year, month;
	year = S.substr(0, 4);	
	month = S.substr(5, 2);
	int year_int, month_int;
	year_int = atoi(year.c_str());
	
	string handan = S.substr(5, 1);
	string handan2 = S.substr(6, 1);
	int a = atoi(handan.c_str());
	if(a==0){
		month_int = atoi(handan2.c_str());
	}	else if(a==1){
		month_int = atoi(month.c_str());
	}
	
	if(year_int<2019){
		cout<<"Heisei";
	}	else if(year_int==2019 && month_int<5){
		cout<<"Heisei";
	}	else{
		cout<<"TBD";
	}
	return 0;
}	


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

int main()
{
	string s,t;
	cin>>s>>t;
	
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3860
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D*/
#include <iostream>

using namespace std;

int main() {
    int n;
    int maxv;
    int minv;

    cin>>n;
    cin>> minv;
    for(int i = 0; i < n-1; i++){
        int r;
        cin>>r;
        int tmp=r- minv;
        if(i == 0 || maxv <tmp){
            maxv =tmp;
        }
        minv =min(minv,r);
    }
    cout<< maxv <<endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll x,y;
  cin >> x >> y;
  
  ll ans = 0;
  ll x_sign;
  if(x >= 0)
    x_sign = 1;
  else
    x_sign = -1;

  if((x < 0 && abs(x) < abs(y)) || (x >= 0 && abs(x) > abs(y))){
    ans++;
    x_sign *= -1;
  }

  ans += abs(abs(x)-abs(y));

  if(x_sign * y < 0)
    ans++;

  cout << ans << endl;


  
  
  
}


Measured memory_bytes: 256
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1000 + 20;

int n, m;
double a;

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

    cin >> n;
    double tmp = 0;
    for(int i = 0; i < n; i++) {
    	cin >> a;
    	tmp += 1 / a;
    }
    cout << 1 / tmp << endl;

    return 0;
}











Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD 1000000007
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    string s;
    ll n;
    cin>>n;
    cin>>s;
    int i;
    ll cnt[30] = {};
    FOR0(i, n)
    {
        cnt[s[i]-'a']++;
    }
    ll ans = 1;
    FOR0(i, 26)
    {
        ans *= (cnt[i]+1);
        ans %= MOD;
    }
    ans -= 1;
    ans += MOD;
    ans %= MOD;
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
        }
	int[][] cost;
	int n;
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			n = scan.nextInt();
			if(n == 0){
				break;
			}
			cost = new int[10][10];
			for(int i = 0;i < 10;i++){
				Arrays.fill(cost[i],Integer.MAX_VALUE);
			}
			int max = -1;
			for(int i = 0;i < n;i++){
				int a = scan.nextInt();
				int b = scan.nextInt();
				int c = scan.nextInt();
				cost[a][b] = c;
				cost[b][a] = c;
				max = Math.max(max,Math.max(a, b));
			}
			for(int i = 0;i <= max;i++){
				for(int j = 0;j <= max;j++){
					for(int k = 0;k <= max;k++){
						if(j == k){
							cost[j][k] = 0;
						}else if(cost[j][i] != Integer.MAX_VALUE && cost[i][k] != Integer.MAX_VALUE){
							cost[j][k] = Math.min(cost[j][k],cost[j][i] + cost[i][k]);
						}
					}
				}
			}
			int min = Integer.MAX_VALUE;
			int t = 0;
			for(int i = 0;i <= max;i++){
				int tt = 0;
				for(int j = 0;j <= max;j++){
					if(cost[i][j] != Integer.MAX_VALUE){
						tt += cost[i][j];
					}
				}
				if(min > tt){
					min = tt;
					t = i;
				}
			}
			System.out.println(t + " " + min);
		}
	}
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int h,w;cin>>h>>w;
  int a[h][w];
  queue<P> q;
  REP(i,h){
    string s;
    cin>>s;
    REP(j,w){
      if(s[j]=='.'){
        a[i][j] = INF;
      }else{
        a[i][j] = 0;
        P p;
        p.first = i;
        p.second = j;
        q.push(p);
      }
    }
  }
  int count = 1;

  while(q.size()){

    int kazu = q.size();
    REP(i,kazu){
      P p = q.front();
      int x = p.first;
      int y = p.second;
      q.pop();
      //cout<<"jiji    "<<x<<"  "<<y<<"  "<<a[x][y]<<endl;
      if(x!=0){
        if(a[x][y] + 1 < a[x-1][y]){
          a[x-1][y] = a[x][y] + 1;
          P p2;
          p2.first = x-1;
          p2.second = y;
          q.push(p2);
          //cout<<"a"<<endl;
        }
      }
      if(x!=h-1){
          if(a[x][y] + 1 < a[x+1][y]){
          a[x+1][y] = a[x][y] + 1;
          P p2;
          p2.first = x+1;
          p2.second = y;
          q.push(p2);
          //cout<<"b"<<endl;
        }

      }
      if(y!=0){
          if(a[x][y] + 1 < a[x][y-1]){
          a[x][y-1] = a[x][y] + 1;
          P p2;
          p2.first = x;
          p2.second = y-1;
          q.push(p2);
          //cout<<"c"<<endl;
        }
      }
      if(y!=w-1){
        if(a[x][y] + 1 < a[x][y+1]){
          a[x][y+1] = a[x][y] + 1;
          P p2;
          p2.first = x;
          p2.second = y+1;
          q.push(p2);
          //cout<<"d"<<endl;
        }
        //cout<<"a---- "<<q.size()<<endl;
      }
    }


  }
  int ans = 0;
    REP(i,h){
      REP(j,w){
        ans = max(ans,a[i][j]);
        //cout<<a[i][j]<<"    ";

      }
     // cout<<endl;
    }
    cout<<ans<<endl;

 

  return 0;
}

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

int main(){
  string W; cin >> W;
  transform(W.begin(), W.end(), W.begin(), ::toupper);  
  string T;
  int ans = 0;
  while(cin >> T, T!="END_OF_TEXT"){
    transform(T.begin(), T.end(), T.begin(), ::toupper);  
    if(W==T) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int UF[100000];

int func(int c){
    if(c != UF[c]){
        UF[c] = func(UF[c]);
    }
    return UF[c];
}

void u(int a, int b){
    UF[func(a)] = UF[func(b)];
}

int cmp_0(const void *a, const void *b){
    return (*(int(*)[3])a)[0] - (*(int(*)[3])b)[0];
}

int cmp_1(const void *a, const void *b){
    return (*(int(*)[3])a)[1] - (*(int(*)[3])b)[1];
}

int main(void){

    int N;
    int cities[100000][3], roads[200000][3];

    scanf("%d", &N);

    int x[N], y[N];

    for(int i = 0; i < N; i++){
        scanf("%d%d", &x[i], &y[i]);
        cities[i][0] = x[i];
        cities[i][1] = y[i];
        cities[i][2] = i;
    }

    qsort(cities, N, sizeof(int[3]), cmp_0);

    for(int i = 0; i < N-1; i++){
        roads[i][0] = cities[i+1][0]-cities[i][0];
        roads[i][1] = cities[i][2];
        roads[i][2] = cities[i+1][2];
    }

    qsort(cities, N, sizeof(int[3]), cmp_1);

    for(int i = 0; i < N-1; i++){
        roads[i+N-1][0] = cities[i+1][1] - cities[i][1];
        roads[i+N-1][1] = cities[i][2];
        roads[i+N-1][2] = cities[i+1][2];
    }

    qsort(roads, 2*N-2, sizeof(int[3]), cmp_0);

    for(int i = 0; i < 100000; i++){
        UF[i] = i;
    }

    int cost = 0;
    int X, Y;

    for(int i = 0; i < 2 * N - 2; i++){
        X = roads[i][1];
        Y = roads[i][2];
        if(func(X) != func(Y)){
            u(X, Y);
            cost += roads[i][0];
        }
    }

    printf("%d\n", cost);

    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int max_num = 55556;
	bool prime[max_num];
	fill(prime, prime + max_num, true);
	prime[0] = prime[1] = false;
	for(int i = 0; i < max_num; i++) {
		if(prime[i]) {
			for(int j = i * 2; j < max_num; j += i) {
				prime[j] = false;
			}
		}
	}
	int n;
	cin >> n;
	for(int i = 0; i < max_num; i++) {
		if(prime[i] && i % 5 == 1) {
			if(i != 11) cout << " ";
			cout << i;
			n--;
		}
		if(n == 0) {
			cout << endl;
			return 0;
		}
	}
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
 
int G[100][100];
 
int main(){
  int n,m,l,o,i,j;
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&l);
    for(j=0;j<l;j++){
      scanf("%d",&o);
      G[i][o-1]=1;
    }
  }
   
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",G[i][j]);
    }
      printf("%d\n",G[i][j]);
 
  }
  return 0;
}

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

int N, M;
typedef pair<int,int> pint;

vector<pint> A;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main() {
    cin >> N >> M;
    A.resize(M);
    for (int i = 0; i < M; ++i) cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end(), cmp);
    int res = 0;
    int endtime = 0;
    for (int i = 0; i < M; ++i) {
        if (A[i].first >= endtime) {
            endtime = A[i].second;
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1152
x,y=map(int,input().split())
ans=0
if y==0:
    ans=abs(x)+[0,1][x>0]
elif x==0:
    ans=abs(y)+[0,1][y<0]
elif (x*y)>=0:
    ans=abs(y-x)+[0,2][y-x<0]
else:
    ans=abs(abs(y)-abs(x))+1
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;
import java.util.HashSet;
import java.lang.String;

public class Main {
  
  public static void main (String[] arg) {
    Scanner sc = new Scanner(System.in);
    HashSet<Integer> colors = new HashSet<Integer>();
    colors.add(sc.nextInt());
    colors.add(sc.nextInt());
    colors.add(sc.nextInt());    
    sc.close();
    
    int result = colors.size();
    System.out.println(result);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
//#include<stdio.h>
using namespace std;
//#include<math.h>
//using iostream std;
/*void rev(char *a)
{
        if(*a=='0')
                *a='1';
        else
                *a='0';
}*/
int main( )
{
        //char a,b='5';
        //scanf("%[^\n]s",a);
        long a,N;
        scanf("%ld",&N);
        long sum=0;
        while(N--)
        {
                cin>>a;
                if(a!=0)
                sum+=(a-1);

        }
        printf("\n%ld",sum);

        return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000
using namespace std;

int main()
{
	int n, k;
	int a, b;
	scanf("%d %d", &n, &k);
	vector<int> v[2000];
	int e1[2000], e2[2000];
	for(int i=0; i<n-1; i++){
		scanf("%d %d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
		e1[i]=a;
		e2[i]=b;
	}
	int d[2000][2000];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==j){
				d[i][j]=0;
			}else{
				d[i][j]=INF;
			}
		}
	}
	for(int i=0; i<n; i++){
		queue<int> que;
		que.push(i);
		int used[2000]={};
		while(!que.empty()){
			int x=que.front();
			que.pop();
			if(used[x]==1) continue;
			used[x]=1;
			for(int j=0; j<v[x].size(); j++){
				if(d[i][v[x][j]]>d[i][x]+1){
					d[i][v[x][j]]=d[i][x]+1;
					que.push(v[x][j]);
				}
			}
		}
	}
	if(k%2==0){
		int ans=INF;
		for(int i=0; i<n; i++){
			int count=0;
			for(int j=0; j<n; j++){
				if(d[i][j]>k/2) count++;
			}
			if(ans>count) ans=count;
		}
		printf("%d\n", ans);
	}else{
		int ans=INF;
		for(int i=0; i<n-1; i++){
			int count=0;
			for(int j=0; j<n; j++){
				if(min(d[e1[i]][j], d[e2[i]][j])>k/2) count++;
			}
			if(ans>count) ans=count;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

bool ok(int x, int y, int z, int N)
{
  return 0 <= x && x < N && 0 <= y && y < N && 0 <= z && z < N;
}

bool finish(const vector<vector<vector<int> > >& c, int M, int me)
{
  const int N = c.size();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        for (int d = 0; d < 13; d++) {
          int x = i, y = j, z = k;
          int m = 0;
          while (ok(x, y, z, N)) {
            if (c[x][y][z] == me) {
              ++m;
            } else {
              m = 0;
            }
            if (m >= M) {
              return true;
            }
            static const int di[] = {0,1,1, 1,0,1,1, 1, 0,-1,-1,-1,0};
            static const int dj[] = {1,1,0,-1,1,1,0,-1,-1,-1, 0, 1,0};
            static const int dk[] = {0,0,0, 0,1,1,1, 1, 1, 1, 1, 1,1};
            x += di[d];
            y += dj[d];
            z += dk[d];
          }
        }
      }
    }
  }
  return false;
}

int main()
{
  int N, M, P;
  while (cin >> N >> M >> P && N != 0) {
    vector<pair<int,int> > xy(P);
    for (int i = 0; i < P; i++) {
      cin >> xy[i].first >> xy[i].second;
      --xy[i].first;
      --xy[i].second;
    }

    vector<vector<vector<int> > > cube(N, vector<vector<int> >(N, vector<int>(N, -1)));
    for (int i = 0; i < P; i++) {
      vector<int>& v = cube[xy[i].first][xy[i].second];
      for (int j = 0; j < N; j++) {
        if (v[j] == -1) {
          v[j] = i&1;
          break;
        }
      }
      if (finish(cube, M, i&1)) {
        cout << (i&1 ? "White" : "Black") << ' ' << i+1 << endl;
        goto NEXT;
      }
    }
    cout << "Draw" << endl;
NEXT:
    ;
  }
  return 0;
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int ans = 0;
	
	bool has_snacks[n];
	for(int i=0;i<n;i++){
	    has_snacks[i]=false;
	}
	for(int i = 0; i < k; i++){
	    int d;
	    cin>>d;
	    for(int j=0; j < d; j++){
    	    int w;
    	    cin>>w;
    	    has_snacks[w - 1] = true;
    	}
	}
	for(int i=0;i<n;i++){
	    if(has_snacks[i]==false){
	        ans++;    
	    }
	}
	cout<<ans<<endl;
}


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

int n, mat[20][20];
ll mask[(1 << 16) + 5];
ll dp[(1 << 16) + 5];
vector<int> adj[(1<<16) + 5];

int bit(int u){return (1 << u);}

void solve(int pos, int k, int bitmask){
    if(pos == n){
        if(k != 0) adj[bitmask].push_back(k);
    }
    else{
        solve(pos+1, k, bitmask);
        if(!(bit(pos)&bitmask))
            solve(pos+1, k|bit(pos), bitmask);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> mat[i][j];

    for(int i = 0; i < (1 << n); i++){
        ll sum = 0;
        for(int j = 0; j < n; j++)
            for(int k = j+1; k < n; k++)
                if( (bit(j)&i) and (bit(k)&i) )
                    sum += mat[j][k];
        mask[i] = sum;
    }
    
    for(int i = 0; i < (1 << n); i++)
        solve(0, 0, i);

    // for(int i = 0; i < (1 << n); i++){
    //     bitset<5> aux(i);
    //     cout << aux.to_string() << " : ";
    //     for(int m : adj[i]){
    //         bitset<5> xx(m);
    //         cout << xx.to_string() << " ";
    //     }
    //     cout << endl;
    // }

    for(int j = 0; j < (1 << n); j++)
        for(int m : adj[j])
            dp[j|m] = max(dp[j|m], dp[j] + mask[m]);
    
    cout << dp[bit(n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 174076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    map<char, int> m;
    int cnt=0;
    bool fl = true;

    string S;
    cin >> S;
    int size = S.size();

    for (int i=0;i<size;i++){
        char a;
        a = S[i];
        m[a] ++;

        if(m[a]>1){
            cout << "no" << endl;
            fl = false;
            return 0;
        }
        
    }
    if(fl) cout << "yes" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,data[100];
	int i;

	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d ",&data[i]);
	}
	scanf("%d",&data[i]);
	for(i=n-1;i>0;i--){
		printf("%d ",data[i]);
	}
	printf("%d\n",data[0]);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define BIT_SIZE 1000000
typedef int BITTYPE;
BITTYPE _prepared_bit_table[BIT_SIZE];
//[1,n],0?????±?????????!
template <typename T>class BIT{
private:
	T* bit;int n;
public:
	BIT(int _n){bit=_prepared_bit_table;fill(bit,bit+BIT_SIZE,0);n=_n;}
	BIT(T* _table,int _sz,int _n){bit=_table;fill(bit,bit+_sz,0);n=_n;}
	int sum(int i){int s=0;while(i>0){s+=bit[i];i-=i&-i;}return s;}
	int sum(int lb,int ub){return sum(ub)-sum(lb-1);}
	void add(int i,int x){while(i<=n){bit[i]+=x;i+=i&-i;}}
	//v[1]+v[2]+...+v[x]>=w??¨??????????°????x????±???????
	int lowerbound(int w){if(w<=0)return 0;int x=0;for(int k = (1<<(31-__builtin_clz(n))); k >0 ; k>>=1)if(x+k<=n&&bit[x+k]<w){w-=bit[x+k];x+=k;}return x+1;}
};
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;

int main() {
    int n,q;cin>>n>>q;
    BIT<int> bit(n);
    for(int i = 0; i < q; i++){
        int t,x,y;cin>>t>>x>>y;
        if(t==0)bit.add(x,y);
        else cout<<bit.sum(x,y)<<endl;
    }
    return 0;
}

Measured memory_bytes: 7076
import collections

N = int(input())
a = input().split(" ")

test = collections.Counter(a)
test_key = list(test.keys())
test_value = list(test.values())

ans = 0
for i in range(len(test_key)):
    if int(test_key[i]) > test_value[i]:
        ans += test_value[i]
    elif int(test_key[i]) < test_value[i]:
        ans += test_value[i] - int(test_key[i])

print(ans)

Measured memory_bytes: 20848
L = int(input())
A = [int(input()) for i in range(L)]
dp = [[0]*5 for _ in range(L+1)]
for i in range(1, L+1):
    a = A[i-1]
    g = a%2
    dp[i][0] = dp[i-1][0] + a
    dp[i][1] = min(dp[i-1][:2]) + (g if a!=0 else 2)
    dp[i][2] = min(dp[i-1][:3]) + (1-g if a!=0 else 1)
    dp[i][3] = min(dp[i-1][:4]) + (g if a!=0 else 2)
    dp[i][4] = min(dp[i-1]) + a
print(min(dp[-1]))


Measured memory_bytes: 67804
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))

B=[0]*(n+1)
B[0]=3
ans=1
for i in A:
    ans *=B[i]
    ans %=mod
    B[i] -=1
    B[i+1] +=1

print(ans)

Measured memory_bytes: 53300
#include<stdio.h>
#define ll long long
ll max(ll a, ll b){return a > b ? a : b;}
int main(){
    int n, m;
    ll k;
    scanf("%d%d%lld",&n,&m,&k);
    ll a[n + 1], b[m + 1];
    ll ans = 0, best = 0;
    b[0] = a[0] = 0;
    for(int i = 1; i <= n; i++){
        scanf("%lld",&a[i]);
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= m; i++){
        scanf("%lld",&b[i]);
        b[i] += b[i - 1];
        if(b[i] <= k)
            best = i;
    }
    for(int i = 0; a[i] <= k; i++){
        while(a[i] + b[best] > k)
            best --;
        ans = max(ans, i + best);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4848
#!/usr/bin/env python3
import itertools
import sys


def solve(N: int, P: "List[int]", Q: "List[int]"):
    for i, p in enumerate(itertools.permutations(range(1, N+1))):
        if P == list(p):
            pp = i
        if Q == list(p):
            qq = i
    print(abs(pp-qq))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    bool frag1 = false;

    rep(i, s.size() / 2)
    {
        if (s[i] != s[s.size() - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, (s.size() / 2) / 2)
    {
        if (s[i] != s[(s.size() / 2) - 1 - i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    REP(i, s.size() / 2 + 1, s.size() / 2 + (s.size() / 2) / 2)
    {
        if (s[i] != s[s.size() / 2 + 1 + (s.size() / 2) - 1 - i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, X = map(int, input().split())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
res = N + 1
for i in range(N + 1):
  if cs[i] > X:
    res = i
    break
print(res)

Measured memory_bytes: 38384
from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

        visited.append(label)

        for v in d[label]:
            if tekazu[v] == float("inf"):
                tekazu[v] = tekazu[label] + 1
                queue.appendleft(v)

    return

n = int(input())
d = [[] for _ in range(n)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)

tekazu = [float("inf") for _ in range(n)]
tekazu[0] = 0
bfs(0)
tekazu_Fennec = tekazu

tekazu = [float("inf") for _ in range(n)]
tekazu[-1] = 0
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 79264
n = int(input())
A = list(map(int,input().split()))
absA = [abs(a) for a in A]
sgn = 0
for i in range(n):
  if A[i]<0:
    sgn += 1
if sgn%2 == 0:
  print(sum(absA))
else:
  print(sum(absA)-2*min(absA))

Measured memory_bytes: 14332
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <utility>
#include <cstdio>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;

int main() {
  int N;
  LL x, y, h, px, py, ph;
  LL H, X, Y;
  vector<tuple<LL, LL, LL> >  v;
  cin >> N;
  rep(i, N) {
    cin >> x >> y >> h;
    v.push_back(make_tuple(x, y, h));
  }
  
  rep(Cx, 101) {
    rep(Cy, 101) {
      int H = -1;
      int Hmax = 2e9;
      bool success = true;
      rep(i, N) {
        tie(x, y, h) = v[i];
        int d = abs(Cx - x) + abs(Cy - y);
        if (h > 0) {
          int H2 = h + d;
          if (H > 0 and H != H2) {
            success = false;
            break;
          } else {
            H = H2;
          }
        } else {
          Hmax = min(Hmax, d);
        }
      }
      if (success and H <= Hmax) {
        cout << Cx << " " << Cy << " " << H <<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 384
N, x = map(int, input().split())
inputs = [int(i) for i in input().split()]

inputs.sort()
ans = 0
limit = 0
for i in range(len(inputs)):
    if i == N - 1 and x - inputs[i] != limit:
        break
    elif x - limit >= inputs[i]:
        ans += 1
        limit += inputs[i]
    else:
        limit += inputs[i]

print(ans)


Measured memory_bytes: 3060