akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
const int MAX = 10001000;
bool isPrime[MAX];
int minFact[MAX];
vector<int> preprocess(int n=MAX){
    vector<int> res;
    for(int i=0;i<n;i++){
        isPrime[i]=true;
        minFact[i]=-1;
    }
    isPrime[0]=false; minFact[0]=0;
    isPrime[1]=false; minFact[1]=1;
    for(int i=2;i<n;i++){
        if(isPrime[i]){
            minFact[i]=i;
            res.push_back(i);
            for(int j=i*2;j<n;j+=i){
                isPrime[j]=false;
                if(minFact[j]==-1) minFact[j]=i;
            }
        }
    }
    return  res;
}
vector<pair<int,int>> primeFactor(int n){
    vector<pair<int,int>> res;
    while(n!=1){
        int prime=minFact[n];
        int cnt=0;
        while(minFact[n]==prime){
            n/=prime;
            cnt++;
        }
        res.push_back({prime,cnt});
    }
    return res;
}
long long gcd(long long a,long long b){
    while(b!=0){
        a %= b;
        if(a==0) return b;
        b %= a;
    }
    return a;
}
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    preprocess();
    int n; cin >> n;
    vector<long long> a(n);
    long long G;
    rep(i,n){
        cin >> a[i];
        if(i==0) G=a[0];
        else G=gcd(G,a[i]);
    }
    bool ok=1;
    vector<bool> ex(1001001,false);
    rep(i,n){
        vector<P> p=primeFactor((int)a[i]);
        for(P u:p){
            if(ex[u.fi]==true) ok=0;
            ex[u.fi]=true;
        }
    }
    if(ok){
        cout << "pairwise coprime" << endl;
    }else if(G==1){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
}




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

int main(){
	long long int n;cin>>n;
	int v[n+1];
	v[0]=0;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++){
		cin>>v[i];
	}
	int dp[n+1];
	dp[0]=1e9;
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4268
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,n-1){
        if(a[i]==a[i+1]) {
            cout << "NO" << endl;
            ans=1;
            break;
        }
    }
    if(ans==0)cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int N, M, C;
    int *B, A;
    char c;
    
    int i, j;
    int p_sum;
    int ctr = 0;
    
    
    scanf("%d%c%d%c%d", &N, &c, &M, &c, &C);
    
    
    B = (int*)malloc(sizeof(int)*M);
    
    
    for(j=0; j<M; j++)
    {
        scanf("%d%c", &B[j], &c);
    }
    
    for(i=0; i<N; i++)
    {
        p_sum = 0;
        
        for(j=0; j<M; j++)
        {
            scanf("%d%c", &A, &c);
            
            p_sum += B[j]*A;
        }
        
        if(p_sum + C > 0)
            ctr++;
    }
    
    
    printf("%d\n", ctr);
    
    
    free(B);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 128
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    a = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    print(a + a**2 + a**3)


resolve()

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

int main()
{
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	a+=b;
	c+=d;
	if(a==c)
		cout<<"Balanced\n";
	else if(a>c)
		cout<<"Left\n";
	else
		cout<<"Right\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
struct RollingHash{
  string S;
  ull B;
  vector<ull> hash,p;
  int len;
  RollingHash(){}
  RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();};
  void init(){
    len=S.length();
    hash.resize(len+1);
    p.resize(len+1);
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};
signed main(){
  string t,p;
  cin>>t>>p;
  RollingHash rt(t),rp(p);
  for(int i=0;i<(int)(t.size()-p.size())+1;i++){
    if(rt.find(i,i+p.size())==rp.find(0,p.size())) cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 20624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


int main(){fastio
    
    ll n,k;cin>>n>>k;
    ll ok=0,ng=(1E18)+1;
    n=min(n,70);
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll sum=0;
        ll now=mid;
        rep(i,1,n){
            sum+=now;
            now/=2;
        }
        if(sum<=k){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    
    return 0;
}



Measured memory_bytes: 3180
implicit none
integer :: n,d
integer,allocatable :: x(:,:),dx(:)
integer :: i,j,k,z

read *,n,d
allocate(x(d,n))
do i = 1, n
   read *,(x(j,i),j=1,d)
enddo

allocate(dx(d))

k = 0
do i = 1, n-1
   do j = i+1, n
      dx(:) = x(:,i) - x(:,j)
      z = dot_product(dx,dx)
      if (z == int(sqrt(real(z,kind=8)))**2) then
         k = k + 1
      endif
   enddo
enddo

print '(i0)',k
end

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string today;
  cin>>today;
  if(today=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  if(today=="Rainy"){
    cout<<"Sunny"<<endl;
  }
  if(today=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	int w;
	cin>>S>>w;
	bool ok = false;
	string res = "";
	for(int i = 0; i < S.size(); ++i){
		if(i % w == 0){
			ok = true;
		}
		if(ok){
			res += S[i];
			ok = false;
		}
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double x = 0;
    int water = 100*A, suger = 0;
    
    for(int i = 0; i <= F; i += 100*A){
        for(int j = i; j <= F; j += 100*B){
            if(j == 0) continue;
            else{
                for(int k = j; k <= F; k += C){
                    for(int l = k; l <= F; l += D){
                        if(l-j <= E*j/100){
                            if(x < double(l-j)/double(l)){
                                x = double(l-j)/double(l);
                                water = l;
                                suger = l-j;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << water << ' ' << suger << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int dr[4] = { -1, 0, 0, 1 };
int dc[4] = { 0, -1, 1, 0 };

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> a(H, vector<int>(W, 0));
    for (int r = 0; r < H; ++r) {
        for (int c = 0; c < W; ++c) {
            cin >> a[r][c];
        }
    }

    vector<string> res;
    for (int r = 0; r < H; ++r) {
        for (int c = 0; c < W; ++c) {
            if (a[r][c] % 2 == 0) {
                continue;
            }

            if (c + 1 < W) {
                res.push_back(to_string(r + 1) + " " + to_string(c + 1) + " " + to_string(r + 1) + " " + to_string(c + 1 + 1));
                a[r][c]--;
                a[r][c + 1]++;
            } else if (r + 1 < H) {
                res.push_back(to_string(r + 1) + " " + to_string(c + 1) + " " + to_string(r + 1 + 1) + " " + to_string(c + 1));
                a[r][c]--;
                a[r + 1][c]++;
            }
        }
    }

    cout << res.size() << endl;
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i] << endl;
    }
    return 0;

}


Measured memory_bytes: 11892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int power(int a,int x){
	if(x==0) return 1;
	int y=power(a,x/2);
	y=(y*y)%M;
	if(x%2==1) return((a*y)%M);
	return y;
}

int32_t main(){
	IOS;
	int n,k;
	cin>>n>>k;
	int a[n];
	int ans=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		int x=0;
		int y=0;
		for(int j=i+1;j<n;j++) if(a[j]<a[i]) x++;
		for(int j=0;j<n;j++) if(a[j]<a[i]) y++;
		ans=(ans+(x*k)%M)%M;
		ans=(ans+(y*((k*(k-1)%M)*power(2,M-2)%M)%M)%M)%M;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
//#include <map>
#include <set>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> P;


typedef struct
{
	int i;
	int j;
	int hp;
} STATE;

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

char map[1024][1024];
int H, W, N;
int si, sj, gi, gj;
int d[1024][1024][10];

int search()
{
	queue<STATE> que;
	
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			for (int k = 0; k <= N; k++){
				d[i][j][k] = INF;
			}
		}
	}
	
	STATE tmp = {si, sj, 0};
	que.push(tmp);
	d[si][sj][0] = 0;
	
	while (que.size()){
		STATE st = que.front();
		que.pop();
		
//		printf("%d %d %d\n", st.i, st.j, st.hp);
		
//		if (st.hp == N) return (d[st.i][st.j][st.hp]);
		if (st.hp == N) break;
				
		for (int i = 0; i < 4; i++){
			int ni = st.i + dy[i];
			int nj = st.j + dx[i];
			int nhp = st.hp + (st.hp == map[ni][nj]);
			
			if (map[ni][nj] != 'X' && d[ni][nj][nhp] == INF){
				STATE tmp = {ni, nj, nhp};
				que.push(tmp);
				d[ni][nj][nhp] = d[st.i][st.j][st.hp] + 1;
			}
		}
	}
	
	return (d[gi][gj][N]);
}

int main()
{
	for (int i = 0; i < 1024; i++){
		for (int j = 0; j < 1024; j++){
			map[i][j] = 'X';
		}
	}
	
	scanf("%d %d %d", &H, &W, &N);
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			scanf(" %c", &map[i][j]);
			
			if (map[i][j] == 'S'){
				si = i;
				sj = j;
			}
			if (map[i][j] == '0' + N){
				gi = i;
				gj = j;
			}
			if (map[i][j] >= '1' && map[i][j] <= '9'){
				map[i][j] -= '1';
			}
		}
	}
	
	printf("%d\n", search());
}

Measured memory_bytes: 43152
#!/usr/bin/env python3
import sys
from itertools import product
INF = float("inf")


def solve(N: int, K: int, x: "List[int]", y: "List[int]"):
    sx = sorted(x)
    sy = sorted(y)
    m = INF

    for (i, x1), (j, y1) in product(enumerate(sx[:-K+1]), enumerate(sy[:-K+1])):
        # 始点を固定
        for x2 in sx[i+1:]:
            for y2 in sy[j+1:]:
                # 終点を固定
                counter = sum([1 for xx, yy in zip(x, y)
                               if (x1 <= xx <= x2) and (y1 <= yy <= y2)])
                if counter >= K:
                    area = abs((y2-y1)*(x2-x1))
                    m = min(m, area)
                    break   # これ以上yをあげたところで面積は増える一方なので抜ける
    print(m)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, K, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50268
/***************************************************
 * Problem Name : B - Greedy Takahashi.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-01-02
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    ll a, b, k;
    cin >> a >> b >> k;
    ll x = a - k;

    if (x >= 0) {
        cout << a - k << " " << b << "\n";

    } else {
        cout << 0 << " " << max (0LL, b - (k - a) ) << "\n";
    }

    return 0;
}


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

char in[100010];

int main()
{
    cin >> in;
    char *p = in;
    bool b = false;
    int ans1 = 0;
    int ans2 = 0;
    while(*p)
    {
        if(*p == "01"[b])
        {
            ans1++;
        }
        b = b ? false : true;
        p++;
    }
    p = in;
    b = true;
    while(*p)
    {
        if(*p == "01"[b])
        {
            ans2++;
        }
        b = b ? false : true;
        p++;
    }
    cout << min(ans1, ans2) << endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 3005;

/* ...o(^-^)o... */

const lint mod = MOD9;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend istream& operator>>(istream& is, mint& m){
        long long x; is >> x; m = x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

mint dp[MAX][MAX];

int main(){
    int n, s; cin >> n >> s;
    vector<int> a(n); rep(i, n) cin >> a[i];

    dp[0][0] = 1;
    rep(i, n) rep(j, s+1){
        dp[i+1][j] = dp[i][j] * 2;
        if(j >= a[i]) dp[i+1][j] += dp[i][j-a[i]];
    }

    out(dp[n][s]);
}

Measured memory_bytes: 74040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i <= (n); i++)
using namespace std;
 
int main() {
  int n, y;
  cin >> n >> y;
  bool flag = true;
  
  rep(i, n) {
    rep(j, n - i) {
        int total = 10000 * i + 5000 * j + 1000 * (n - i - j);
        if (total == y) {
          cout << i << " " << j << " " << (n - i - j) << endl;
          flag = false;
          break;
        }
    }
    if (!flag) {
      break;
    }
  }
  if (flag) {
    cout << -1 << " " << -1 << " " << -1 << endl; 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N,K;
  cin >> N >> K;
  if(500*N >= K){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<int, int> mp;
    rep(i, 0, 3){
        int a;
        cin >> a;
        mp[a]++;
    }
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it -> second == 1){
            cout << it -> first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll a,b;
int main(){
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int dp[100005];
int h[100005];
int main(){
    memset(dp, 0, sizeof dp);

    int n, k;
    cin >> n >> k;

    for(int i = 1; i <= n; ++i){
        cin >> h[i];
    }

    for(int i = 2; i <= n; ++i){
        dp[i] = INT_MAX;
        for(int j = 1; j <= min(k, i - 1); ++j) {
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int s[14],h[14],c[14],d[14];

void print(int *ara,char s){
	for(int i=1;i<14;i++){
		if(ara[i]==0) cout << s << " " << i << endl;
	}
}


int main() {
    
    int n,num;
    cin >> n;
    string str;
    while(n--){
    	cin >> str >> num;
    	if(str=="S") s[num]=1;
    	else if(str=="H") h[num]=1;
    	else if(str=="C") c[num]=1;
    	else d[num]=1;
    }
    print(s,'S');
    print(h,'H');
    print(c,'C');
    print(d,'D');

    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 998244353 //1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 1<<18

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int a[N], b[N], c[N];
void dwt(int a[], int l, int r){
    if(l+1 >= r)return;
    int m = (l+r) >> 1;
    dwt(a, l, m);
    dwt(a, m, r);
    int n = (r - l) >> 1;
    rep(i, 0, n){
        int u = (a[l + i] + a[m + i]) % mod;
        int v = (a[l + i] - a[m + i] + mod) % mod;
        a[l + i] = u;
        a[m + i] = v;
    }
}
const ll inv2 = (mod + 1) / 2;
void idwt(int a[], int l, int r){
    if(l+1 >= r)return;
    int m = (l+r) >> 1;
    idwt(a, l, m);
    idwt(a, m, r);
    int n = (r - l) >> 1;
    rep(i, 0, n){
        int u = (a[l + i] + a[m + i]) * inv2 % mod;
        int v = (a[l + i] - a[m + i] + mod) * inv2 % mod;
        a[l + i] = u;
        a[m + i] = v;
    }
}

int main(){
    int j,k,i,T,ca=0, n, m, K = 0;
    scanf("%d", &n);
    m = (1<<n);
    int s = 0;
    rep(i, 0, m)scanf("%d", &a[i]), add(s, a[i]);   
    s = pow(s, mod-2);
    rep(i, 0, m)a[i] = 1LL * a[i] * s % mod;
    dwt(a, 0, m);
    rep(i, 1, m)b[i] = mod - 1;
    b[0] = m - 1;
    dwt(b, 0, m);
    rep(i, 1, m){
        c[i] = 1LL * b[i] * pow(a[i] - 1, mod - 2) % mod;
    }
    idwt(c, 0, m);
    printf("0\n");
    rep(i, 1, m){
        c[i] = (c[i] - c[0] + mod) % mod;
        printf("%d\n", c[i]);
    }
}



Measured memory_bytes: 5888
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (A, B, C, D) = Scanner.Scan<long, long, long, long>();
            var answer = -(long)1e18;
            answer = Math.Max(answer, A * C);
            answer = Math.Max(answer, A * D);
            answer = Math.Max(answer, B * C);
            answer = Math.Max(answer, B * D);
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28380
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int Maxn = 55;
int a[Maxn], n;
struct lnode {
	int x, y;
	lnode(int x = 0, int y = 0) : x(x), y(y) {}
}list[Maxn<<1]; int l;
int _max(int x, int y) { return x > y ? x : y; }
int _min(int x, int y) { return x < y ? x : y; }
int main() {
	int i, j, k;
	scanf("%d", &n);
	int Min = 0x7fffffff, Max = -0x7fffffff;
	for(i = 1; i <= n; i++) scanf("%d", &a[i]), Max = _max(Max, a[i]), Min = _min(Min, a[i]);
	if(Max > -Min){
		int p = 0;
		for(i = 1; i <= n; i++) if(a[i] == Max){ p = i; break; }
		for(i = 1; i <= n; i++){
			if(a[i] < 0){
				a[i] += Max;
				list[++l] = lnode(p, i);
			}
		}
		for(i = 2; i <= n; i++){
			if(a[i] < a[i-1]){
				list[++l] = lnode(p, i);
				a[i] += Max;
				if(a[i] > Max){
					p = i;
					Max = a[i];
				}
			}
		}
	} else {
		int p = 0;
		for(i = 1; i <= n; i++) if(a[i] == Min){ p = i; break; }
		for(i = 1; i <= n; i++){
			if(a[i] > 0){
				a[i] += Min;
				list[++l] = lnode(p, i);
			}
		}
		for(i = n-1; i >= 1; i--){
			if(a[i] > a[i+1]){
				list[++l] = lnode(p, i);
				a[i] += Min;
				if(a[i] < Min){
					p = i;
					Min = a[i];
				}
			}
		}
	}
	printf("%d\n", l);
	for(i = 1; i <= l; i++) printf("%d %d\n", list[i].x, list[i].y);
	return 0;
}

Measured memory_bytes: 128
fun main() {
  val S = readString()
  println(S + if (S.last() == 's') "es" else "s")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int Pow(int a,int b)    {
    int ans = 1;
    while  (b)  {
        if (b & 1)  ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}

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

    int S;  cin >> S;

    int ans = 0;

    for(int i = 1 ; i <= S ; ++i)   if (S % i == 0) {
        if (i < 9 && S / i > 9 * Pow(10,i - 1))
            continue;
        
        add(ans,mul(9,Pow(10,i - 1)));
        sub(ans,S / i);
        add(ans,1);
    }
    for(int i = 8 ; i <= S ; ++i)   {
        int q = S / i;
        int r = S % i;

        if (r == 0) {
            r = i;
            q--;
        }
        if (q <= r) continue;

        add(ans,(q - r - 1) / (i + 1) + 1);
    }
    for(int i = 1 ; i < 8 ; ++i)    {
        int r1 = 9 * Pow(10,i - 1);
        int r2 = r1 * 10;

        for(int j = 1 ; j <= r1 ; ++j)  {
            if (i * j >= S) break;
            if((S - i * j) % (i + 1))
                continue;
            
            if((S - i * j) / (i + 1) <= r2)
                add(ans,1);
        }
    }

    for(int l = 1     ; l <= 6 ; ++l)
    for(int r = l + 2 ; r <= 8 ; ++r)   {
        int rem = S;

        for(int j = l + 1 ; j < r ; ++j)
            rem -= j * 9 * Pow(10,j - 1);
        
        if (rem < 0)    continue;

        int hig1 = 9 * Pow(10,l - 1);
        int hig2 = 9 * Pow(10,r - 1);

        for(int a = 1 ; a <= hig1 ; ++a)    {
            if (a * l >= rem)   break;
            if ((rem - a * l) % r == 0 && (rem - a * l) / r <= hig2)
                add(ans,1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {

	int A,B;
	cin >> A >> B;

	rep(i,2000) {
		int _a = floor((double)i*0.08);
		int _b = floor((double)i*0.1);

		if (_a==A && _b==B) {
			cout << i;
			break;
		}

		if (i==1999) {
			cout << -1;
		}
	}

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";

const int MAX = 1000001;
vector<long long >isprime(MAX , true); 
vector<long long >prime; 
vector<long long >SPF(MAX); 
void Seive(int N) 
{ 
    isprime[0] = isprime[1] = false ; 
   
    for (long long int i=2; i<N ; i++) 
    { 
        if (isprime[i]) 
        { 
            prime.push_back(i);  
            SPF[i] = i; 
        } 
  
        for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) 
        { 
            isprime[i*prime[j]]=false; 
   
            SPF[i*prime[j]] = prime[j] ; 
        } 
    } 
} 

ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0) 
        return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 
#define N_MAX 101
#define W_MAX 1000000001
#define V_SUM_MAX 100001

bool v[V_SUM_MAX][N_MAX];
vector<vector<ll>>dp(V_SUM_MAX,vector<ll>(N_MAX));
ll solveDp(int r, int i, vector<ll>&w, vector<ll>&val, int n) 
{ 
    // Base cases 
    if (r <= 0) 
        return 0; 
    if (i < 0) 
        return W_MAX; 
    if (v[r][i])
        return dp[r][i]; 
 	// t1("test");
    v[r][i] = 1; 
   
    dp[r][i]=min(solveDp(r, i - 1, w, val, n), w[i] + solveDp(r - val[i], i - 1, w, val, n)); 
    return dp[r][i]; 
} 
// int knapsack(vector<ll>val, std::vector<ll> weight, int value, int n){
// 	for(int i=0;i<=value;i++){
// 		for(int j=0;j<(int)n;j++){
// 			// if(v[i][j]) continue;
// 			if(i==0 || j==n){ dp[i][j] = W_MAX;}
// 			else if(val[j+1]<=i)
// 			dp[i][j+1] = min(weight[j] + dp[i+val[j]][j],dp[i][j+1]);
// 			else
// 			dp[i][j] = dp[i][j- 1];
// 			v[i][j]=1;
// 			// t1(dp[i][j]);
// 		}
// 	}
// 	return dp[value][n];
// }
void solve(){
	int n,we;
	cin>>n>>we;
	vector<ll>val(n),weight(n);
	for(int i=0;i<n;i++) cin>>weight[i]>>val[i];
	int sum1 = accumulate(val.begin(),val.end(),0);
	memset(v,false,sizeof(v));
	// for(int i=0;i<V_SUM_MAX;i++){
	// 	for(int j=0;j<W_MAX;j++){
	// 		dp[i][j] = INT_MAX;
	// 	}
	// }
	// knapsack(val,weight,sum1,n);
	for(int i=sum1;i>=0;i--){
		if(solveDp(i,n-1,weight,val,n)<=we){
			cout<<i<<endl;
			break;
		}
		// t1("end");
		// t1(dp[17][n]);
		// if(knapsack(val,weight,i,n)<=we){
			
		// 	cout<<i<<endl;
		// 	break;
		// }
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}

return 0;
}

Measured memory_bytes: 110656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    if(n%1000 != 0){
        cout << 1000-n%1000 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <set>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int n;
    cin >> n;
    set<string> s;
    rep(i, n)
    {
        string item;
        cin >> item;
        s.insert(item);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
#define MAX 3000000
using Graph=vector<vector<int>>;

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll solve(ll r,ll c){
  ll ans=COM(r+c+2,c+1);
  ans+=MOD-1;
  ans%=MOD;
  return ans;
}

int main(){
  ll r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;

  COMinit();

  ll ans=0;
  ans+=solve(r2,c2)-solve(r1-1,c2)-solve(r2,c1-1)+solve(r1-1,c1-1);
  ans+=2*MOD;
  ans%=MOD;
  cout<<ans<<endl;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    string s, t;
    cin >> s >> t;
    ll max_count = 0;

    REP(i, s.size() - t.size() + 1) {
      ll count = 0;
      REP(j, t.size()) {
        if (s[i + j] == t[j]) {
          count++;
        }
      }
      max_count = max(max_count, count);
    }

    COUT(t.length() - max_count);


}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#define ll long long
using namespace std;
long long N, A, B;
//trynum回で敵を全部燃やせるか？O(N)
bool chk(vector<long long> v, long long trynum){
	for (long long i = 0; i < N; i++){
		v[i] -= B*trynum;
	}
	long long delta = A - B;
	for (long long i = 0; i < N; i++){
		if (v[i] <= 0) break;
		if (v[i] % delta == 0){
			trynum -= v[i] / delta;
		}
		else{
			trynum -= (v[i] / delta + 1);
		}
	}
	if (trynum >= 0) return true;
	else return false;
}

int main(){

	cin >> N>>A>>B;
	vector<long long> mons;
	for (long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		mons.push_back(tmp);
	}
	sort(mons.begin(), mons.end());
	reverse(mons.begin(), mons.end());
	long long left = 1, right = mons[0]/B+1;
	while (right-left>1){
		long long mid = (left + right) / 2;
		if (chk(mons, mid)){
			//クリアできるならそれを探索範囲の上限
			right = mid;
		}
		else{
			left = mid;
		}
		//cout << mid << "\n";
	}
	if (chk(mons, left)){
		cout << left << "\n";
	}
	else{
		cout << right << "\n";
	}







	return 0;
}

Measured memory_bytes: 1908
# include <iostream>
# include <algorithm>
# include <unordered_map>
# include <iomanip>
using namespace std;
typedef long long int ll;
typedef long double ld;
unordered_map<ll,ll>cnt,f;
ll C[53][53];
int main()
{
	ll v[53];
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			if(i==j or j==0)
				C[i][j]=1;
			else
				C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	for(int i=0;i<n;i++)
		cin>>v[i],cnt[v[i]]++;
	sort(v,v+n,greater<ll>());
	ld mean=0,sum=0;
	for(int i=0;i<a;i++)
	{
		sum+=v[i];
		f[v[i]]++;
	}
	mean=sum/a;
	ll res=0;
	n=cnt[v[a-1]];
	int r=f[v[a-1]];
	if(r==a)
	{
		for(int i=a;i<=b;i++)
			res+=C[n][i];
	}
	else
		res+=C[n][r];
	cout<<setprecision(20)<<fixed<<mean<<"\n"<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
c = 0
for i in range(n-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2] or  p[i] > p[i+1] and p[i+1] > p[i+2]:
        c += 1
print(c)


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

int main(){
  long long int x,ans;
  cin >> x;
  ans = x / 11 * 2;
  if(x % 11 != 0){
    ans++;
    if(x % 11 > 6){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

int main(){
    
    int N,a[25],c[25];
    cin>>N;
    for(int i=1;i<N+1;i++){
        cin>>a[i];
    }
    for(int i=1;i<N+1;i++){
        cin>>c[i];
    }
    int ans=0;
    for(int i=1;i<N+1;i++){
        if(a[i]-c[i]>0){
            ans+=a[i]-c[i];
        }
    }
    cout<<ans<<endl;
    

}


Measured memory_bytes: 256
S = input()
K = int(input())
flg = True
for i in range(K):
    if len(S) <= i:
        break
    if S[i] != '1':
        flg = False
if flg:
    print('1')
    exit()
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()
print('1')

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        int n;
        int a[200200];
        int b[200200];
        long long c=0;
        
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&a[i]);
        }
        for(i=0;i<=n;i++){
                b[i] = 0;
        }
        for(i=0;i<=n;i++){
                b[a[i]]++;
        }
     //   for(i=0;i<n;i++){
       //         printf("%d ", b[i]);
       // }
        for(i=0;i<=n;i++){
                if(b[i]>0){
                        long long bl = b[i];
                c += bl*(bl-1)/2;
                }
        }
        for(i=0;i<n;i++){
                printf("%lld\n",c-b[a[i]]+1);
        }
        return 0;
}


Measured memory_bytes: 4096