akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >>f;
	double conc = -1;
	int ans_total_weight = -1;
	int ans_sugar_weight = -1;
	for(int a_i = 0; a_i*a*100 <= f; a_i++){
		for(int b_i = 0; a_i*a*100 + b_i*b*100 <= f; b_i++){
			for(int c_i = 0; a_i*a*100 + b_i*b*100 + c_i*c <= f; c_i++){
				for(int d_i = 0; a_i*a*100 + b_i*b*100 + c_i*c + d_i*d <= f; d_i++){

					if( (e*(a_i*a + b_i*b) >= (c_i*c + d_i*d)) && (a_i*a+b_i*b > 0)){
						double temp_conc = (c_i*c + d_i*d);
						temp_conc /= (a_i*a*100 + b_i*b*100);
						if(conc <= temp_conc){
							conc = temp_conc;
							ans_total_weight = a_i*a*100 + b_i*b*100 + c_i*c + d_i*d;
							ans_sugar_weight = c_i*c + d_i*d;
						//	cout << a_i*a*100 << " " << b_i*b*100 << " " << c_i*c << " " << d_i*d<< " "<<conc << endl;
						}
					}

				}
			}
		}
	}
	cout << ans_total_weight << " "<<ans_sugar_weight << endl;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  cout << max(max(a, b), c) - min(min(a, b), c) << endl;
}

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

keta = 1
now_26 = 26
while N > now_26:
  keta += 1
  now_26 += 26 ** keta

num = N - int(now_26 - 26 ** keta) -1

answer = ""
for i in range(keta):
  answer += chr(97 + num % 26)
  num = num // 26

print(answer[::-1])

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,l;
  cin>>n>>l;
  vector<Int> v(n),w(n),m(n);
  for(Int i=0;i<n;i++)
    cin>>v[i]>>w[i]>>m[i];

  const Int x=50;
  const Int INF = 1e15;
  vector<Int> dp(n*x*x+1,INF);
  dp[0]=0;
  for(Int i=0;i<n;i++){
    Int s=min(m[i],x);
    m[i]-=s;
    for(Int k=1;;k<<=1){
      chmin(k,s);
      if(!k) break;
      for(Int j=n*x*x;j>=0;j--)
	if(j+k*v[i]<=n*x*x) chmin(dp[j+k*v[i]],dp[j]+k*w[i]);	
      s-=k;      
    }
  }

  vector<Int> ord(n);
  iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](Int a,Int b){
      return v[a]*w[b]>v[b]*w[a];
    });

  Int ans=0;
  for(Int j=0;j<=n*x*x;j++){
    Int lim=l-dp[j];
    if(lim<0) continue;
    Int res=j;
    for(Int i=0;i<n;i++){
      Int k=ord[i];
      Int c=min(m[k],lim/w[k]);
      lim-=w[k]*c;
      res+=v[k]*c;      
    }
    chmax(ans,res);
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3880
N = int(input())
A = list(map(int, input().split()))

res = 1<<30
cand = -100
while cand <= 100:
    tmp = 0
    for a in A:
        dif = cand - a
        tmp += dif*dif
    res = min(res, tmp)


    cand += 1

print(res)

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

int main() {	
 int x,y;
  cin>>x>>y;
  if(x==2&&y==2)
    cout<<"Yes"<<endl;
  else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
      cout<<"Yes"<<endl;
  else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
      cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
    
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  int n,k,ans=0,h;cin>>n>>k;
  REP(i,n){
    cin>>h;
    if(h>=k) ans++;
  }
  cout<<ans;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x;
    cin >> x;
    cout << (10-x/200) << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define repeat(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int N;
  cin >>N;
  
  vector<int>W(N);
  int sum=0;
  repeat(i,N){
    cin >> W[i];
    sum += W[i];
  }
  
  vector<int>diff(N-1);
  int S1=0, S2=0;
  repeat(i,N-1){
    S1 += W[i];
    S2 = sum-S1;
    diff[i] = abs(S1-S2);
  }
  
  int ans;
    
  ans = *min_element(diff.begin(),diff.end());
    
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n;
    cin >> n;

    vector<pii> lr;
    int mal = -1, mir = INF;
    rep(i,n){
        int l,r;
        cin >> l >> r;
        l--;
        mal = max(mal, l);
        mir = min(mir, r);
        lr.emplace_back(l,r);
    }

    int ans = 0;
    pii x;
    each(x,lr){
        ans = max(ans, max(0, mir - mal) + (x->se - x->fi));
    }

    vector<pii> t;
    rep(i,n){
        int l = lr[i].fi, r = lr[i].se;
        int a = max(0, mir - l);
        int b = max(0, r - mal);
        t.emplace_back(b, -a);
    }

    sort(all(t));
    int k = INF;
    rep(i,n){
        int a = -t[i].se, b = t[i].fi;
        if(i) ans = max(ans, k + b);
        k = min(k, a);
        // debug(a, b, k, ans)
    }
    cout << ans << endl;
    return 0;
}


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

struct _dice {
    int num[7];
    void roll(char x);
};

void _dice::roll(char o){
    int tmp[7];
    for (int i=1; i<7; i++) tmp[i] = num[i];
    if (o == 'E'){
        num[1] = tmp[4];
        num[3] = tmp[1];
        num[6] = tmp[3];
        num[4] = tmp[6];
    }
    if (o == 'W'){
        num[4] = tmp[1];
        num[1] = tmp[3];
        num[3] = tmp[6];
        num[6] = tmp[4];
    }
    if (o == 'N'){
        num[1] = tmp[2];
        num[2] = tmp[6];
        num[6] = tmp[5];
        num[5] = tmp[1];
    }
    if (o == 'S'){
        num[1] = tmp[5];
        num[5] = tmp[6];
        num[6] = tmp[2];
        num[2] = tmp[1];
    }
}

int main(){
    _dice dice;
    string ord;
    for (int i=1; i<7; i++) cin >> dice.num[i];
    cin >> ord;
    for (int i=0; i<ord.size(); i++) dice.roll(ord[i]);
    cout << dice.num[1] << endl;
    return 0;
}


Measured memory_bytes: 3220
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=input()
    keta=len(n)
    saileft=int(n[0])
    if n[1:].count('9')==keta-1:
        print(saileft+(keta-1)*9)
    else:
        print(saileft-1+9*(keta-1))
resolve()


Measured memory_bytes: 38424
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
       int kazu=sc.nextInt();
      if(1000-(kazu%1000)!=1000){
       System.out.println(1000-(kazu%1000));
      }else{
        System.out.println(0);
      }
}
}

Measured memory_bytes: 35592
#include <bits/stdc++.h>
#define ll long long
#define NMAX
using namespace std;
ll a, b, c, k, sum;
int main()
{
    cin>>a>>b>>c>>k;
    sum+=min(a,k);
    k=k-min(a,k);
    if(k>0)
    k=k-min(b,k);
    if(k>0)
    {
        sum=sum-min(c,k);
        k=k-min(c,k);
    }
    cout<<sum<<' ';
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll n;
vector<ll>v[100005];
ll dp[100005][2];
ll func(ll i,ll c,ll pre)
{
//	cout<<i<<" "<<c<<endl;
	if(dp[i][c]!=-1)
		return dp[i][c];
//	visited[i]=1;
	ll j, ans=1,flag=0;
	for(j=0; j<v[i].size(); j++)
	{
		if(c==0 && v[i][j]!=pre)
		{
			flag++;
			ans=((ans%mod)*((func(v[i][j],c,i)%mod)+(func(v[i][j],1-c,i)%mod)))%mod;
		}
		else if(c==1 && v[i][j]!=pre)
		{
			ans=((ans%mod)*(func(v[i][j],1-c,i)%mod))%mod;
			flag++;
		}
	}
	if(flag==0)
		ans=1;
	return dp[i][c]=ans;
}
int main()
{
	boost
	cin>>n;
	ll i;
	for(i=0; i<(n-1); i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(i=0; i<100005; i++)
	{
		dp[i][0]=-1;
		dp[i][1]=-1;
	}
	ll ans1=func(1,0,0);
	ll ans2=func(1,1,0);
	cout<<((ans1+ans2)%mod)<<endl;
	return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
using ll = long long;

int gcd(int x,int y){
   return (y==0)? x: gcd(y,x%y);
   }

int main(){
int k;
ll ans = 0;
cin >> k;
for(int a = 1; a<= k; a++){
  for(int b= 1; b<= k; b++){
     for(int c = 1; c<= k; c++){
            ans += gcd(a, gcd(b,c));
          }
      }
  }
cout << ans <<endl;
return 0;
}
 

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

using namespace std;

#define fr(i,s,e) for(i=s;i<e;i++)

int main() {
    int i,x=700;
    string s;
    cin>>s;
    fr(i,0,3){
        if(s[i]=='o')
            x=x+100;
    }
    cout<<x;
return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,t,n;
    scanf("%d %d",&a,&b);

    if(b>a)
    {
        t=b;
        b=a;
        a=t;
    }
    n=a/b;
    if(n>=2)
    {
        printf(":(");
    }
    else
    {
        printf("Yay!");
    }
    return 0;

}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  unordered_map<ll, int> bk;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ++bk[x];
  }

  int cnt = 0;
  for (auto &a : bk) {
    if (a.first > a.second) {
      cnt += a.second;
    } else if (a.first < a.second) {
      cnt += a.second - a.first;
    }
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 4260
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1005;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,ans;
int ok;
int s[N],tmp[N];
int a[N][N];
int start[N];
bool vis[N];
int main()
{
	read(n);
	Rep(i,1,n)
		Rep(j,1,n-1)
			read(a[i][j]);
	s[0]=n;
	Rep(i,1,n)s[i]=i;
	Rep(i,1,n)start[i]=1;
	while(ok<n){
		int p=0;
		ans++;
		memset(tmp,0,sizeof(tmp));
		memset(vis,0,sizeof(vis));
		Rep(i,1,s[0]){
			int u=s[i];
			int v=a[u][start[u]];
			if(vis[u]||vis[v])continue;
			if(a[v][start[v]]==u){
				p++;
				start[u]++;
				start[v]++;
				tmp[++tmp[0]]=u;
				tmp[++tmp[0]]=v;
				vis[u]=true;
				vis[v]=true;
				if(start[u]==n)ok++;
				if(start[v]==n)ok++;
			}
		}
		memcpy(s,tmp,sizeof(tmp));
		if(!p)return puts("-1"),0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4224
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

W,H,N = LI()

s,t,u,v = 0,W,0,H
for i in range(N):
    x,y,a = LI()
    if a == 1:
        s = max(s,x)
    if a == 2:
        t = min(t,x)
    if a == 3:
        u = max(u,y)
    if a == 4:
        v = min(v,y)

if t > s and v > u:
    print(max(0,(t-s)*(v-u)))
else:
    print(0)


Measured memory_bytes: 62324
import java.util.*;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int maxCheese = sc.nextInt();
		int ans = 0;
		char[][] map = new char[h][w];
		int[][] path = new int[h][w];
		int[] startX = new int[maxCheese + 1];
		int[] startY = new int[maxCheese + 1];
		int[] moveX = {0,0,-1,1};
		int[] moveY = {-1,1,0,0};
		boolean[][] check = new boolean[h][w];
		
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
			for (int j = 0; j < map[i].length; j++) {
				if (map[i][j] == 'S') {
					startX[0] = j;
					startY[0] = i;
				} else if (map[i][j] != '.' && map[i][j] != 'X') {
					startX[map[i][j] - '0'] = j;
					startY[map[i][j] - '0'] = i;
				}
			}
		}
		
		for (int i = 0; i < startX.length - 1; i++) {

			int goalX = startX[i + 1];
			int goalY = startY[i + 1];
			Queue<Integer> queueX = new LinkedList<Integer>();
			Queue<Integer> queueY = new LinkedList<Integer>();

			path = new int[h][w];
			check = new boolean[h][w];
			
			path[startY[i]][startX[i]] = 0;
			check[startY[i]][startX[i]] = true;
			queueX.add(startX[i]);
			queueY.add(startY[i]);

			loop:
			while (!queueX.isEmpty()) {

				int x = queueX.poll();
				int y = queueY.poll();

				for (int j = 0; j < moveX.length; j++) {
					int nextX = x + moveX[j];
					int nextY = y + moveY[j];

					if (0 <= nextX && nextX < w &&
						0 <= nextY && nextY < h &&
						!check[nextY][nextX] &&
						map[nextY][nextX] != 'X') {
						
						check[nextY][nextX] = true;
						path[nextY][nextX] = path[y][x] + 1;
						queueX.add(nextX);
						queueY.add(nextY);
						
						if (nextY == goalY && nextX == goalX) {
							ans += path[nextY][nextX];
							break loop;
						}

					}

				}

			}

		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21000
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m=100,c=0;
    cin>>n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++) cin>>h[i];
    for(ll i=0;;){
        for(ll j=i;j<n && h[j]==0;i=++j);
        if(i==n) break;
        for(ll j=i;;j++){
            m=min(m,h[j]);
            if(j==n-1 || h[j+1]==0){
                for(ll k=i;k<=j;k++){
                    h[k]-=m;
                }
                c+=m;
                break;
            }
        }
        m=100;
    }
    cout<<c<<endl;
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200000], b[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i] >> b[i];

    sort(a, a + n);
    sort(b, b + n);

    cout << (n % 2 ? b[n/2] - a[n/2] : b[n/2-1] + b[n/2] - a[n/2-1] - a[n/2]) + 1 << "\n";

    return 0;
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;


int main() {
  int a[5], k;
  rep(i,5) cin >> a[i];
  cin >> k;
  if(a[4]-a[0]>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007

ll now = 0,ans = 0,n;
string s;
int main() {
	cin >> n >> s;
	REP(i, n) {
		if (s[i] == 'I')now++;
		else now--;
		ans = max(ans, now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin);freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define MAX 200005
#define v_n 5005
#define e_n 5000005
#define eps 0
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
vector<int> hh[MAX];
int work[MAX];
int bck[MAX];
int dp[MAX];
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	int N;
	scanf("%d", &N);
	up(i, 1, N)
	{
		scanf("%d", &work[i]);
		if (hh[work[i]].empty() || i >1+bck[work[i]])
		{
			hh[work[i]].push_back(i);
			bck[work[i]] = i;
		}
		if (bck[work[i]] == i - 1)
		{
			bck[work[i]]++;
		}
	}
	dp[0]=dp[1] = 1;
	up(i, 2, N)
	{
		int net=upper_bound(hh[work[i]].begin(), hh[work[i]].end(), i)- hh[work[i]].begin()-1;
		if (net >= 0)
		{
			dp[i] = (dp[i] + dp[hh[work[i]][net]-1]) % MOD;
			if(net>=1&&hh[work[i]][net-1]>0)
			dp[i] = (dp[i] + dp[hh[work[i]][net-1]]) % MOD;
		}
		//cout << i << " " << dp[i] << endl;
		
	}
	printf("%d\n", dp[N] % MOD);
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=3e5 +10 ;
const LL MOD = 1e9+7;
int pre[N], n, nxt[3];
LL f[N]; char s[N];


int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%s", s); n=strlen(s);
	for (int i=0; i<n; ++i) pre[i+1] =( pre[i] + (s[i]-'a'+1))%3;
	
	bool flag= false;
	for (int i=0; i+1 < n; ++i)
		if ( s[i] ==s[i+1] ) flag= true;
	if ( !flag){
		puts("1"); return 0;
	}
	for (int i=0; i<3; ++i) nxt[i] = i==pre[n] ? n: n+1;
	f[n] = 1;
	for (int i=n; i--; ){
		f[i] = i&&pre[i] == pre[n];
		for (int c=0; c<2; ++c)
			f[i] =(f[i] + f[ nxt[(pre[i]+c+1)%3] ])%MOD;
		nxt[ pre[i]] = i;
	}
	cout<<f[0]<<endl;
	return 0;
	
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fore(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define ordenar(a) sort(all(a))
typedef long long ll;
typedef vector<int> vi;

string a, b;

int main(){
    IOS

    cin>>a, b = a;

    reverse(all(b));
    
    int cont = 0;

    fore(i,0,(int)a.size()/2){
        if(a[i]!=b[i]) cont++;
    }

    cout<<cont;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;

signed main(){
    int n, sum = 0;
    cin >> n;
    vector<int> a(n), b(n);
    int MIN = INF;
    bool f = true;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] != b[i]) f = false;
        sum += a[i];
        if(a[i] > b[i]) MIN = min(MIN, b[i]);
    }
    if(f) cout << 0 << endl;
    else cout << sum - MIN << endl;
}

Measured memory_bytes: 512
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt = 0
    for i in range(N):
        if A[i] >= B[i]:
            cnt += B[i]
        else:
            cnt += A[i]
            if A[i+1] > B[i] - A[i]:
                cnt += B[i] - A[i]
                A[i+1] -= (B[i] - A[i])
            else:
                cnt += A[i+1]
                A[i+1] = 0
    print(cnt)

main()

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

using namespace std;
using Int = long long;

signed main(){
    Int r, d, x;
    cin >> r >> d >> x;
    Int ans[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

    Int tmp = x;
    for(int i = 0; i < 10; i++){
        tmp = r * tmp - d;
        ans[i] = tmp;
    }

    for(int i = 0; i < 10; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define endl '\n'
 
using namespace std;
 
int main(){
 
  cin.tie(0); // cout と cin の同期を切る
  ios::sync_with_stdio(false); /* cの stdioストリーム (printfとか)と*/

  long long N;
  
  long long sum[200001];

  cin>>N;

  sum[0]=0;

  long long a[200001];
 
  long long cnt=0;

  for(int i=1;i<=N;i++){
    cin>>a[i];
    sum[i]=(sum[i-1]+a[i]);
    if(sum[i]==0){
      cnt++;
    }
  }
  sort(sum+1,sum+N+1);
 
  long long temp=1;
 
  for(int i=1;i<N;i++){
    if(sum[i]!=sum[i+1]){
      if(temp>=2){
	cnt+=((temp-1)*(1+temp-1)/2);
 
      }
      temp=1;
    }else{
 
      temp++;
 
    }
  }
  if(temp>=2){
    cnt+=((temp-1)*(1+temp-1)/2);
  }
 
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string A, B;
  cin >> A >> B;
  int a = A.size(), b = B.size();
  if(a < b)
    cout << "LESS" << endl;
  else if(a > b)
    cout << "GREATER" << endl;
  else {
    string ans = "EQUAL";
    for(int i=0; i<a; i++) {
      if(A[i] > B[i]) {
	ans = "GREATER";
	break;
      } else if(A[i] < B[i]) {
	ans = "LESS";
	break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> vec;
	set<int> indices;
	for(int i = 0; i < h; i++) {
		string s;
		cin >> s;
		if(s.find('#') != string::npos) {
			vec.push_back(s);
			for(int j = 0; j < s.length(); j++){
				if(s[j] == '#') {
					indices.insert(j);
				}
			}
		}
	}
	for(int i = 0; i < vec.size(); i++) {
		for(int j = 0; j < vec[i].length(); j++) {
			if(indices.count(j)) {
				cout << vec[i][j];
			}
		}
		cout << 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;

int main()
{
    int N, count = 0;
    string A, B, C;
    set<char> s;
    cin >> N >> A >> B >> C;
    rep(i, N)
    {
        s.clear();
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        count += (s.size() - 1);
    }
    cout << count << endl;
}

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

int64_t cal(int64_t x,int64_t y,int64_t z){
    return x*x + y*y + z*z + x*y + y*z + z*x;
}

int main(){
    int64_t N;
    int64_t tmp = 0;
    bool finish;
    cin >> N;
    vector<int64_t> ans_list(N+1,0);
    for(int64_t i = 1; i <= 100;i++){
        for(int64_t j = i; j <= 100;j++){
            for(int64_t k = j; k <= 100; k++){
                //cout << i << j << k << endl;
                tmp = cal(i,j,k);
                if(tmp <= N){
                    if(i<j && j<k){
                        ans_list.at(tmp) += 6;
                    }else if((i<j && j==k) || (i==j && j<k)){
                        ans_list.at(tmp) += 3;
                    }else{
                        ans_list.at(tmp) += 1;
                    }
                }
            }
        }
    }
    for(int64_t a = 1; a <= N; a++){
        cout << ans_list.at(a) << endl;
    }
}

Measured memory_bytes: 3668
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(20);
    ll last=0;
    ll sum=0;
    V vec2(n);
    rep(i,n)cin>>vec2[i];
    rep(i,n){
        ll x=vec2[i];
        rep(j,20){
            if(x&(1<<j)){
                vec[j]++;
            }
        }
        bool h=true;
        rep(j,20){
            if(vec[j]>=2){
                h=false;
                break;
            }
        }
       /* for(auto i:vec){
            cout<<i<<" ";
        }
        cout<<endl;*/
        if(h)continue;
      //  cout<<vec2[last]<<"の続きは"<<vec2[i]<<"で重なる"<<endl;
      //  cout<<vec2[i]<<" "<<sum<<endl;
        while(1){
            ll temp=vec2[last];
            sum+=i-last;
          //  cout<<temp<<"を削除"<<endl;
            rep(j,20){
                if(temp&(1<<j)){
                    vec[j]--;
                }
            }
            last++;
          /*  for(auto i:vec){
                cout<<i<<" ";
            }
            cout<<endl;*/
            bool f=true;
            rep(j,20){
                if(vec[j]>=2){
                    f=false;
                }
            }
            if(f)break;
            
        }
        
    }
  //  ll dis=n-last;
    for(int i=last;i<n;i++){
        sum+=n-i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()

	Y := S[0:2]
	M := S[2:4]

	ans := check(Y, M) << 0
	ans |= check(M, Y) << 1
	if ans == 3 {
		fmt.Println("AMBIGUOUS")
	} else if ans == 1 {
		fmt.Println("YYMM")
	} else if ans == 2 {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}

}

func check(Y string, M string) int {

	if "00" <= Y && Y <= "99" {

	} else {
		return 0
	}
	if "01" <= M && M <= "12" {

	} else {
		return 0
	}
	return 1
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int arr[n],i,res=0;
    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(i=0;i<k;i++)
        res+=arr[i];
    cout<<res;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

bool check = 0;
bool boo = 0;
ll minn = INF, maxx = 0;
int ans = 0;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    double d, t, s;
    cin >> d >> t >> s;

    if (d / s <= t)
        Yes();
    else
        No();
    return 0;
}


Measured memory_bytes: 3736
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, m;
  cin >> n >> m;
  if (n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[2100];
int q[2100];
int r[2100];
int UF[1100];
vector<pair<int,int> >g[1100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
pair<int,pair<int,int> > edge[2100];
int vis[2100];
int calc(int a,int b){
	for(int i=0;i<1100;i++)vis[i]=0;
	queue<pair<int,int> >Q;
	Q.push(make_pair(a,0));
	vis[a]=1;
	while(Q.size()){
		int at=Q.front().first;
		int cost=Q.front().second;
		Q.pop();
		if(at==b)return cost;
		for(int i=0;i<g[at].size();i++){
			if(vis[g[at][i].first])continue;
			vis[g[at][i].first]=1;
			Q.push(make_pair(g[at][i].first,max(cost,g[at][i].second)));
		}
	}
	return -1;
}
int main(){
	int a,b;
	long long c;
	scanf("%d%d%lld",&a,&b,&c);
	for(int i=0;i<b;i++){
		scanf("%d%d%d",p+i,q+i,r+i);p[i]--;q[i]--;
		edge[i]=make_pair(r[i],make_pair(p[i],q[i]));
	}
	for(int i=0;i<a;i++)UF[i]=-1;
	std::sort(edge,edge+b);
	long long cur=0;
	for(int i=0;i<b;i++){
		if(FIND(edge[i].second.first)!=FIND(edge[i].second.second)){
			cur+=edge[i].first;
			UNION(edge[i].second.first,edge[i].second.second);
			g[edge[i].second.first].push_back(make_pair(edge[i].second.second,edge[i].first));
			g[edge[i].second.second].push_back(make_pair(edge[i].second.first,edge[i].first));
		}
	}
	if(cur>c){
		printf("0\n");return 0;
	}
	long long ret=0;
	int tmp=0;
	int ks=0;
	for(int i=0;i<b;i++){
		long long v=cur+r[i]-calc(p[i],q[i]);
		if(v==c){
			tmp++;
		}else if(v>c){
			ks++;
		}
	}
	if(tmp+ks==b)ret=pw(2,ks)*(pw(2,tmp)-2)%mod;
	else ret=pw(2,ks)*(pw(2,tmp)-1)%mod*2%mod;
	printf("%lld\n",ret);
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod = 1e9 + 7;
const int MX = 1e5+10;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
  int L,R,d;
  cin>>L>>R>>d;
  cout<<R/d-(L-1)/d<<endl;
   
   return 0;
}


Measured memory_bytes: 3572
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

// #define int long long

/* cpp template {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool prime[1000001] = {1, 1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  REPS(i, 2, 1000001){
    if (!prime[i]){
      for (int j = i + i; j < 1000001; j += i){
        prime[j] = true;
      }
    }
  }
  
  for (int n; cin >> n, n; ){
    int ans = 0;
    REP(i, n / 2 + 1){
      if (!prime[i] && !prime[n - i]){
        ans++;
      }
    }
    print(ans);
  }

  return (0);
}

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1000;
const int MAX_W = 5000;
int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];
int main(){
    cin>>n>>W;
    for(int i=0;i<n;i++) cin>>v[i]>>w[i];
      for (int j = 0; j <= W; j++) {
    dp[n][j] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i])
        dp[i][j] = dp[i + 1][j];
      else
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
        }
    }
  cout << dp[0][W] << endl;
}



Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int n,m,rn,rm;
    cin >> n >> m;
    int a[100];
    for(int i=1;i<=100;i++){
        a[i-1] = i * (i-1);
    }
    rn = a[n-1]/2;
    rm = a[m-1]/2;
    if(n==0){rn=0;}
    if(m==0){rm=0;}
    cout << rn + rm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long power = 1;
    REP(i, 1, n + 1) {
        power = (power * i) % 1000000007;
    }
    cout << power << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

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

    cin >> a >> b >> c;

    bool ans = false;

    rep(i,0,b) {
        if((a*i)%b==c) {
            ans = true;
        }
    }

    if (ans) {
        cout << "YES" << endl;
    }

    else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>

void reverse(int [], int, int);
void pri(int [], int);

int main(void)
{
    int i, n, q, b, e, A[1000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &b, &e);
        reverse(A, b, e);
    }

    pri(A, n);
    return 0;
}

void reverse(int A[], int b, int e)
{
    int tmp;

    e--;
    while (b < e) {
        tmp = A[b];
        A[b] = A[e];
        A[e] = tmp;
        b++;
        e--;
    }
}

void pri(int A[], int N)
{
    int i;
    
    for (i = 0; i < N; i++) {
        if (i > 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}


Measured memory_bytes: 2112
[a,b,c,d] = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

if a >= 0 and c >= 0:
    print(b*d)
elif b <= 0 and d <= 0:
    print(a*c)
elif a >= 0 and d <= 0:
    print(a*d)
elif b <= 0 and c >= 0:
    print(b*c)

elif a <= 0 and b >= 0 and c <= 0 and d >= 0:
    a_c = a*c
    b_d = b*d
    if a_c >= b_d:
        print(a_c)
    else:
        print(b_d)

elif a <= 0 and b >= 0 and d <= 0:
    print(a*c)

elif a <= 0 and b >= 0 and d >= 0:
    print(b*d)

elif b <= 0 and c <= 0 and d >= 0:
    print(a*c)

elif b >= 0 and c <= 0 and d >= 0:
    print(b*d)





Measured memory_bytes: 9224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % 2019; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % 2019;
	if (k != 0)rip(i, k)j = j * a % 2019;
	return(j);
}
int main() {
	int x;
	cin >> x;
	for (int i = -2500; i < 2500; i++){
		int count = 0;
		for(int j=-2500;j<i;j++)
	{
			if (pow(i, 5) - pow(j, 5) == x) {
				cout << i << " " << j << endl;
				count++;
				break;
			}
		}
		if (count != 0)break;
    }
}

Measured memory_bytes: 4228