akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll R;

    cin >> R;

    R *= 2;

    cout << setprecision(20) << (ld)R*M_PI << endl;

    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, B, C;
ll f[5001], invf[5001], res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	f[0] = 1;
	cin >> N >> A >> B >> C;
	if (B & 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= 5000; ++i) {
		f[i] = f[i - 1] * i%mod;
	}
	for (int i = 0; i <= 5000; ++i) {
		invf[i] = modinv(f[i]);
	}
	if (B) {
		for (int i = 0; i <= A; ++i) {
			for (int j = 0; j * 3 + i <= C; ++j) {
				res += f[A + j + B / 2] * invf[A - i] % mod*invf[i] % mod*invf[j] % mod*invf[B / 2] % mod*f[C - (i + 3 * j) + B / 2 - 1] % mod*invf[C - (i + 3 * j)] % mod*invf[B / 2 - 1] % mod;
				res %= mod;
			}
		}
	}
	else {
		for (int i = 0; i <= A; ++i) {
			if (C - i >= 0 && (C - i) % 3 == 0) {
				res += f[A + (C - i) / 3] * invf[A - i] % mod*invf[i] % mod*invf[(C - i) / 3] % mod;
				res %= mod;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    cout << fixed << setprecision(0) ;
    ll a;
    long double b;
    cin >> a >> b;
    ll c = a*b;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a < 0) {
		cout << c * abs(a) + d + b * e << endl;
	}
	else {
		cout << (b - a) * e << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
n=int(input())
#n,m=map(int,input().split())
#t=int(input())
hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

flag="Yes"

for i in range(n-2,-1,-1):
    righth=hl[i+1]
    cur=hl[i]
    if cur<=righth:
        pass
    elif cur==righth+1:
        hl[i]=cur-1
    else:
        flag="No"
        break

print(flag)




Measured memory_bytes: 20696
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
//const ll P=1000000007;
const long long P=998244353;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll n;
  string s; 
  cin>>n>>s;
  s+="000";
  ll ss=(s.at(0)-'0')*100+(s.at(2)-'0')*10+(s.at(3)-'0');
  ll ans=ss*n/100;
  cout<<ans<<endl;
          
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int r,d,x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i ++) {
        x = r*x -d;
        cout << x << endl;
    }

}


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

int main() {
	int N;
	cin>>N;
	long long int A[N],B[N],count=0,mod,add;
	REP(i,0,N){
		cin>>A[i]>>B[i];
	}
	for(int i=N-1;i>=0;i--){
		if(A[i]%B[i]==0){
			A[i-1]+=count;
			continue;
		}
		else if(A[i]>B[i]){
			mod=A[i]%B[i];
			add=B[i]-mod;
		}else{
			add=B[i]-A[i];
		}
		count+=add;
		A[i-1]+=count;
	}
	print(count);
	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int* parent,*height;

struct Info{
	Info(){
		cost = -1;
	}
	char name[11];
	int cost;
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int left,int right){
	return getParent(left) == getParent(right);
}

void unite(int left,int right){
	int left_parent = getParent(left);
	int right_parent = getParent(right);

	if(left_parent == right_parent)return;

	if(height[left_parent] >= height[right_parent]){
		if(height[left_parent] == height[right_parent]){
			height[left_parent]++;
		}
		parent[right_parent] = left_parent;
	}else{
		parent[left_parent] = right_parent;
	}
}


int main(){

	int N,M;
	scanf("%d",&N);
	parent = new int[N];
	height = new int[N];

	int* min_cost = new int[N];

	Info info[N];

	for(int i = 0; i < N; i++){
		parent[i] = i;
		height[i] = 0;
	}

	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].name,&info[i].cost);
		min_cost[i] = info[i].cost;
	}

	char left[11],right[11];
	int left_id,right_id;

	scanf("%d",&M);

	for(int loop = 0; loop < M; loop++){
		scanf("%s %s",left,right);

		for(int i = 0; i < N; i++){
			if(strCmp(left,info[i].name)){
				left_id = i;
				break;
			}
		}

		for(int i = 0; i < N; i++){
			if(strCmp(right,info[i].name)){
				right_id = i;
				break;
			}
		}

		unite(left_id,right_id);
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(isSame(i,k)){
				min_cost[i] = min(min_cost[i],info[k].cost);
			}
		}
	}

	int sum = 0;
	for(int i = 0; i < N; i++)sum += min_cost[i];

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

	return 0;
}

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

int main() {
    long long s;
    cin >> s;
    vector<int> num;
    
    while(s > 0){
        num.push_back(s%10);
        s /= 10;
    }
    reverse(num.begin(), num.end());
    
    int ans = 753;
    int delta = 0;
    int ref = 0;
    for (int i = 0; i < num.size() - 2; i++) {
        ref = num.at(i)*100 + num.at(i+1)*10 + num.at(i+2);
        delta = abs(ref - 753);
        ans = min(delta, ans);
    }
    cout << ans << endl;
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll r, d, x;
  cin >> r >> d >> x;
  rep(i,10){
    x = r * x - d;
    cout << x << endl;
  }
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int n, res = 0;
	cin >> n;
	REP(i, n) {
		int l, r;
		cin >> l >> r;
		res += r - l + 1;
	}
	cout << res << endl;
	return 0;
}

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


bool issq(int a){
	int b = sqrt(a);
	return a == b*b;
}

void solve(){
	int n , d;
	cin >> n >> d;
	vector<vector<int>> v(n,vector<int>(d));
	for(int i = 0 ; i < n ; ++i){
		for(int j = 0 ; j < d; ++j){
			cin >> v[i][j];
		}
	}
	int cnt = 0;
	for(int i = 0 ; i < n ; ++i){
		for(int j = i+1; j < n ;++j){
			int dis = 0;
			for(int k = 0 ; k < d ; ++k){
				dis += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
			}
			if(issq(dis)){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return;
}

int main(){
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q ; ++i){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<ll, ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
//#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int>
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define inf 1e10
#define NINF -1e16

#define N 1000005
int spf[N];
vll primes,prev[N],next[N];
set<int>s;
void sieve()
{
	rep(i,2,N)
	{
		if (spf[i]==0)
		{
			spf[i]=i;
			for(int j=2*i;j<=N;j+=i)
			{
				if(spf[j]==0)
					spf[j]=i;
			}
		}
	}
}
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    }
    for (int p=2; p<=n; p++) 
    {
        if (prime[p]) 
        {
            primes.pb(p); 
            s.insert(p);
        }
    }    
} 
// bool isPrime(ll n) 
// { 
//     if (n <= 1) 
//         return false; 
//     if (n <= 3) 
//         return true; 
//     if (n % 2 == 0 || n % 3 == 0) 
//         return false; 
//     for (int i = 5; i * i <= n; i = i + 6) 
//         if (n % i == 0 || n % (i + 2) == 0) 
//             return false; 
//     return true; 
// } 
// ll power(ll x,ll y)
// {
//     ll X=x;
//     //X=X%p;//if x is greater than p
//     if(X==0)
//     {
//         return 0;
//     }
//     ll res=1ll;
//     while(y>0)
//     {
//         if(y&1)
//         {
//             res=((res)*(X));
//             y--;
//         }
//         y=y>>1;
//         X=((X)*(X));
//     }
//     // res=(res>=0)?(res%p):(res+p)%p;
//     return(res);
// }
// void dfs(int u, int par){
//     cnt[u] = 1;
//     p[u] = par;
//     for(int i : g[u]){
//         if(i != par){
//             dfs(i,u);
//             cnt[u] += cnt[i];
//         }
//     }
// }
// int children(vll v[],int parent,int src,vll& chil)
// {
// 	int ans =0;
// 	for(auto it:v[src])
// 	{
// 		if(it!=parent)
// 		{
// 			ans+= 1+children(v,src,it,chil);
// 		}
// 	}
// 	chil[src] = ans;
// 	return ans;
 
// }
bool cmp(const pair<int,int>&a,const pair<int,int>&b)
{
    if (a.F==b.F)
    return a.S<b.S;
    else
    return a.F>b.F;
}
signed main() {
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand (static_cast <unsigned> (time(0)));
	SieveOfEratosthenes(1000005); 
// 	sort(all(primes));
    sieve();
	int t=1;
	//cin >> t;
	while (t--) 
	{
	    int n;
	    cin >> n;
	    int flag=0,c=0;
	    rep(i,0,n)
	    {
	        int x,y;
	        cin >> x>>y;
	        if (x==y)
	        c++;
	        else
	        c=0;
	        if (c>=3)
	        {
	            flag=1;
	        }
	    }
	    if (flag==1)
	    cout <<"Yes";
	    else
	    cout <<"No";
	}
	return 0;
}

Measured memory_bytes: 63184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
int main() {
  cin >> s;
  lli t = s.size();
  lli ans = 0;
  for (lli i=t-1; i>=0; --i) {
    if (i<t-1 && s[i] != '0') {
      s[i]--;
      for (lli k=i+1; k<t; ++k) s[k] = '9';
    }
    lli sum = 0;
    for (lli j=0; j<t; ++j) {
      sum += s[j] - '0';
    }
    cerr << s << endl;
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  int ans=0;
  int sum=0;
  for (int i=0;i<N;i++){
    cin >> a[i];
    sum+=a[i];
  }
  for (int i=0;i<N;i++){
    ans=abs(sum-N*a[i])<abs(sum-N*a[ans])?i:ans;
  }  
  cout << ans << endl;
}


Measured memory_bytes: 256
global N,K
global ws

def check(max_p):
    track=0
    now=0
    for i in range (N):
        if(ws[i]>max_p):return False
        if(now+ws[i]>max_p):
            track+=1
            now=ws[i]
        else:
            now+=ws[i]
    if now>0:
        track+=1
    if(track>K):
        return False
    else:
        return True

N,K=map(int,input().split())

ans=0
now=0
ws=[]
for i in range(N):
    w=int(input())
    ws.append(w)

amin=0
amax=int(1E30)

while amin+1!=amax:
    amid=(amin+amax)//2
    if(check(amid)):
        amax=amid
    else:
        amin=amid
print(amax)
   

Measured memory_bytes: 11628
#include <cassert>
#include <iostream>
#include <string>

std::string answer(int a, int b)
{
	return a * b % 2 != 0 ? "Yes" : "No";
}

int main()
{
	using namespace std;

	assert(answer(1, 1) == "Yes");
	assert(answer(1, 3) == "Yes");
	assert(answer(2, 3) == "No");
	assert(answer(1, 2) == "No");

	int a, b;
	cin >> a >> b;

	cout << answer(a, b) << endl;
}


Measured memory_bytes: 256
n, k= gets.split(' ').map(&:to_i)
h = gets.split(' ').map(&:to_i)

dp = Array.new(h.length,1000000000)
dp[0] = 0
for i in 1..h.length-1
	j = 0
	while i-j-1>=0 && j < k do
		dp[i] = dp[i-j-1]+(h[i-j-1]-h[i]).abs if dp[i] > dp[i-j-1]+(h[i-j-1]-h[i]).abs
		
	j += 1
	end
end

puts dp[h.length-1]

Measured memory_bytes: 8844
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String args[]) {
		FastScanner in = new FastScanner();
		long a=in.nextInt();
		long b=in.nextInt();
		long c=in.nextInt();
		long d=in.nextInt();
		System.out.println(Math.max(Math.max(a*c, b*d), Math.max(a*d, b*c)));
	}

	///////////////////////////
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;


int main() {
	FASTIO
	int h, w;
	cin >> h >> w;
	int m;
	cin >> m;
	vector<int> horizontal(w + 1), vertical(h + 1);
	unordered_map<int, unordered_map<int, bool>> mp;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		mp[a][b] = 1;
		horizontal[b]++;
		vertical[a]++;
	}
	int mx = 0;
	vector<int> u, v;
	mx = *max_element(vertical.begin(), vertical.end());
	for (int i = 0; i <= h; i++) {
		if (mx == vertical[i]) {
			u.push_back(i);
		}
	}
	mx = *max_element(horizontal.begin(), horizontal.end());
	for (int i = 0; i <= w; i++) {
		if (mx == horizontal[i]) {
			v.push_back(i);
		}
	}
	for (int i = 0; i < u.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			mx = max(mx, horizontal[v[j]] + vertical[u[i]] - mp[u[i]][v[j]]);
			if (!mp[u[i]][v[j]])return cout << mx << endl, 0;
		}
	}
	cout << mx << endl;
}



Measured memory_bytes: 56120
#include<iostream> 
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
using namespace std; 
typedef long long int ll;

void solve(){
    ll n,d,c=0,x,y;
    cin>>n>>d;
    while(n--){
       cin>>x>>y;
       if(((x*x)+(y*y))<=(d*d)) c++;
    }
    cout<<c;
}

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

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

using namespace std;

int main(void){
    long long h;

    cin >> h;

    long long x = log2(h);

    long long ans = 1, pw2 = 1;
    for(long long i=0; i<x; i++){
        pw2 *= 2;
        ans += pw2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+5;
ll sum[N],a[N],m,n;

int main()
{
    cin>>n>>m;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(ll i=1;i<=n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    ll l=0,r=2e5+1,ans,res,cnt;
    while(l<=r){
        ll mid=(l+r)>>1;
        res=cnt=0;
        for(ll i=1;i<=n;i++){
            ll pos=lower_bound(a+1,a+n+1,mid-a[i])-a;
            cnt+=n-pos+1;
            res+=sum[n]-sum[pos-1]+a[i]*(n-pos+1);
        }
        if(cnt>=m){
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%lld\n",res-(cnt-m)*ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int a[100000];

int euclid(int a, int b) {
    if (b == 0)
        return a;
    return euclid(b, a % b);
}

int main()
{
    int n, k, max;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        if (i == 0)
            max = a[i];
        scanf("%d", &a[i]);
        if (a[i] > max)
            max = a[i];
    }
    if (k > max) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int d = a[0];
    for (int i = 1; i < n; i++) {
        d = euclid(a[i], d);
        if (d == 1)
            break;
    }
    if (k % d == 0)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 640
import math

a, b, c, d = map(int, input().split())
total = b - a + 1
c_cnt = b // c - (a-1) // c
d_cnt = b // d - (a-1) // d
common_div = (c * d) // math.gcd(c, d)
common_cnt = b // common_div - (a-1) // common_div
total = total - c_cnt - d_cnt + common_cnt
print(total)


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

using namespace std;

using namespace std;

int main()
{
    string s;
    cin>>s;

    int n = s.size();

    if(s[n-1]!='s')
    {
        cout<<s+'s'<<endl;
    }
    else
    {
        cout<<s+"es"<<endl;
    }
    

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

void bfs(vector<string> &G, vector<vector<int>> &D, int h, int w) {
    queue<pair<int, int>> Q;
    Q.push(make_pair(h, w));
    while (!Q.empty()) {
        auto q = Q.front(); Q.pop();
        REP(i, 0, 4) {
            int nh = q.first + dx[i];
            int nw = q.second + dy[i];
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (G[nh][nw] == '#' || D[nh][nw] > 0) continue;
            D[nh][nw] = D[q.first][q.second] + 1;
            if (q.first == H - 1 && q.second == W - 1) return;
            Q.push(make_pair(nh, nw));
        }
    }
}

int main() {
    cin >> H >> W;
    vector<string> G(H);
    REP(i, 0, H) cin >> G[i];

    int count = 0;
    REP(i, 0, H) REP(j, 0, W) if (G[i][j] == '.') count++;

    vector<vector<int>> dist(H, vector<int>(W, 0));
    bfs(G, dist, 0, 0);

    if (dist[H - 1][W - 1] > 0) {
        cout << count - dist[H - 1][W - 1] - 1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 1/12/2019, 9:05:30 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

typedef tuple<int, int> P;

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W;
string S[410];
bool visited[410][410];

int main()
{
  cin >> H >> W;
  for (auto i = 0; i < H; i++)
  {
    cin >> S[i];
  }
  fill(&visited[0][0], &visited[0][0] + 410 * 410, false);
  ll ans = 0;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      if (!visited[i][j])
      {
        stack<P> St;
        St.push(P(i, j));
        ll cnt[2] = {0, 0};
        while (!St.empty())
        {
          int x = get<0>(St.top());
          int y = get<1>(St.top());
          St.pop();
          if (!visited[x][y])
          {
            // cerr << "visiting: (" << x << ", " << y << ")" << endl;
            visited[x][y] = true;
            cnt[S[x][y] == '.']++;
            for (auto k = 0; k < 4; k++)
            {
              int nx = x + dx[k];
              int ny = y + dy[k];
              // cerr << "considering: (" << nx << ", " << ny << ")" << endl;
              if (0 <= nx && nx < H && 0 <= ny && ny < W && !visited[nx][ny] && S[x][y] != S[nx][ny])
              {
                St.push(P(nx, ny));
              }
            }
          }
        }
        // cerr << cnt[0] << " " << cnt[1] << endl;
        ans += cnt[0] * cnt[1];
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    ll x;
    cin >> x;
    ll ans = 1;
    rep(i, 1, x+1){
        rep(j, 2, x+1){
            ll p = pow(i, j);
            if(p > x) break;
            ans = max(ans, p);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int k=fs.nextInt();
		int arr[]=fs.readArray(n);
		int dp[]=new int[n];
		Arrays.fill(dp,(int)1e9);
		dp[0]=0;
		for(int i=1;i<n;i++)
		{
			for(int j=i>=k ? i-k:0;j<i;j++)
			{
				dp[i]=Math.min(dp[i],dp[j]+Math.abs(arr[j]-arr[i]));
			}
		}
//		System.out.println(Arrays.toString(dp));
		System.out.println(dp[n-1]);
	}
}
class FastScanner 
{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public double nextDouble()
		{
			return Double.parseDouble(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 43968
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        int k=Integer.parseInt(sc.next());
        int l=Integer.parseInt(sc.next());
        UnionFindTree roads=new UnionFindTree(n);
        for(int i=0;i<k;i++){
            roads.union(Integer.parseInt(sc.next())-1,Integer.parseInt(sc.next())-1);
        }
        UnionFindTree trains=new UnionFindTree(n);
        for(int i=0;i<l;i++){
            trains.union(Integer.parseInt(sc.next())-1,Integer.parseInt(sc.next())-1);
        }
        HashMap<Pair,Integer> map=new HashMap<>();
        for(int i=0;i<n;i++){
            Pair p=new Pair(roads.find(i),trains.find(i));
            if (map.containsKey(p)){
                map.put(p,map.get(p)+1);
            }else{
                map.put(p,1);
            }
        }
        StringBuilder sb=new StringBuilder();
        for (int i=0;i<n;i++){
            if(i!=0){
                sb.append(" ");
            }
            Pair p=new Pair(roads.find(i),trains.find(i));
            sb.append(map.get(p));
        }
        System.out.println(sb);
    }
}

class Pair{
    int x;
    int y;
    public Pair(int x,int y){
        this.x=x;
        this.y=y;
    }
    @Override
    public int hashCode(){
        return Objects.hash(x,y);
    }
    @Override
    public boolean equals(Object o){
        if(o==this){
            return true;
        }
        if(!(o instanceof Pair)){
            return false;
        }
        Pair p=(Pair) o;
            return p.x==x && p.y==y;
    }
}

class UnionFindTree{
    int[] par;
    int[] rank;
    public UnionFindTree(int size){
        this.par=new int[size];
        this.rank=new int[size];
        for (int i=0;i<size;i++){
            makeSet(i);
        }
    }
    public void makeSet(int i){
        par[i]=i;
        rank[i]=0;
    }
    public void union(int x,int y){
        int xRoot=find(x);
        int yRoot=find(y);
        if(rank[xRoot]>rank[yRoot]){
            par[yRoot]=xRoot; 
        }else if(rank[xRoot]<rank[yRoot]){
            par[xRoot]=yRoot;
        }else if(xRoot!=yRoot){
            par[yRoot]=xRoot;
            rank[xRoot]++;
        }
    }
    public int find(int i){
        if (i!=par[i]){
            par[i]=find(par[i]);
        }
        return par[i];
    }
    public boolean same(int x,int y){
        return find(x)==find(y);
    }
}

Measured memory_bytes: 87072
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 21;
int n, f[N][N], numl[N], numr[N];
char s[N * 2];
ll ans;
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	scanf("\n%s", s + 1);
	int lim = (1 << n);
	for (int i = 0; i < lim; i++){
		int l = 0, r = 0;
		for (int j = 1; j <= n; j++)
			if ((i & (1 << (j - 1))) == 0)
				numl[++l] = s[j]; 
				else numr[++r] = s[j];
		for (int j = 1, k = l; j < k; j++, k--) swap(numl[j], numl[k]);
		for (int j = 1, k = r; j < k; j++, k--) swap(numr[j], numr[k]);
		memset(f, 0, sizeof(f));
		f[0][0] = 1;
		for (int j = 0; j <= r; j++)
			for (int k = 0; k <= l; k++){
				int tmp = j + k + 1;
				if (j < r && s[n + tmp] == numr[j + 1]) f[j + 1][k] += f[j][k];
				if (k < l && s[n + tmp] == numl[k + 1]) f[j][k + 1] += f[j][k];
			}
		ans = ans + f[r][l];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    x = []
    y = []

    N = NI()

    for _ in range(N):
        a,b = LI()
        x.append(a+b)
        y.append(a-b)

    xm = max(x) - min(x)
    ym = max(y) - min(y)

    print(max(ym,xm))



if __name__ == '__main__':
    main()

Measured memory_bytes: 96252
import sys

k, x = map(int, sys.stdin.readline().split())

def main():
    l = max(-10 ** 6, x - (k - 1))
    r = min(10 ** 6, x + (k - 1))
    return range(l, r + 1)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep =' ')

Measured memory_bytes: 3060
X = int(input())

if 400 <= X and X <= 599:
    print('8')
elif 600 <= X and X <= 799:
    print('7')
elif 800 <= X and X <= 999:
    print('6')
elif 1000 <= X and X <= 1199:
    print('5')
elif 1200 <= X and X <= 1399:
    print('4')
elif 1400 <= X and X <= 1599:
    print('3')
elif 1600 <= X and X <= 1799:
    print('2')
elif 1800 <= X and X <= 1999:
    print('1')
else:
    pass


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;
int memo[100005],a[100005];
int n,k;
int dp(int i)
{
    if(memo[i]!=-1)
    {
        return memo[i];
    }
    if(i>=n-1)
    {
        return 0;
    }
    int ret=INT_MAX;
    for(int j=1;j<=k;++j)
    {
        if(i+j<n)
            ret=min(ret,abs(a[i+j]-a[i])+dp(i+j));
    }
    return memo[i]=ret;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]);
    }
    memset(memo,-1,sizeof memo);
    printf("%d",dp(0));
    return 0;
}





Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
int map[51][51];
void search(int i,int j)
{
  if(map[i+1][j] == 1){
    map[i+1][j] = map[i][j];
    search(i+1,j);
  }
  if(map[i][j+1] == 1){
    map[i][j+1] = map[i][j];
    search(i,j+1);
  }
  if(map[i+1][j+1] == 1){
    map[i+1][j+1] = map[i][j];
    search(i+1,j+1);
  }
  if(j > 0){
    if(map[i][j-1] == 1){
      map[i][j-1] = map[i][j];
      search(i,j-1);
    }
    if(map[i+1][j-1] == 1){
      map[i+1][j-1] = map[i][j];
      search(i+1,j-1);
    }
  }
  if(i > 0){
    if(map[i-1][j] == 1){
      map[i-1][j] = map[i][j];
      search(i-1,j);
    }
    if(map[i-1][j+1] == 1){
      map[i-1][j+1] = map[i][j];
      search(i-1,j+1);
    }
  }
  if(i > 0 && j > 0){
    if(map[i-1][j-1] == 1){
      map[i-1][j-1] = map[i][j];
      search(i-1,j-1);
    }
  }
}
int main()
{
  for(;;){
    int w,h,i,j,count = 1;
    scanf("%d %d",&w,&h);
    if(w == 0 || h == 0) break;
    memset(map, 0, sizeof(map));
    for(i=0; i<h; i++){
      for(j=0; j<w; j++){
        scanf("%d",&map[i][j]);
      }
    }
    for(i=0; i<h; i++){
      for(j=0; j<w; j++){
        if(map[i][j] == 1){
          map[i][j] += count++;
          search(i,j);
        }
      }
    }
    printf("%d\n",count-1);
  }
  return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
ll k;

ll a[MAX_N];
ll f[MAX_N];

ll aifi[MAX_N];

bool check(ll x) {
  ll tmp_k = k;

  for (int i = 0; i < n; ++i) {
    ll aifi = a[i] * f[i];

    if (aifi <= x) continue;

    if (tmp_k == 0 && aifi > x) return false;

    ll diff = aifi - x;
    ll times = (diff - 1L) / f[i] + 1L;
    ll actual = min(times, tmp_k);

    aifi -= f[i] * actual;

    tmp_k -= actual;

    if (aifi > x) return false;
  }

  return true;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(f[i]));
  }

  if (n == 1) {
    ll ans = (a[0] - min(a[0], k)) * f[0];
    printf("%llf\n", ans);
    return 0;
  }

  sort(a, a + n);

  sort(f, f + n);
  reverse(f, f + n);

  ll ok = INF;
  ll ng = -1L;

  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2L;

    if (check(next)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  ll ans = ok;

  printf("%lld\n", ans);

  return 0;
}


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

using namespace std;

//#define int long long
#define INF 1e9
#define LINF 1e18

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    bool even = s.size() % 2;
    bool same = s[0] == s[s.size() - 1];
    if(even^same) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 200005;

vector <int> a, b, c, d;
int n, m, cur, ans[N];
char s[N];

inline int Erase(vector <int> &v, int x) {
  int p = lower_bound(v.begin(), v.end(), x) - v.begin();
  for (int i = p; i < v.size() - 1; ++i) {
    v[i] = v[i + 1];
  }
  v.pop_back();
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), scanf("%s", s + 1), s[0] = s[n << 1] = '1';
  for (int i = 0; i < n << 1; ++i) {
    if (s[i] == '0' && s[i + 1] == '0') {
      a.pb(i);
    } else if (s[i] == '0' && s[i + 1] == '1') {
      b.pb(i);
    } else if (s[i] == '1' && s[i + 1] == '0') {
      c.pb(i);
    } else {
      d.pb(i);
    }
  }
  m = d.size();
  if (m & 1) {
    puts("No");
  } else {
    if (m & 3) {
      int p, q, r;
      for (p = 0; p <= n << 1 && s[p] == '1'; ++p);
      if (p > n << 1) {
        puts("No");
        return 0;
      }
      while (true) {
        for (; p < n << 1 && s[p + 1] == '0'; ++p);
        if (p >= n << 1) {
          puts("No");
          return 0;
        }
        if (p + 2 <= n << 1 && s[p + 2] == '1') {
          break;
        } else {
          p += 2;
        }
      }
      for (q = p + 1; q <= n << 1 && s[q] == '1'; ++q);
      if (q > n << 1) {
        puts("No");
        return 0;
      }
      for (r = 0; r < m && d[r] > p && d[r] < q - 1; ++r);
      if (r == m) {
        puts("No");
        return 0;
      }
      if (d[r] <= p) {
        for (; r + 1 < m && d[r + 1] < p; ++r);
      }
      int x = p, y = q - 1, z = p + 1, w = d[r];
      ans[x] = ans[y] = ++cur, Erase(b, x), Erase(c, y);
      ans[z] = ans[w] = ++cur, Erase(d, z), Erase(d, w);
    }
    for (int i = 0; i < b.size(); ++i) {
      ans[b[i]] = ans[c[i]] = ++cur;
    }
    for (int i = 0; i < a.size(); i += 2) {
      ans[a[i]] = ans[a[i + 1]] = ++cur;
    }
    for (int i = 0; i < d.size(); i += 4) {
      ans[d[i]] = ans[d[i + 2]] = ++cur;
      ans[d[i + 1]] = ans[d[i + 3]] = ++cur;
    }
    puts("Yes");
    for (int i = 0; i < n << 1; ++i) {
      printf("%d%c", ans[i], i == (n << 1) - 1 ? '\n' : ' ');
    }
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 3448
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	r1 := scanInt()
	c1 := scanInt()
	r2 := scanInt()
	c2 := scanInt()

	facInit(r2+c2+2)

	var a mint
	a.add(comb(r2+1+c2+1, c2+1)-1)
	a.sub(comb(r2+1+c1, c1)-1)
	a.sub(comb(c2+1+r1, r1)-1)
	a.add(comb(c1+r1, r1)-1)

	fmt.Println(a)

}

const mod = 1000000007

type mint int

func (a *mint) add(b int) { *a = (*a+mint(b))%mod; if *a<0 { *a += mod } }
func (a *mint) sub(b int) { *a = (*a-mint(b))%mod; if *a<0 { *a += mod } }

var fac, ifac []int

func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)
	inv := make([]int, n+1)

	fac[0] = 1; fac[1] = 1
	ifac[0] = 1; ifac[1] = 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i]*inv[i+1]%mod
	}
}

func comb(a,b int) int { return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod }
func perm(a,b int) int { return fac[a]*ifac[a-b]%mod }

Measured memory_bytes: 49024
a=int(input())
b=list(map(int,input().split()))
c=sum(b)
d=0
e=0
f=0
for i in range(a):
  d=d+b[i]
  if d>=c/2:
    e=i
    break
for i in range(e):
  f=f+b[i]
if abs(d-(c-d))<abs(f-(c-f)):
  print(abs(d-(c-d)))
else:
  print(abs(f-(c-f)))

Measured memory_bytes: 9168
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
	a = list(map(int, input().split()))
	val = 0
	for j in range(m):
		val += a[j] * b[j]
	val += c
	if val > 0:
		cnt += 1
print (cnt)

Measured memory_bytes: 3060
from collections import deque
s = input()
s = deque(list(s))
q = int(input())
inv=False
for _ in range(q):
    query = input()
    if query == '1':
        inv=not(inv)
    else:
        _q,f,c = query.split()
        if inv:
            if f=='2':
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)

if inv:
    print(''.join(list(s)[::-1]))
else:
    print(''.join(list(s)))



            

    

Measured memory_bytes: 72168
from collections import deque
import sys
input = sys.stdin.readline

def C(i, j):
    p = [1, 0]
    q = deque([(i, j, ".")])
    while q:
        x, y, c = q.popleft()
        for u, v in d:
            dx, dy = x + u, y + v
            if 0 <= dx < h and 0 <= dy < w and s[dx][dy] != c and use[dx][dy]:
                use[dx][dy] = False
                p[s[dx][dy] == "#"] += 1
                q.append((dx, dy, s[dx][dy]))
    return p[0]*p[1]


h, w = map(int, input().split())
s = [input() for i in range(h)]
use = [[1] * w for i in range(h)]
d = [(0, 1), (1, 0), (0, -1), (-1, 0)]
ans = 0
for i in range(h):
    for j in range(w):
        if use[i][j] and s[i][j] == ".":
            use[i][j] = False
            ans += C(i, j)
print(ans)


Measured memory_bytes: 75716
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int A, B; cin >> A >> B;
    print(A*B - (A+B-1));
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,M;
  M=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0;i<N;i++)
    cin >> vec.at(i);
  for (int i=0;i<N-1;i++){
    for (int j=i+1; j<N; j++){
      if (vec.at(i)<vec.at(j)){
        a=vec.at(i);
        vec.at(i)=vec.at(j);
        vec.at(j)=a;
      }
    }
  }
  
  for(int i=0;i<N;i++){
   if (i%2==0)
     M += vec.at(i);
   else
     M -= vec.at(i);
 }
  cout << M << endl;
}
        
      


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

int main() {
    int counter[256] = {};
    char ch;
    while((ch = getchar()) != EOF) {
        counter[ch]++;
    }
    
    for (int i = 97; i <= 122; i++) {
        printf("%c : %d\n", i, counter[i] + counter[i - 32]);
    }
}


Measured memory_bytes: 3152
#include <iostream>

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main(void) {
    int a;
    int b;
    int g;
    while (std::cin >> a >> b) {
        g = gcd(a, b); 
        std::cout << g << " "; 
        std::cout << (int)((double)a / (double) g * (double)b) << std::endl;
    }
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,m;
int a[52525], b[52525], c[52525];

ll dp[125252][2];

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

bool ppcnt[16];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  REP(i,16)ppcnt[i] = __builtin_popcount(i)%2==0;
  map<pii,int> M;
  REP(i,m)M[pii(a[i],b[i])] = c[i];
  REP(j,16){
    if(!ppcnt[j])continue;
    pii a = pii(0,0);
    pii b = pii(0,1);
    pii c = pii(1,0);
    pii d = pii(1,1);
    if(M.count(a) && M[a] != (j>>0&1))continue;
    if(M.count(b) && M[b] != (j>>1&1))continue;
    if(M.count(c) && M[c] != (j>>2&1))continue;
    if(M.count(d) && M[d] != (j>>3&1))continue;
    dp[0][j>>3&1] += 1;
  }
  REP(i,n-2)REP(r2,2)if(dp[i][r2]){
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(M.count(pii(ci-1,ci+1)) && M[pii(ci-1,ci+1)] != ld)continue;
      if(M.count(pii(ci+1,ci-1)) && M[pii(ci+1,ci-1)] != ru)continue;
      REP(to,8){
        int nj = to*2+r2;
        if(!ppcnt[nj])continue;
        if(M.count(pii(ci+1,ci+0)) && M[pii(ci+1,ci+0)] != (nj>>1&1))continue;
        if(M.count(pii(ci+0,ci+1)) && M[pii(ci+0,ci+1)] != (nj>>2&1))continue;
        if(M.count(pii(ci+1,ci+1)) && M[pii(ci+1,ci+1)] != (nj>>3&1))continue;
        (dp[i+1][nj>>3] += dp[i][r2]) %= MOD;
      }
    }
  }
  ll base = (dp[n-2][0] + dp[n-2][1]) % MOD;
  ll fr = n<=3 ? 0ll : ((ll)n*n - 7ll*2 - 5ll*(n-4))/2;
  REP(i,m){
    int x = a[i], y = b[i], z = c[i];
    if(abs(x-y)<=2)continue;
    if(M.count(pii(y,x))){
      if(M[pii(y,x)] != z){
        base = 0;
      }else if(x<y){
        fr--;
      }
    }else{
      fr--;
    }
  }
  ll ans = base * modpow(2ll, fr) % MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main()
{
    string s;
    cin >> s;
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        bool flag = false;
        string t;
        cin >> t;
        string tmp = t + t;
        for (ll j = 0; j < t.size(); j++)
        {
            string sbstr = tmp.substr(j, s.size());
            if (sbstr == s)
            {
                flag = true;
            }
        }
        if (flag)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3196