akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Calc
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int a;


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;



    return 0;
}


Measured memory_bytes: 3648
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Control.Monad
import Data.Char
import Data.List

solve :: VU.Vector Int -> Int -> Int
solve xs n = minimum $ map (\i -> VU.sum $ VU.map (\x -> (i-x)^2) xs :: Int) [-100..100]

main = do
    n <- readLn :: IO Int
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve as n

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x;
  x=max(a,max(b,c));
  if(x==a) cout<<10*a+b+c<<endl;
  else if(x==b) cout<<10*b+c+a<<endl;
  else cout<<10*c+a+b<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        byte[] s = {'A', (byte)in.s(9)[8], 'C'};
        System.out.write(s, 0, 3);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_n=2005;
vector<pair<ll,ll> >kids(max_n); 
ll dp[max_n][max_n],n;
ll slove(ll l,ll r){
	if(l>r) return 0;
	if(dp[l][r]) return dp[l][r];
	ll i=n-(r-l+1);
	return 
        dp[l][r]=max(slove(l,r-1)+kids[i].first*(r-kids[i].second),
                    slove(l+1,r)+kids[i].first*(kids[i].second-l)); 
}
int main(){
	scanf("%d",&n);
	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
        kids.push_back({x,i});
    }
	sort(kids.rbegin(),kids.rend());
	slove(0,n-1);
	printf("%lld\n",dp[0][n-1]);
	return 0;
}


Measured memory_bytes: 26620
dict = {}
init = 'abcdefghijklmnopqrstuvwxyz'
for s in init:
    dict[s] = 0

list_sentence = []
while True:
    try:
        list_sentence.append(input())
    except:
        break;

for sentence in list_sentence:
    for s in sentence:
        if s.lower() in dict:
            dict[s.lower()] += 1

for k, v in dict.items():
    print(k, ':', v)



Measured memory_bytes: 5568
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int ans = 0;
	vector<int> C(N), V(N);
	for (int i = 0; i < N; i++) cin >> C[i];
	for (int i = 0; i < N; i++) cin >> V[i];
	for (int i = 0; i < N; i++) {

		if (C[i] - V[i] > 0) ans += C[i] - V[i];
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

int main(int argc, char *argv[])
{
  for(;;) {
    string str;
    vector<string> hs;
    vector<string> ts;
    cin >> str;
    if(str == "#") break;
    int n = str.length();
    int cnt = 0;
    vector<bool> used(256,false);
    used['z'] = true;
    function<void(int)> rec = [&rec,&str,&hs,&ts,&n,&cnt,&used](int i) {
      if(i==n) {
        cnt++;
        if(hs.size() < 5) {
          hs.push_back(string(str));
        } else {
          if(ts.size() > 4) {
            ts.erase(ts.begin());
          }
          ts.push_back(string(str));
        }
      } else {
        bool notFirst = str[i] == 'a';
        for(int j = 0; j < i; j++) {
          if(str[i] == str[j]) {
            notFirst = true;
            break;
          }
        }
        if(notFirst) { // i can remain
          rec(i+1);
        }
        if(!used[str[i]]) {
          used[str[i]] = true;
          str[i]++;  // pull-back!
          rec(i+1);
          str[i]--;  // restore.
          used[str[i]] = false;
        }
      }
    };
    rec(0);
    cout << cnt << endl;
    for(int i = 0; i < hs.size(); i++) {
      cout << hs[i] << endl;
    }
    for(int i = 0; i < ts.size(); i++) {
      cout << ts[i] << endl;
    }
  }
  return 0;
}

/*
 .jkb
   -u-> j.kb  # ng j is the first 
   -c-> k.kb
     -u-> kk.b # ok k is not the first one
        -u-> kkb. # ng. b is the first
        -c-> kkc. # ok
     -c-> kl.b 
        -u-> klb. # ng
        -u-> klc. # ok

*/

Measured memory_bytes: 3168
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N,A,B,X=0;
	cin >> N >> A>>B;
	if(N%(A+B)>=A)
		cout << (A *( N / (A + B))) +A ;
	else
		cout << (A * (N / (A + B))) +N%(A+B);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w,h,x,y,r;

	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);


	if(w < x + r || h < y + r || x < 0 || y < 0)
	{
		printf("No\n");
	}else
	{
		printf("Yes\n");

	}

	return 0;
}

Measured memory_bytes: 584
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    
    vector<int> cnt(24, 0);
    rep(i, n) ++cnt[d[i]];
    if (cnt[0]) {
        cout << "0\n";
        return;
    }
    vector<bool> iru(24, false);
    iru[0] = true;
    vector<int> vec;
    rep(i, 24) {
        if (cnt[i] == 1) {
            vec.push_back(i);
        }
        if (cnt[i] == 2) {
            if (i == 12) {
                cout << "0\n";
                return;
            }
            iru[i] = iru[24 - i] = true;
        }
        if (cnt[i] >= 3) {
            cout << "0\n";
            return;
        }
    }
    
    if (!sz(vec)) {
        int res = inf;
        rep(i, 24) rep(j, 24) {
            if (i != j && iru[i] && iru[j]) chmin(res, min(abs(i - j), 24 - abs(i - j)));
        }
        cout << res << "\n";
        return;
    }
    int ans = 0;
    rep(bit, 1 << sz(vec)) {
        auto iru_ = iru;
        rep(i, sz(vec)) {
            if ((bit >> i) & 1) iru_[vec[i]] = true;
            else iru_[24 - vec[i]] = true;
        }
        int res = inf;
        rep(i, 24) rep(j, 24) {
            if (i != j && iru_[i] && iru_[j]) chmin(res, min(abs(i - j), 24 - abs(i - j)));
        }
        chmax(ans, res);
    }
    
    cout << ans << "\n";
    return;
}


Measured memory_bytes: 3664
def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline
    input()
    a = list(map(int, input().split()))
    ans = sum(a)
    a = Counter(a)
    for _ in range(int(input())):
        b, c = map(int, input().split())
        if b in a:
            ans += (c - b) * a[b]
            print(ans)
            a[c] = a[c] + a[b] if c in a else a[b]
            del a[b]
        else:
            print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21140
#include <bits/stdc++.h>
    using namespace std;
    
    int main() {

        long long N,A,B;
        long long kai,amari;

        long long kaitou=0;

        cin >> N >> A >> B;

        if (A !=0 ){
     
        kai = N/(A+B);

        amari = N%(A+B);

        if(amari> A){
            kaitou = kai*A +A;
        }else{
          kaitou = kai*A+amari; 
        }
        

        }
            cout << kaitou << endl; 

        return 0;

    }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(9);
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++){
        int p;scanf("%d",&p);
        a[min(p/400,8)]++;
    }
    int cnt=0;
    for(int i=0;i<8;i++){
        if(a[i])cnt++;
    }
    if(!cnt)printf("1 %d\n",a[8]);
    else printf("%d %d\n",cnt,cnt+a[8]);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

// value
map<int, map<int,int>> pres;

int serch(vi vec, int n){
	for (int i = 0; i < vec.size(); i++) {
		if(vec[i] == n) return i + 1;
	}
	return -1;
}

void solve() {

    int N, M;
	cin >> N >> M;

	vector<P> C;
	for (int i = 0; i < M; i++) {
		P c;
		cin >> c.fst >> c.scd;
		C.pb(c);
		pres[c.fst][c.scd] == 0;
	}

	for (auto itr :pres){
		int i = 0;
		for(auto itr2:itr.scd){
			pres[itr.fst][itr2.fst] = i + 1;
			i++;
		}
	}

	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n", C[i].fst, pres[C[i].fst][C[i].scd]);
	}

	return;

}

int main() {

	//cin.tie(0);
	//ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 16372
#include <stdio.h>
int main(){
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
  	int Cleft;
	if(A==B){
    	Cleft=C;
    }else if(A-B>C){
		Cleft=0;
	}else{
		Cleft=C-(A-B);
	}
	printf("%d",Cleft);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
using namespace std;
#define ll long long

int main() {
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	string S; cin >> S;
	if(D<C){
	    bool flag=false;
	    for(int i=B-1; i<D; ++i){
	        if(S.substr(i-1, 3)=="...") flag=true;
	    }
	    if(!flag){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	for(int i=A; i+2<C; ++i){
	    if(S.substr(i, 2)=="##"){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	for(int i=B; i+2<D; ++i){
	    if(S.substr(i, 2)=="##"){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using LL = long long;
using P = pair<int,int>;


int main(){
	int A, B;
	cin >> A >> B;
	for(int i = 13; i <= 1000; i++){
		int a = i * 0.08;
		int b = i * 0.1;
		if(a == A && b == B){
		   cout << i << endl;
	       return 0;
		}
 	}
	cout << -1 << endl;
    return 0;	

}














Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<cstring>
const int MAX_N=100000+16;
int a[MAX_N*2];
bool mark[MAX_N*2];
int N,Q;
int main(){
    //freopen("1.txt","r",stdin);
    while(scanf("%d%d",&N,&Q)!=EOF){
        if(N==0&&Q==0)break;
        memset(mark,false,sizeof(bool)*(N+10));
        a[1]=0;
        mark[1]=1;
        for(int i=2;i<=N;i++){
            scanf("%d",&a[i]);
        }
        long ans=0;
        while(Q--){
            char c[2];
            int x;
            scanf("%s %d",c,&x);
            if(c[0]=='Q'){
                while(!mark[x]){
                    x=a[x];
                }
                ans+=x;
            }
            else {
                mark[x]=true;
            }
        }
        printf("%ld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3616
def resolve():
    N, D = map(int, input().split())
    ans = 0
    for _ in range(N):
        x, y = map(int, input().split())
        dist = (x**2 + y**2)**0.5
        if dist <= D:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9584
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

// ------ Variable ------ //

int N, M;


// ------ Greatest Common Divisor ------ //

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

	if (a > b) { return GCD(a % b, b); }
	if (b > a) { return GCD(b % a, a); }
}


// ------ Bipartite Matching ------ //

vector<vector<int> > Graph;

vector<int> match;

vector<bool> used;

bool dfs(int v)
{
	used[v] = true;

	for (int i = 0; i < Graph[v].size(); i++)
	{
		int u = Graph[v][i], w = match[u];

		if (w < 0 || !used[w] && dfs(w))
		{
			match[v] = u;
			match[u] = v;

			return true;
		}
	}

	return false;
}

int Bipartite_Matching()
{
	int Ans = 0;

	match = vector<int>(N + M, -1);

	for (int i = 0; i < N + M; i++)
	{
		if (match[i] < 0)
		{
			used = vector<bool>(N + M, 0);

			if (dfs(i))
			{
				Ans++;
			}
		}
	}

	return Ans;
}

int main()
{
	while (true)
	{
		cin >> N >> M;

		if (N == 0 && M == 0) { break; }

		Graph = vector<vector<int> >(N + M, vector<int>());

		vector<int> A(N);
		vector<int> B(M);

		for (int i = 0; i < N; i++) { cin >> A[i]; }
		for (int i = 0; i < M; i++) { cin >> B[i]; }

		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < M; j++)
			{
				if (GCD(A[i], B[j]) != 1)
				{
					Graph[i].push_back(N + j);
					Graph[N + j].push_back(i);
				}
			}
		}

		cout << Bipartite_Matching() << endl;
	}

	return 0;
}

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

int main() {
  int a,b;
  cin>> a >> b ;
  if ((a+b)%2 == 0) {
    cout<<(a+b)/2<< endl;
    }
  else{
    cout<< (a+b)/2+1<< endl;
  }
}



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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> ab(n);
  rep(i,n) cin >> ab[i].first >> ab[i].second;
  
  sort(ab.begin(), ab.end());
  ll cnt = 0, ans = 0;
  
  rep(i,n) {
    if (cnt < m && cnt + ab[i].second <= m) {
      cnt += ab[i].second;
      ans += ab[i].first * ab[i].second;
    }
    else if (cnt < m && ans + ab[i].second >= m) {
      ans += ab[i].first * (m - cnt);
      while (cnt < m) cnt++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <iterator>
using namespace std;

typedef long long ll;

int N;
map<int, int> M;

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

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

	ll ans = 0;
	map<int, int>::iterator itr;
	for (itr = M.begin(); itr != M.end(); ++itr) {
		int num = itr->first;
		int cnt = itr->second;
		if (cnt != num) {
			if (cnt > num)
				ans += (ll)(cnt - num);
			else
				ans += (ll)cnt;
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	string s = to_string(a) + to_string(b);
	int x = stoi(s);
	rep2(i, 1, 1000) {
		if (i*i == x) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull B=950527;
int n,m;
char str[1005];
ull a[1005];
int main(){
  scanf("%s",str);
  n=strlen(str);
  for(int i=0;i<n;i++){
    a[i]=str[i];
    if(i)a[i]+=a[i-1]*B;
  }
  scanf("%s",str);
  m=strlen(str);
  ull key=0,num=0,C=1;
  for(int i=0;i<m;i++){
    key=key*B+str[i];
    C*=B;
  }
  for(int i=0;i<n;i++){
    num=a[i];
    if(i-m>=0)num-=C*a[i-m];
    if(key==num){
      cout<<i-m+1<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll x, y;
  cin >> x >> y;

  if (x + y <= 1) cout << "Brown" << endl;
  else {
    if (abs(x - y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
  }


  
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  ll W, a, b;
  cin >> W >> a >> b;

  ll ans = 0LL;
  if(a < b) ans = b-(a+W);
  else ans = a-(b+W);

  if(ans < 0) cout << "0" << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[110];
long long dp[110000];
long long sum[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	dp[0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<=b;j++){
			sum[j+1]=(sum[j]+dp[j])%mod;
		}
		for(int j=0;j<=b;j++){
			dp[j]=(mod+sum[j+1]-sum[max(0,j-p[i])])%mod;
		}
	}
	printf("%lld\n",dp[b]);
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s,t;
    cin >> s >> t;
    if(s.size()==1){
        if((s[0] == '?'&&t.size()==1)||(s == t)){
            cout << t << endl;
        }else{
            cout << "UNRESTORABLE" << endl;
        }
        return 0;
    }
    if(t.size()>s.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    replace(ALL(s),'?','.');
    string ans;
    bool exist = false;
    for(int i=0;i<=s.size()-t.size();i++){
        regex re(s.substr(i,t.size()),regex_constants::extended);
        if(regex_search(t,re)){
            ans = s.substr(0,i) + t + s.substr(i+t.size());
            exist = true;
        }
    }
    if(exist){
        replace(ALL(ans),'.','a');
        cout << ans << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");

	const x = parseInt(line0vars[0], 10);
	const y = parseInt(line0vars[1], 10);

	if (y%2 === 1) {
		console.log("No");
		return;
	}

	const result = (x * 2 <= y && y <= x * 4);
	console.log(result ? "Yes" : "No");

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


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

int main(int argc,char** argv)
{

	int n;
	cin  >> n;
	char a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i]=='Y'){
			cout << "Four" <<endl;
			return 0;
		}
	}
	cout << "Three" <<endl;

	return 0;

}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func divFloor(a, b int) int {
	return (a + (b - 1)) / b
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	a := nextInts(n)

	l, r := 0, max(a...)
	for l < r-1 {
		mid := (l + r) / 2
		x := 0
		for i := 0; i < n; i++ {
			x += divFloor(a[i], mid) - 1
		}
		if x <= k {
			r = mid
		} else {
			l = mid
		}
	}

	puts(r)
}


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

enum Color {
	WHITE,
	GRAY,
	BLACK,
};

class dfs {
public:
	dfs(bool matrixT[][100], Color colorT[], int ts_F[], int ts_L[], int verNum) {
		for (int i = 0; i < verNum; i++) {
			for (int j = 0; j < verNum; j++)
				matrixTable[i][j] = matrixT[i][j];
		}
		verNumber = verNum;
	}

	void DFS_Recursive(int nowVerVal) {
		colorTable[nowVerVal] = GRAY;
		++ttl;
		ts_first[nowVerVal] = ttl;

		for (int nextVer = 0; nextVer < verNumber; nextVer++) {
			if (matrixTable[nowVerVal][nextVer] == false) continue;
			if (colorTable[nextVer] != WHITE) continue;
			DFS_Recursive(nextVer);
		}
		colorTable[nowVerVal] = BLACK;
		++ttl;
		ts_last[nowVerVal] = ttl;
	}

	void DFS_InitWithRecursive() {
		ttl = 0;
		for (int i = 0; i < verNumber; i++)
			colorTable[i] = WHITE;

		for (int i = 0; i < verNumber; i++)
			if (colorTable[i] == WHITE) DFS_Recursive(i);
	}

	void DFS_Stack(int firstVerVal) {
		stack<int> stack;
		stack.push(firstVerVal);
		colorTable[firstVerVal] = GRAY;
		++ttl;
		ts_first[firstVerVal] = ttl;

		while (!stack.empty()) {
			int nowVerVal = stack.top();
			int nextVerVal = searchNext(nowVerVal);
			if (nextVerVal != -1) {
				if (colorTable[nextVerVal] == WHITE) {
					colorTable[nextVerVal] = GRAY;
					ts_first[nextVerVal] = ++ttl;
					stack.push(nextVerVal);
				}
			}
			else {
				colorTable[nowVerVal] = BLACK;
				++ttl;
				ts_last[nowVerVal] = ttl;
				stack.pop();
			}
		}
	}

	void DFS_InitWithStack() {
		ttl = 0;
		for (int i = 0; i < verNumber; i++) {
			colorTable[i] = WHITE;
			nextFirstVal[i] = 0;
		}

		for (int i = 0; i < verNumber; i++)
			if (colorTable[i] == WHITE) DFS_Stack(i);
	}

	int searchNext(int nowVerNum) {
		//????????????????????????????????¨????????????????????????
		for (int i = nextFirstVal[nowVerNum]; i < verNumber; i++) {
			nextFirstVal[nowVerNum]++;
			if (matrixTable[nowVerNum][i]) return i;
		}
		return -1;
	}

	void print() {
		for (int i = 0; i < verNumber; i++) {
			cout << i + 1 << " " << ts_first[i] << " " << ts_last[i] << endl;
		}
	}
private:
	bool matrixTable[100][100];
	Color colorTable[100];
	int ts_first[100];
	int ts_last[100];
	int verNumber;
	int ttl;
	int nextFirstVal[100];
};

int main() {
	int verNum; //num??????????????°???value????????????????????????????????¨???
	bool matrixTable[100][100]; //???????????¨??????????????????
	Color colorTable[100];
	int timeStamp_first[100];
	int timeStamp_last[100];
	cin >> verNum;

	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++) {
			matrixTable[i][j] = false;
		}

	for (int i = 0; i < verNum; i++) {
		int verVal, nextVerNum;
		cin >> verVal >> nextVerNum;
		for (int j = 0; j < nextVerNum; j++) {
			int nextVerVal;
			cin >> nextVerVal;
			//0?????????????????´???
			matrixTable[verVal - 1][nextVerVal - 1] = true;
		}
	}

	dfs* d = new dfs(matrixTable, colorTable, timeStamp_first, timeStamp_last, verNum);
	d->DFS_InitWithStack();
	d->print();

	return 0;
}

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


int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				int flag=0;
				if(a[i]==a[j]||a[j]==a[k]||a[k]==a[i]) continue;
				if(a[i]+a[j]>a[k])	++flag;
				if(a[j]+a[k]>a[i])	++flag;
				if(a[i]+a[k]>a[j])	++flag;
				if(flag==3) ++ans;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b / a < c){
        cout << b / a << endl;
    }else{
        cout << c << endl;
    }
}

Measured memory_bytes: 256
H, W = map(int, input().split())

A = []
for _ in range(H):
  a = list(map(int, input().split()))
  A.append(a)

ans = []
for i in range(H):
  for j in range(W-1):
    if A[i][j] % 2 == 1:
      A[i][j+1] += 1
      ans += [[i+1, j+1, i+1, j+2]]
for i in range(H-1):
  if A[i][W-1] % 2 == 1:
    A[i+1][W-1] += 1
    ans += [[i+1, W, i+2, W]]

print(len(ans))
for a in ans:
  print(' '.join(map(str, a)))

Measured memory_bytes: 31364
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 	
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
   
 void solve() {
		string s;
		cin>>s;
		if(s=="ABC") cout<<"ARC\n";
		else cout<<"ABC\n";
	  
         
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>M;
    vec s(N),t(M);
    rep(i,N) cin>>s[i];
    rep(i,M) cin>>t[i];
    mat dp(N+1,vec(M+1,0));//1-indexed
    bool same;
    int mod = 1000000007;
    reps(i,1,N+1){
        reps(j,1,M+1){
            same = s[i-1]==t[j-1];
            if(same) dp[i][j] = dp[i-1][j]+dp[i][j-1]+1;
            else dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            (dp[i][j]+=mod)%=mod;
        }
    }
    cout<<dp[N][M]+1<<endl;
}

Measured memory_bytes: 31616
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;
 
int main() {
    int64_t n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int64_t i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    for (int64_t i = 0; i < n; ++i) {
        for (int64_t j = 0; j < n; ++j) {
            if (i == j) continue;
            sum += sqrt( pow(x[i] - x[j], 2) + pow (y[i] - y[j], 2) );
        }
    }
    sum = sum / n;
    cout << setprecision(17);
    cout << sum << endl;
}


Measured memory_bytes: 256
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
      print(0)
      return

  prod = 1
  for a in A:
      prod *= a
      if prod > 1000000000000000000:
          print(-1)
          return
  print(prod)

main ()

Measured memory_bytes: 84708
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  set<string>s;
  string  str;
  for(int i = 0;i<n;i++)
  {
    cin>>str;
    s.insert(str);
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
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,m,sum=0;
  cin >> n >> m;
  int a[m];
  rep(i,0,m){
    cin >> a[i];
    sum+= a[i];
  }
  cout << max(-1, n-sum);
}


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    int minv=a[0];
    int maxv=-1000000000;
    for (int i=1;i<n;i++){
        if(maxv<a[i]-minv){
            maxv=a[i]-minv;
        }
        if(minv>a[i]){
            minv=a[i];
        }
        
        
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3884
import numpy as np
N, M = map(int, input().split())
p_dict = {}
p = [0 for i in range(M)]
y = [0 for i in range(M)]
i_in_p = [0 for i in range(M)]
 
for i in range(M):
    p[i], y[i] = map(int, input().split())
    if p[i] not in p_dict:
        i_in_p[i] = 0
        p_dict[p[i]] = [y[i]]
        continue
    i_in_p[i] = len(p_dict[p[i]])
    p_dict[p[i]].append(y[i])
for key in p_dict.keys():
    p_dict[key] = np.array(p_dict[key]).argsort().argsort() + 1
for i in range(M):
    print('{:06d}{:06d}'.format(p[i], p_dict[p[i]][i_in_p[i]]))

Measured memory_bytes: 50020
#include<iostream>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
int const maxn = 2e6+100;
int const mod = 1e9+7;
LL fac[maxn];
LL qpow(LL a, LL b){
	LL ans = 1;
    while (b) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
LL C(LL n, LL m){
	return fac[n] * qpow(fac[m], mod-2) % mod * qpow(fac[n-m], mod-2) % mod;
}
int main(){
	fac[0] = fac[1] = 1;
	for(int i = 2; i < maxn; i++)
		fac[i] = fac[i-1] * i % mod;
	LL r1, r2, c1, c2;
	scanf("%lld %lld %lld %lld", &r1, &c1, &r2, &c2);
	LL res=C(r2+c2+2, c2+1) + C(r1+c1, c1) - C(r2+c1+1, c1) - C(r1+c2+1, c2+1);
	res = (res % mod + mod) % mod;
	printf("%lld\n", res%mod);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, i, A, B, mid, mid2;
vector<int> data;
pair<int, int> best;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    data.resize(n);
    for (auto& e: data) scanf("%d", &e);
    sort(data.begin(), data.end());

    A = data.back();
    mid = A / 2;
    mid2 = (A + 1) / 2;

    best = mp(A + 3, -1);
    for (auto e : data) {
        if (e == A) continue;

        if (e <= mid) {
            best = min(best, mp(mid - e, e));
        } else {
            best = min(best, mp(e - mid2, e));
        }
    }

    B = best.second;
    printf("%d %d", A, B);


    return 0;
}


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

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
};


int main() {
	int N, K;
	cin >> N >> K;
	vector<mll> Perm(K + 1), Perm2(K - 1);
	Perm[0] = 1;
	for (int i = 1; i <= K; i++) Perm[i] = Perm[i - 1] * (K - i + 1);
	if (K > 1) {
		Perm2[0] = 1;
		for (int i = 1; i <= K - 2; i++) Perm2[i] = Perm2[i - 1] * (K - 2 - i + 1);
	}
	else {
		if (N == 1) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}

	vector<vector<int>> Tree(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		Tree[a - 1].push_back(b - 1);
		Tree[b - 1].push_back(a - 1);
	}
	mll ans = 1;
	vector<int> Colored(N);
	queue<int> Q;
	Q.push(0);
	Colored[0] = 1;
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		if (v == 0) {
			if (Tree[v].size() + 1 <= K) ans *= Perm[Tree[v].size() + 1];
			else ans = 0;
		}
		else {
			if (Tree[v].size() - 1 <= K-2) ans *= Perm2[Tree[v].size() - 1];
			else ans = 0;
		}
		for (int u : Tree[v]) {
			if (!Colored[u]) {
				Q.push(u);
				Colored[u] = 1;
			}
		}
	}
	cout << ans.x << endl;
}


Measured memory_bytes: 11320
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int x, y;
	cin >> x >> y;
	if (x < y) cout << "a < b\n";
	else if (x > y) cout << "a > b\n";
	else cout << "a == b\n";
}


Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

string s;
int ans;

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[0] == '0') {
			if (i % 2 == 0) {
				if (s[i] != '0') {
					s[i] = '0';
					ans++;
				}
			}
			else {
				if (s[i] != '1') {
					s[i] = '1';
					ans++;
				}
			}
		}
		else {
			if (i % 2 == 0) {
				if (s[i] != '1') {
					s[i] = '1';
					ans++;
				}
			}
			else {
				if (s[i] != '0') {
					s[i] = '0';
					ans++;
				}
			}
		}
	}
	


	cout << ans << endl;

	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int k;cin>>k;
  string s;cin>>s;
  if(s.size()<=k)cout<<s<<endl;
  else
  {
    int i;
    rep(i,k)cout<<s[i];
    cout<<"..."<<endl;
  }
  
}


Measured memory_bytes: 3628
#include<map>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>

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

using namespace std;

const double EPS=1e-8;

/*** geometry part ***/

struct point{
	double x,y;
	point():x(0),y(0){}
	point(double x,double y):x(x),y(y){}
	point operator-(const point &a)const{ return point(x-a.x,y-a.y); }
	bool operator==(const point &a)const{ return abs(x-a.x)<EPS && abs(y-a.y)<EPS; }
	bool operator!=(const point &a)const{ return abs(x-a.x)>EPS || abs(y-a.y)>EPS; }
};

double dot(const point &a,const point &b){ return a.x*b.x+a.y*b.y; }

double cross(const point &a,const point &b){ return a.x*b.y-a.y*b.x; }

struct segment{
	point a,b;
	segment(){}
	segment(const point &a,const point &b):a(a),b(b){}
};

typedef vector<point> polygon;

bool cover(const segment &S,const point &p){
	return abs(cross(S.a-p,S.b-p))<EPS && dot(S.a-p,S.b-p)<EPS;
}

// 二つの線分が長さ正の部分で接しているかどうか
bool touch(const segment &S,const segment &T){
	if(abs(cross(S.b-S.a,T.b-T.a))>EPS) return false; // 平行でないとダメ
	if(S.a==T.a && S.b==T.b
	|| S.a==T.b && S.b==T.a) return true;
	return cover(S,T.a) && S.a!=T.a && S.b!=T.a
		|| cover(S,T.b) && S.a!=T.b && S.b!=T.b
		|| cover(T,S.a) && T.a!=S.a && T.b!=S.a
		|| cover(T,S.b) && T.a!=S.b && T.b!=S.b;
}

// 二つの多角形が長さ正の部分で接しているかどうか
bool touch(const polygon &F,const polygon &G){
	int m=F.size(),n=G.size();
	rep(i,m) rep(j,n) {
		segment S(F[i],F[(i+1)%m]);
		segment T(G[j],G[(j+1)%n]);
		if(touch(S,T)) return true;
	}
	return false;
}

/*** end ***/

/*** graph part ***/

int N; // 異なる国の個数
bool G[10][10]; // 国どうしの接続関係のグラフ

int color[10];
// 彩色
int dfs(int u,int next){
	if(u==N) return next;

	int res=N;
	rep(c,next+1){
		bool ok=true;
		rep(v,N) if(G[u][v] && color[v]==c) ok=false;
		if(ok){
			color[u]=c;
			res=min(res,dfs(u+1,max(c+1,next)));
			color[u]=-1;
		}
	}
	return res;
}

/*** end ***/

int main(){
	for(int n;scanf("%d",&n),n;){
		string name[100];
		polygon F[100];
		rep(i,n){
			char s[32]; scanf("%s",s);
			name[i]=s;
			while(1){
				point p;
				scanf("%lf",&p.x);
				if(p.x==-1) break;
				scanf("%lf",&p.y);
				F[i].push_back(p);
			}
		}

		map<string,int> f;
		rep(i,n) if(f.count(name[i])==0) f.insert(make_pair(name[i],f.size()));

		N=f.size();
		rep(u,N) rep(v,N) G[u][v]=false;
		rep(i,n) rep(j,n) {
			int u=f[name[i]],v=f[name[j]];
			if(u!=v && !G[u][v] && touch(F[i],F[j])) G[u][v]=true;
		}

		rep(u,N) color[u]=-1;
		printf("%d\n",dfs(0,0));
	}

	return 0;
}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	for(int i = 0; i < s.size()+1; i++){
		if(i < 4) cout << s[i];
		else if(i > 4) cout << s[i-1];
		else cout << ' ';
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256