akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fori(x,y)   for(ll i=x;i<y;i++)
#define forj(x,y)   for(ll j=x;j<y;j++)
#define rfori(a,b)   for(int i=a;i>=b;i--)
#define for_it(a)     for(auto it: a)
#define pb          push_back
#define pf          push_front
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define mp          make_pair
#define mod         1000000007
#define mem(a,b)    memset(a,b,sizeof(a))
#define ld          long double
#define endl        "\n"
#define ll          long long
#define llu         unsigned long long 
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vl          vector<ll> 
#define vi          vector<int> 
#define vc          vector<char> 
#define vs          vector<string> 
#define si          set<int>
#define spii        set<pii>
#define usi         unordered_set<int>
#define usl         unordered_set<ll>
#define uspii       unordered_set<pii>
#define mii         map<int,int>
#define umii        unordered_map<int,int>
#define pqmx        priority_queue<int>
#define pqmn        priority_queue<int,vi,greater<int>>
#define setbits(x)  __builtin_popcountll(x)
#define fast        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcase    int test;cin>>test;for(ll tst=0;tst<test;tst++)
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

/*-----------------------------------------------------------------------------------------------------------------*/



int main()
{
	#ifndef ONLINE_JUDGE
	freopen("C_IN.txt","r",stdin);
	freopen("C_Out.txt","w",stdout);
	#endif
	fast;

	ll n,m;
	cin>>n>>m;
	vl v(11,0);
	fori(0,m)
	{
		int x;
		cin>>x;
		v[x]++;
	}
	ll res=0,b=n;
	while(1)
	{
		int temp=b;
		bool flag=true;
		while(temp>0)
		{
			int rem=temp%10;
			temp=temp/10;
			if(v[rem])
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			cout<<b;
			break;
		}
		b++;
	}
	return 0;
}






Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
  int n,h,hi;
  cin >> n;
  cin >> h;
  
  int out = 0;
  for(int i=0;i<n;i++)
  {
    cin >> hi;
    
    if(hi >= h)
      out++;
  }
  
  cout << out;
  return 0;
}


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

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    printf("%lf\n", sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2)));

    return 0;
}



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

int main(){
    int N, cnt;
    string s;
    map<string, int> box;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s;
        box[s]++;
    }
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s;
        box[s]--;
    }
    int max = 0;
    for(auto p: box){;
        if(max < p.second){
            max = p.second;
        }
    }

    cout << max << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[2]={1,0};
int ny[2]={0,1};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main (){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>maze(h+1,vector<char>(w+1,'.'));
    vector<vector<int>>cost(h+1,vector<int>(w+1,0));
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            cin >> maze[i][j];
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            if(i==1&&j==1){
                if(maze[i][j]=='#') cost[i][j]=1;
            }
            else if(i==1){
                if(maze[i][j]=='#'){
                    if(maze[i][j-1]=='#') cost[i][j]=cost[i][j-1];
                    else cost[i][j]=cost[i][j-1]+1;
                }
                else cost[i][j]=cost[i][j-1];
            }
            else if(j==1){
                if(maze[i][j]=='#') {
                    if(maze[i-1][j]=='#')cost[i][j]=cost[i-1][j];
                    else cost[i][j]=cost[i-1][j]+1;
                }
                else cost[i][j]=cost[i-1][j];
            }
            else {
                int tate=inf;
                int yoko=inf;
                if(maze[i][j]=='#') {
                    if(maze[i-1][j]=='#') tate=cost[i-1][j];
                    else tate=cost[i-1][j]+1;
                    if(maze[i][j-1]=='#') yoko=cost[i][j-1];
                    else yoko=cost[i][j-1]+1;
                    cost[i][j]=min(tate,yoko);
                }
                else cost[i][j]=min(cost[i][j-1],cost[i-1][j]);
            }
        }
    }

    cout << cost[h][w] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans;
    for(int i = 0; i < n; i++) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
const ll INF = (1ll << 60);
const ll MOD = 1000000007;

int main() {
  ll N; cin>>N;
  vi a(N); REP(i,N) cin>>a[i];
  UM<ll,ll> cnt; REP(i,N) cnt[a[i]]++;
  ll ans=0;
  for(auto p:cnt) {
    if(p.first>p.second) ans+=p.second;
    else ans+=(p.second-p.first);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5028
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<x<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
typedef long long ll;
using namespace std;
double h,c,t;

int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);
    string s,a;
    cin>>s;
    int i,j,ck,l=s.size();
    for(i=0;i<l;i++)
    {
        if(s[i]=='?')
            cout<<'D';
        else
            cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,K; 
    cin>>A>>B>>K;

    set<int> st;
    REP(i,K) if(A+i<=B) st.insert(A+i);
    REP(i,K) if(B-i>=A) st.insert(B-i);
    for(auto x:st) cout<<x<<endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a + b == c) {
		cout << "Yes" << endl;
	} else if (b + c == a) {
		cout << "Yes" << endl;
	} else if (a + c == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <iomanip>

using namespace std;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    int res = b/a;
    cout << min(res, c) << endl;
}

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

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const LL mod = 1000000007ll;
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint comb(mint N,mint a){
	mint ret = 1;
	for(int i=0;i<a.x;i++){
		mint I = i;
		ret *= (N-I);
		ret /= (I+1);
	}
	return ret;
}

LL N,a,b;

mint ans = 0;

//2^NからNCaとNCb、NC0を引く
void solve(){
	ans = 2;
	ans = ans.pow(N) - 1;
	ans -= (comb(N,a) + comb(N,b));
}
 
int main(){
	cin >> N >> a >> b;
 
	solve();

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

Measured memory_bytes: 384
inp = int(input())
flag = "No"
for i in range(1,10):
  if (str(inp/i)).split(".")[1]=="0":
    a = str((inp/i)).split(".")[0]
    
    if(len(a)==1):
      for j in range(1,10): 
        if (str(int(a)/j)).split(".")[1]=="0":
          b = str((int(a)/j)).split(".")[0]
          if (b=="1"):
            flag="Yes"
            break  
print(flag)

Measured memory_bytes: 3064
n = int(input())
a = [int(x) for x in input().split()]
def solve(a):
  actMax = a[0]
  for i in range(1,n):
    if(a[i]<actMax-1):
      print("No")
      return
    actMax = max(actMax,a[i])
  print("Yes")
    
solve(a)
  

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

int n, m, k[10], s[10][10], p[10];
int main() {
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> k[i];
        for(int j=0; j<k[i]; j++) {
            int x; cin >> x;
            s[i][x - 1]++;
        }
    }
    /*for(int i=0; i<m; i++) {
        for(int j=0; j<n; j++) {
            cout << s[i][j] << " ";
        }
        cout << endl;
    }*/
    for(int i=0; i<m; i++) cin >> p[i];
    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++) {
        int as[m] = {0};
        bool flag = true;
        for(int i=0; i<n; i++) {
            if(bit>>i & 1) {
                for(int j=0; j<m; j++) as[j] += s[j][i];
            }
        }
        for(int j=0; j<m; j++) if(as[j] % 2 != p[j]) flag = false;
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif



struct edge {
	ll next_node;
	int flip;
};

vector<edge> edges;
vector<int> ne[100001];
int is_odd[100001];
int reach[100001];

ll n, m;

bool dfs_is_odd( int node ){
	reach[node] = true;
	for ( auto it : ne[node] ){
		edge &e = edges[it];
		if ( reach[e.next_node] )
			continue;
		
		if ( dfs_is_odd( e.next_node ) ){
			// ルートに向かってしわ寄せをする
			e.flip = 1;
			is_odd[node] ^= 1;
			is_odd[e.next_node] ^= 1;
		}
	}
	return is_odd[node];
}

int main(){
	cin >> n >> m;
	
	rep(i,m){
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		
		edges.push_back({b,0});
		edges.push_back({a,0});
		
		ne[a].push_back(i*2);
		ne[b].push_back(i*2+1);
		is_odd[a] ^= 1;
	}
	
	if ( dfs_is_odd(0) ){
		cout << -1 << endl;
	}
	else {
		for ( int i = 0; i < SZ(edges); i+= 2 ){
			if ( edges[i].flip || edges[i+1].flip ){
				// flipなら b a の順で
				cout << edges[i].next_node+1 << " " << edges[i+1].next_node+1 << endl;
			}
			else {
				cout << edges[i+1].next_node+1 << " " << edges[i].next_node+1 << endl;
			}
		}
	}
	
	return 0;
}




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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int res = 0;
    while(N>=K){
        N = (N-N%K)/K;
        res++;
    }
    cout << res+1 << endl;
    return 0;
}


Measured memory_bytes: 256
/*author:anshumanc007
   created on:09/01/2019
            */
//EMBRACE THE STRUGGLE!!!
#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
#define MAX 100005
long long int MOD=1e9+7;
long long int INF=1e18;

long long int dp[MAX][105];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,m,n,o,p,q,r,x,y,a,b,mini=INF,maxi=0,cnt=0,W,ans=0,iter=0,len;
    cin>>n>>k;
    long long int A[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(i=0;i<=k;i++)
    {
        for(j=0;j<=n;j++)
        {
            dp[j][i]=0;
        }
    }
     for(i=0;i<=n;i++)
     {
         dp[0][i]=1;
     }
    
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=n;j++)
        {
             dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
            if(A[j-1]<=(i-1))
                dp[i][j]=(dp[i][j]-dp[i-1-A[j-1]][j-1]+MOD)%MOD;
        }
    }
   cout<<dp[k][n]<<endl;
    

    
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    
    int diff = max(x,y) - min(x,y);
    int minxy = min(x,y);
    ll ans = 0;
    if((ll)(minxy*(a+b)) > (ll)(2*c)*minxy){
         ans  = (2*c)*minxy;
        if(x>y) ans += min((ll)diff*a,(ll)diff*(2*c));
        if(x<y) ans += min((ll)diff*b,(ll)diff*(2*c));
        cout<<ans;
    }
    else {
       ans = minxy*(a+b);
      if(x>y) ans += min((ll)diff*a,(ll)diff*(2*c));
      if(x<y) ans += min((ll)diff*b,(ll)diff*(2*c));
      cout<<ans;
    }
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

int n;
int d[15][15];
int dp[1<<15][15];

void solve()
{
  REP(i,(1<<n)) fill_n(dp[i],n,INF);
  dp[(1<<n)-1][0] = 0;
  DOWN(i,(1<<n)-2,0) REP(v,n) REP(u,n) if(!(i>>u&1))
    dp[i][v] = min(dp[i][v],dp[i|1<<u][u]+d[v][u]);
}

int main()
{
  int m; cin >> n >> m;
  REP(i,15) fill_n(d[i],15,INF);
  REP(i,m)
  {
    int s,t,c; cin >> s >> t >> c;
    d[s][t] = c;
  }
  solve();
  cout << (dp[0][0]==INF?-1:dp[0][0]) << endl;
  return 0;
}

Measured memory_bytes: 5016
from pprint import pprint
width, height, n = map(int, input().split())
rect = [[True for i in range(width)] for j in range(height)]
for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        for y_counter in range(height):
            x_counter = 0
            while x_counter < x:
                rect[y_counter][x_counter] = False
                x_counter += 1
    elif a == 2:
        for y_counter in range(height):
            x_counter = x
            while x_counter < width:
                rect[y_counter][x_counter] = False
                x_counter += 1
    elif a == 3:
        y_counter = 0
        while y_counter < y:
            for x_counter in range(width):
                rect[y_counter][x_counter] = False
            y_counter += 1
            
    elif a == 4:
        y_counter = y
        while y_counter < height:
            for x_counter in range(width):
                rect[y_counter][x_counter] = False
            y_counter += 1
count = 0
for i in rect:
    for j in i:
        if j == True:
            count += 1
print(count)

Measured memory_bytes: 3700
import sys
import itertools

# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    S = list(input())

    l = []
    down = 0  # "0"
    up = 0  # "1"
    flag = int(S[0])
    if not flag:
        l.append(0)
    for i in range(N):

        if int(S[i]) == 1:
            up += 1
            if down:
                l.append(down)
                down = 0
        if int(S[i]) == 0:
            down += 1
            if up:
                l.append(up)
                up = 0
    if up:
        l.append(up)
    else:
        l.append(down)

    if len(l)<=2*K+1:
        print(N)
        exit()
    total = sum(l[:2*K+1])
    ans =total
    flag =1
    csum=list(itertools.accumulate(l))
    for i in range(2,len(l) - 2 * K +1,2):
        right =min(i+2*K,len(l)-1)
        ans = max(ans, csum[right] - csum[i-1])

    print(ans)

if __name__ == "__main__":
    main()


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

import math
# スペース区切りの整数の入力
d, g = map(int, input().split())
#配列の入力
data = [list(map(int, input().split())) for _ in range(d)]
sn=1000

for i in range(2**d):
    ts = [False]*d
    score = 0
    tmp_sn = 0
    flg = True
    for j in range(d):
        if (i>>j)&1:
            ts[j] = True
            score += data[j][0]*100*(j+1)+data[j][1]
            tmp_sn += data[j][0]


    if score < g:
        for k in reversed(range(len(ts))):
            if  ts[k] == False:
                need = g - score
                s1 = (k+1) * 100
                nnum = math.ceil(need / s1)
                if nnum < data[k][0]:
                    tmp_sn += nnum
                    break
                else:
                    flg = False
                    break

    if flg == True and sn > tmp_sn:
        sn = tmp_sn

print(sn)








Measured memory_bytes: 9160
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int f = 0, ch = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
#define int ll
#define N (1000005)
int s[N], n, ans;
inline void checkmax(int &x, int y){ if(y > x) x = y; }
inline void checkmin(int &x, int y){ if(y < x) x = y; }
inline int solve(int L, int R){
	int l = L, r = R - 1, ans = l;
	while(l <= r){
		int mid = l + r >> 1;
		if(s[mid] - s[L-1] <= s[R] - s[mid]) 
			ans = mid, l = mid + 1; else r = mid - 1;
	}	
	return ans;
}
inline int solve2(int L, int R){
	int l = L, r = R - 1, ans = r;
	while(l <= r){
		int mid = l + r >> 1;
		if(s[mid] - s[L-1] > s[R] - s[mid]) 
			ans = mid, r = mid - 1; else l = mid + 1;
	}	
	return ans;
}
main(){
	read(n); int ans = (ll) (1e18);
	for(int i = 1; i <= n; i++) read(s[i]), s[i] += s[i-1];
	for(int i = 2; i <= n - 2; i++){
		int p1 = solve(1, i), p2 = solve(i + 1, n);
		int mx = 0, mn = (ll) (1e18);
		checkmax(mx, s[p1]), checkmax(mx, s[i] - s[p1]);
		checkmax(mx, s[p2] - s[i]), checkmax(mx, s[n] - s[p2]);	
		checkmin(mn, s[p1]), checkmin(mn, s[i] - s[p1]);
		checkmin(mn, s[p2] - s[i]), checkmin(mn, s[n] - s[p2]);
		checkmin(ans, abs(mx - mn));
	}
	for(int i = 2; i <= n - 2; i++){
		int p1 = solve2(1, i), p2 = solve(i + 1, n);
		int mx = 0, mn = (ll) (1e18);
		checkmax(mx, s[p1]), checkmax(mx, s[i] - s[p1]);
		checkmax(mx, s[p2] - s[i]), checkmax(mx, s[n] - s[p2]);	
		checkmin(mn, s[p1]), checkmin(mn, s[i] - s[p1]);
		checkmin(mn, s[p2] - s[i]), checkmin(mn, s[n] - s[p2]);
		checkmin(ans, abs(mx - mn));
	}
	for(int i = 2; i <= n - 2; i++){
		int p1 = solve(1, i), p2 = solve2(i + 1, n);
		int mx = 0, mn = (ll) (1e18);
		checkmax(mx, s[p1]), checkmax(mx, s[i] - s[p1]);
		checkmax(mx, s[p2] - s[i]), checkmax(mx, s[n] - s[p2]);	
		checkmin(mn, s[p1]), checkmin(mn, s[i] - s[p1]);
		checkmin(mn, s[p2] - s[i]), checkmin(mn, s[n] - s[p2]);
		checkmin(ans, abs(mx - mn));
	}
	for(int i = 2; i <= n - 2; i++){
		int p1 = solve2(1, i), p2 = solve2(i + 1, n);
		int mx = 0, mn = (ll) (1e18);
		checkmax(mx, s[p1]), checkmax(mx, s[i] - s[p1]);
		checkmax(mx, s[p2] - s[i]), checkmax(mx, s[n] - s[p2]);	
		checkmin(mn, s[p1]), checkmin(mn, s[i] - s[p1]);
		checkmin(mn, s[p2] - s[i]), checkmin(mn, s[n] - s[p2]);
		checkmin(ans, abs(mx - mn));
	}
	cout << ans << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: tenka1-procon-2017_d / Link: https://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_d?lang=en  ----- */
/* ------問題------

非負整数専門店「せいすうや」には、N 個の非負整数が売られています。i 個目の非負整数は Ai で、その価値は Bi です。 価値の異なる同じ非負整数が複数売られていることもあります。
高橋君は、「せいすうや」でいくつかの整数を買うことにしました。高橋君は、買う整数たちの bitwise or が K 以下になるような 任意の組み合わせで、整数を買うことができます。高橋君は、買った整数たちの価値の総和をできるだけ大きくしたいです。
高橋君が達成できる、価値の総和の最大値を求めてください。ただし、bitwise or とは、ビットごとの論理和を表します。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,K;

LL ans = 0LL;



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

	cin >> N>>K;
	VL val(N), cost(N);
	FOR(i, 0, N) {
		cin >> val[i] >> cost[i];
	}


	// K 以下の bin, 000010/11111をつくる
	FOR(i, 0, 30) {
		LL num = 0;
		LL ret = 0;
		if ((K&(1 << i)) == 0) {
			continue;
		}
		// Kのあるビットをへし折ったときはK以下になる
		FOR(j, 0, i) {
			num |= (1 << j);
		}
		FOR(j, i + 1, 31) {
			if (K&(1 << j))num |= (1 << j);
		}
		//print_bin(num);
		FOR(j, 0, N) {
			if ((num | val[j]) == num) {
				ret += cost[j];
			}
		}
		ans = max(ans, ret);
	}
	{
		LL ret = 0;
		LL num = K;
		FOR(j, 0, N) {
			if ((num | val[j]) == num) {
				ret += cost[j];
			}
		}
		ans = max(ans, ret);

	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
N, M, *A = map(int, open(0).read().split())
MOD = 10**9 + 7
F = [1]*(N+1)
for j in A:
    F[j-1] = 0
 
a = 1; b = 0
for i in range(N):
    if not F[i]:    #F[i] == 0
        a, b = 0, a
    else:
        a, b = ((a+b) % MOD), a
print(a)

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

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

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    int redcoder = 0;
    vector<int> color(8, 0);
    for(int i = 0; i < N; i++){
        if(1 <= a[i] && a[i] < 400) color[0]++;
        else if(400 <= a[i] && a[i] < 800) color[1]++;
        else if(800 <= a[i] && a[i] < 1200) color[2]++;
        else if(1200 <= a[i] && a[i] < 1600) color[3]++;
        else if(1600 <= a[i] && a[i] < 2000) color[4]++;
        else if(2000 <= a[i] && a[i] < 2400) color[5]++;
        else if(2400 <= a[i] && a[i] < 2800) color[6]++;
        else if(2800 <= a[i] && a[i] < 3200) color[7]++;
        else redcoder++;
    }

    int count = 0;
    for(int i = 0; i < color.size(); i++) if(color[i] > 0) count++;

    cout << max(1, count) << " " << count + redcoder << endl;

    return 0;
}

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

const int MAXN = 200010;

int a[MAXN], n;

inline bool solve()
{
	int cnt0 = 0, cnt1 = 0, d = 0;
	for( int i = 1 ; i <= n ; i++ )
		if( a[ i ] & 1 ) cnt1++;
		else cnt0++;
	if( cnt0 & 1 ) return true;
	if( cnt1 ^ 1 ) return false;
	for( int i = 1 ; i <= n ; i++ )
		if( ( a[ i ] & 1 ) && ( a[ i ] != 1 ) )
		{
			a[ i ]--;
			for( int j = 1 ; j <= n ; j++ ) d = __gcd( d, a[ j ] );
			for( int j = 1 ; j <= n ; j++ ) a[ j ] /= d;
			return ( solve() ^ 1 );
		}
	return false;
}

int main()
{
	scanf( "%d", &n );
	for( int i = 1 ; i <= n ; i++ ) scanf( "%d", &a[ i ] );
	if( n == 1 ) return printf( "Second\n" ), 0;
	if( solve() ) return printf( "First\n" ), 0;
	return printf( "Second\n" ), 0;
}


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

int main() {
  int A,B;
  scanf("%d %d", &A,&B);
  int M[5];
  int stone;

  int count = 0;

  for (int i = A;i<B+1;i++){
    stone = i;
    for(int ii = 0; ii<5; ii++){
      M[ii] = stone%10;
      stone /= 10;
    }

    if(M[0]==M[4] && M[1] == M[3]) count++;
  }

  cout << count << endl;

}

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

int main() {
   long N;
   cin >> N;
   vector<long> A;

   for(int i=1; i<=N; i++) {
      if(i % 3 != 0 && i % 5 != 0) {
         A.push_back(i);
      }
   }

   long sum = 0;
   for(int i=0; i<A.size();i++) {
      sum += A[i];
   }
   cout << sum << endl;
}

Measured memory_bytes: 11564
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (a > b) {
        swap(a, b);
    }

    if (a == 1 && b == 2) {
        cout << "3" << endl;
    } else if (a == 1 && b == 3) {
        cout << "2" << endl;
    } else {
        cout << "1" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
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, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n,k,sum=0;
    int l[55]={};
    cin>>n>>k;
    rep(i,0,n)cin>>l[i];
    sort(l,l+n);
    rep(i,0,k){
        sum+=l[n-1-i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class CGrandGarden {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in>>n;
        vector<ll> h(n+1,0);
        ll ma=0;
        rep(i,n) {
            in>>h[i];
            ma=max(ma,h[i]);
        }
        ll ans=0;

        for(ll i=1; i<=ma; ++i){
            for(ll j=0; j<n; ++j){
                if(h.at(j)>=i && h.at(j+1)<i) ++ans;
            }
        }

        out<<ans<<endl;
	}
};


int main() {
	CGrandGarden solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

int main()
{
    ll n, m;
    while (cin >> n >> m)
    {
        ll t1 = n / 2019, t2 = m / 2019;
        if (t2 - t1 >= 1)
            cout << 0 << endl;
        else
        {
            ll ans = INF;
            ll a = n % 2019, b = m % 2019;
            if (a > b)
                swap(a, b);
            for (ll i = a; i < b; i++)
            {
                for (ll j = i + 1; j <= b; j++)
                    ans = min((i * j) % 2019, ans);
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int ls = s.size(), lt = t.size();
  vector<vector<int>> cnt(ls,vector<int>(lt));
  for(int i = 0; i < ls; ++i){
    for(int j = 0; j < lt; ++j){
      if(i > 0 and j > 0){
	if(s[i] == t[j]) cnt[i][j] = 1+cnt[i-1][j-1];
	else cnt[i][j] = max(cnt[i-1][j],cnt[i][j-1]);
      }
      else if(s[i] == t[j]) cnt[i][j] = 1;
      else if(i > 0) cnt[i][j] = cnt[i-1][j];
      else if(j > 0) cnt[i][j] = cnt[i][j-1];
    }
  }
  /*for(int i = 0; i < ls; ++i){
    for(int j = 0; j < lt; ++j){
      cout << cnt[i][j] << ' ';
    }
    cout << endl;
  }*/
  string ans;
  int x = ls-1, y = lt-1, l = cnt[x][y];
  while(true){
    if(l == 0) break;
    if(s[x] == t[y]){
      ans += s[x];
      --l;
      --x;
      --y;
    }
    else if(x > 0 and cnt[x-1][y] == cnt[x][y]) --x;
    else if(y > 0 and cnt[x][y-1] == cnt[x][y]) --y;
  }
  reverse(begin(ans),end(ans));
  cout << ans;
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll w,h,x,y;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> w >> h >> x >> y;

  double ans = (1.0*w*h)/2.0;

  int v = 0;
  if (w == 2*x && h == 2*y)
    v = 1;
  else
    v = 0;

  printf("%.12f %d\n", ans, v);


  return 0;
}


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

int main(void){
	int a, b;
	cin >> a >> b;
	int digit = 0;
	//int num = b;
	//while(num > 0){
	//	num = num % 10;
	//}
	long long int num = 0;
	if(b/10 == 0){ num = a*10 + b; }
	else if(b/100 == 0){ num = a*100 + b; }
	else{ num = a*1000 + b; }

	bool non = false;
	for(int i=0; i<num; ++i){
		if(i*i == num){
			non = true;
			break;
		}
	}
	if(non) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>

#define sz(a) (int)((a).size())

using namespace std;

mt19937 rnd(239);

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    ll x, y, z, t;
    if (!(cin >> x))
        return 1;
    cin >> y >> z >> t;
    cout << min(x, y) + min(z, t) << endl;
    return 0;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    int T = 100;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        #ifdef ONPC
            cerr << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int K[];
  static int Like[];
  static int check[];
  static int A;
  static int count=0;
  public static void main(String args[]){
    check = new int[33];
    for(int i=0;i<33;i++){
      check[i]=0;
    }
    Scanner sc = new Scanner(System.in);
    int N;
    int M;
    N = sc.nextInt();
    M = sc.nextInt();
    K = new int[N];
  for(int i=0;i<N;i++){
    K[i]=sc.nextInt();
    for(int j=0;j<K[i];j++){
      A = sc.nextInt();
      check[A] += 1;
    }
  }
  for(int i=0;i<33;i++){
    if(check[i]==N){
      count += 1;
    }
  }
  System.out.println(count);
  }
}


Measured memory_bytes: 22700
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = list(input().rstrip())

    ans = ""

    for x in s:
        i = ord(x) + n
        if i > 90:
            i = i - 26

        ans += chr(i)

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#
# abc087 b
#
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ret = 0
for i in range(a+1):
    if (i * 500) > x:
        break
    for j in range(b+1):
        if (i * 500) + (j * 100) > x:
            break
        if (i * 500) + (j * 100) + (c * 50) >= x:
            ret += 1

print(ret)


Measured memory_bytes: 3060
using System;

class B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static void Main()
	{
		var z = Read();
		int h = z[0], w = z[1], n = z[2];
		var p = Read();
		var s = Console.ReadLine();
		var t = Console.ReadLine();

		// L, U
		{
			int x = p[1], y = p[0];
			for (int i = 0; i < n; i++)
			{
				if (s[i] == 'L' && --x < 1) { Console.WriteLine("NO"); return; }
				if (t[i] == 'R' && x < w) x++;

				if (s[i] == 'U' && --y < 1) { Console.WriteLine("NO"); return; }
				if (t[i] == 'D' && y < h) y++;
			}
		}

		// R, D
		{
			int x = p[1], y = p[0];
			for (int i = 0; i < n; i++)
			{
				if (s[i] == 'R' && ++x > w) { Console.WriteLine("NO"); return; }
				if (t[i] == 'L' && x > 1) x--;

				if (s[i] == 'D' && ++y > h) { Console.WriteLine("NO"); return; }
				if (t[i] == 'U' && y > 1) y--;
			}
		}

		Console.WriteLine("YES");
	}
}


Measured memory_bytes: 29124
#include <stdio.h>

int main()
{
int i;
int esc_box;
int list[4];
int chk_val;
chk_val = 1;

scanf("%d %d %d",&list[0],&list[1],&list[2]);

while (chk_val == 1)
{
chk_val = 0;

for (i = 0 ; i < 2 ; i++)
{

if (list[i] > list[i+1])
{
esc_box = list[i];
list[i] = list[i+1];
list[i+1] = esc_box;
chk_val =1;

}

}

}

printf("%d %d %d\n",list[0],list[1],list[2]);
return 0;
}

Measured memory_bytes: 596
line = input().strip()
N,K = line.split(" ")
N = int(N)
K = int(K)

flavors = 0
min_data = 10000000000000000
flag = False

for i in range(N):
    flavor = K  + i
    flavors += flavor
    if abs(min_data) > abs(flavor): min_data = flavor
    if flavor == 0: flag = True

if flag: print(flavors)
else: print(flavors - min_data)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int N,X[99],Y[99],i,j;
double x=0,y=0;
#define ll long long
double d(int a,int b)
{
	double e,f;
	return sqrt((e=(double)abs(X[a]-X[b]))*e+(f=(double)abs(Y[a]-Y[b]))*f);
}

double c(int a)
{
	double l1=d((a-1+N)%N,a);
	double l2=d(a,(a+1)%N);
	double l3=d((a-1+N)%N,(a+1)%N);
	double t1=pow(l3,2)-pow(l1,2)-pow(l2,2);
	return (t1)/((-2)*l1*l2);
}

int ch()
{
	int i,j;
	if(N%2)return 0;
	for(i=0;i<N/2;i++)
	{
		double a=c(i);
		double b=c(i+N/2);
		if(c(i)!=c(i+N/2))
			return 0;
	}
	return 1;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d",X+i,Y+i);
		x+=X[i];
		y+=Y[i];
	}
	ch()?printf("%lf %lf\n",x/N,y/N):puts("NA");
	return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int k,t;
  cin >> k >> t;
  int a[t];
  for(int i = 0; i < t; i++) {
    cin >> a[i];
  }
  sort(a,a+t,greater<int>());
  cout << max(0,a[0]-1 - (k-a[0])) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100001
#define M 1000000001
using namespace std;
int n,k,w[N];

bool check(int P){
  int x=0,sum;
  for(int i=0;i<k;i++){
    sum=0;
    for(int j=x;j<n;j++)
      if(sum+w[j]<=P)sum+=w[j],x++;
      else break;
    if(x==n)return true;
  }
  return false;
}

int bynary_search(){
  int l=0,r=M;
  while(l<r){
    int m=(l+r)/2;
    if(check(m))r=m;
    else l=m+1;
  }
  return l;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>w[i];
  cout<<bynary_search()<<endl;
  return 0;
}

Measured memory_bytes: 1552
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int K, S; cin >> K >> S;
	int ans = 0;
	rep(i, K + 1) rep(j, K + 1) {
		if (i + j <= S && S - i - j <= K) ans++;
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define N 40010
using namespace std;
int a[2];
int main(){
	int a,b;
	cin>>a>>b;
	int d=b*10;
	//cout<<d<<endl;
	for(int i=d;i<=d+9;i++){
		//cout<<(double(i)*0.08)<<endl;
		if(floor(double(i)*0.08)==a){
			cout<<i<<endl; 
			return 0;
		}
	}
	cout<<"-1"<<endl;
}

Measured memory_bytes: 256
//h
#include <stdio.h>
 
int main(){
    long long int a;
    scanf("%lld",&a);
 
    char name[100];
    int i=0;
    
    while(a!=0)
	{
        a--;
        int b = a%26;
        name[i] ='a'+ b;
        a/=26;
        i++;
    }
 
    for(int j=i-1;j>=0;j--)
	{
        printf("%c",name[j]);
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
map<int, bool> m;
vector<int> v;
int main() {
	int n;
	scanf("%d",&n);
	for (int i = 0; i < n;i++) {
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	bool flag = true;
	for (int i = 0; i < n;i++) {
		if (m.count(v[i]) == 0) {
			m[v[i]] = true;
		}
		else {
			flag = false;
			break;
		}
	}
	if (flag) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    ll N, X;  cin >> N >> X;
    vector<ll> x(N);  rep(i, N) cin >> x[i];

    x.push_back(X);
    sort(all(x));
    vector<ll> m;
    rep(i, x.size()-1) {
        m.push_back(x[i+1] - x[i]);
    }

    ll gcd = m[0];
    rep(i, m.size()) {
        gcd = __gcd(gcd, m[i]);
    }

    print(gcd);
}


Measured memory_bytes: 2800
from collections import defaultdict
from math import atan2, gcd

N = int(input())
MOD = 1000000007

d = defaultdict(lambda: [0, 0])

zero = 0
pos = []
neg = []
for _ in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue
    if a < 0:
        a = -a
        b = -b
    elif a == 0 and b > 0:
        b = -b
    if b >= 0:
        pos.append((a, b))
    else:
        neg.append((a, b))

for a, b in pos:
    if b != 0:
        g = gcd(a, b)
    else:
        g = a
    d[(a // g, b // g)][0] += 1
for a, b in neg:
    a, b = -b, a
    if b != 0:
        g = gcd(a, b)
    else:
        g = a
    d[(a // g, b // g)][1] += 1

ans = 1
for p, n in d.values():
    ans *= pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans %= MOD

ans += zero -1
ans %= MOD
print(ans)

Measured memory_bytes: 143116
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;

int n,k;

int main() {
	scanf("%d %d",&n,&k);
	LL ans=0;
	LL x=n/k;
	ans+=x*x*x;
	if(k%2==0) {
		LL y=n/(k/2);
		y-=x;
		ans+=y*y*y;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int c[3][3];
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++) cin>>c[i][j];
	bool ans=true;
	for(int i=0;i<2;i++){
		int temp=c[i+1][0]-c[i][0];
		for(int j=1;j<3;j++){
			if(temp!=c[i+1][j]-c[i][j]) ans=false;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

// range add range sum
class LazySegmentTree {
  int n;
  using T1 = ll;
  using T2 = ll;
  std::vector<T1> node;
  std::vector<T2> lazy;

  // 遅延評価
  void eval(int k, int l, int r) {
    // 遅延配列が空なら終了
    if (lazy[k] == 0) return;
    // 遅延配列を適用
    node[k] = node[k] + lazy[k];
    if (r - l > 1) {
      lazy[2 * k + 1] = lazy[2 * k + 1] + lazy[k] / 2;
      lazy[2 * k + 2] = lazy[2 * k + 2] + lazy[k] / 2;
    }
    // 遅延配列初期化
    lazy[k] = 0;
  }

 public:
  LazySegmentTree(int _n) {
    int sz = _n;
    n = 1;
    while (n < sz) n *= 2;
    // 配列初期化
    node.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
  }
  // 半開区間 [a, b) に対して値 val を反映させる
  void update(int a, int b, T2 val, int l = 0, int r = -1, int k = 0) {
    if (r < 0) r = n;
    // ノード k で遅延評価
    eval(k, l, r);
    if (b <= l || r <= a) return;
    // 区間が被覆されている場合
    if (a <= l && r <= b) {
      // 遅延配列更新, 評価
      lazy[k] = lazy[k] + (r - l) * val;
      eval(k, l, r);
    } else {
      // 子ノードの値を評価し, 更新
      int mid = (l + r) / 2;
      update(a, b, val, l, mid, 2 * k + 1);
      update(a, b, val, mid, r, 2 * k + 2);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }

  // 半開区間 [a, b) に対してクエリを投げる
  T1 query(int a, int b, int l = 0, int r = -1, int k = 0) {
    if (r < 0) r = n;
    eval(k, l, r);
    // 範囲外なら単位元返す
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];
    int mid = (l + r) / 2;
    T1 vl = query(a, b, l, mid, 2 * k + 1);
    T1 vr = query(a, b, mid, r, 2 * k + 2);
    return vl + vr;
  }
};

const int MAX_N = 200010;
LazySegmentTree seg(MAX_N);

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<ll> x(n), h(n);
  vector<P> ps;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> h[i];
    ps.push_back(P(x[i], h[i]));
  }
  sort(ps.begin(), ps.end());
  for(int i=0;i<n;i++){
      x[i] = ps[i].first;
      h[i] = ps[i].second;
  }
  ll ret = 0;
  for(int i=0;i<n;i++){
      ll sum = seg.query(i, i+1);
      if(h[i]<=sum) continue;
      h[i] -= sum;
      ll cnt = (h[i]-1)/a+1;
      ret += cnt;
      auto itr = upper_bound(x.begin(),x.end(), x[i]+2*d);
      int idx = distance(x.begin(), itr);
      seg.update(i, idx, a * cnt);
  }
  cout << ret << endl;
}


Measured memory_bytes: 17520
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

#define minimum(a, b) (((a) < (b)) ? a : b)
vector<ll> vi;

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int> > c, D, sum;
  D = vector<vector<int> >(C + 1, vector<int>(C + 1, 0));
  c = vector<vector<int> >(3, vector<int>(C + 1, 0));
  sum = vector<vector<int> >(3, vector<int>(C + 1, 0));
  REP(i, C) REP(j, C) cin >> D[i + 1][j + 1];
  int tmp = 0, klass = 0;
  REP(i, N) REP(j, N) {
    cin >> tmp;
    klass = (i + j) % 3;
    c[klass][tmp]++;
  }

  for (klass = 0; klass < 3; klass++) {
    for (int target = 1; target <= C; target++) {
      for (int from = 1; from <= C; from++) {
        if (from == target) continue;
        sum[klass][target] += c[klass][from] * D[from][target];
      }
    }
  }

  ll min = 0x7FFFFFFFFFFFFFFF;
  for (int i1 = 1; i1 <= C; i1++) {
    for (int i2 = 1; i2 <= C; i2++) {
      for (int i3 = 1; i3 <= C; i3++) {
        if (i1 == i2 || i2 == i3 || i3 == i1) continue;
        // cerr << "(" << i1 << "," << i2 << "," << i3 << ")" << endl;
        // cerr << sum[0][i1] << "," << sum[1][i2] << "," << sum[2][i3] << endl;
        min = minimum(sum[0][i1] + sum[1][i2] + sum[2][i3], min);
      }
    }
  }
  cout << min << endl;

  return 0;
}


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

int main() {
  int L,R,d;
  int ans =0;

  cin >> L >> R >> d;
  for(int i=L;i<=R;++i){
    if(i%d == 0) ans += 1;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3632
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*34+bin(int(x))[2:])[-33:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())

    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
        return 'Yes'
    
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'

        if vals[0]*2==vals[1] and ("1" not in keys[0]):
            return 'Yes'
        
        if vals[0]==vals[1]*2 and ("1" not in keys[1]):
            return 'Yes'
        
        return 'No'
    if len(keys)==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())


Measured memory_bytes: 19964