akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

const int MAXN = 50;

double a[MAXN];

double solve(int n) {
  std::sort(a, a + n);
  double res = a[0];
  for (int i = 1;i < n; ++i) {
    res = (res + a[i]) / 2.0;
  }
  return res;
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  std::cout << solve(n) << std::endl;
  return 0;
}


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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};


int main() {
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int ans=1e9;
    for(int i=0;i<=max(X,Y)*2;i+=2){
        int val=C*i;
        int restx=max(0,X-i/2),resty=max(0,Y-i/2);
        val+=restx*A+resty*B;
        ans=min(ans,val);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
X = int(input())
exps = []
for b in range(1,34):
  for p in range(2,11):
    x = b**p
    if x < 1001:
      exps.append(x)
exps = list(set(exps))
exps.sort()
for a in exps[::-1]:
  if X >= a:
    print(a)
    break

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

using namespace std;

int main()
{long long int N,K;
cin>>N>>K;
string S;
cin>>S;

if(S[K-1]=='A'){
    S[K-1]='a';
}if(S[K-1]=='B'){
    S[K-1]='b';
}if(S[K-1]=='C'){
    S[K-1]='c';
}
cout<<S<<"\n";
}


Measured memory_bytes: 3548
N = int(input())
A = [int(i) for i in input().split()]

absA = []
for i in range(N):
    absA.append(abs(A[i]))

cnt = 0
for i in range(N):
    if A[i] < 0:
        cnt += 1

flag = 0
for i in range(N):
    if A[i] != 0:
        flag = 1
    if flag == 1 and A[i] == 0:
        cnt += 1
    
if cnt % 2 == 0:
    ans = sum(absA)
else:
    ans = sum(absA) - min(absA) * 2

print(ans)

Measured memory_bytes: 14468
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String str = sc.next();
        String[] strAry = new String[n];
        for (int i = 0; i < n; i++) {
            strAry[i] = String.valueOf(str.charAt(i));
        }
        
        int[] cumsum = new int[n + 1];
        for (int i = 1; i < n; i++) {
            if (strAry[i - 1].equals("A") && strAry[i].equals("C")) {
                cumsum[i + 1] = cumsum[i] + 1;
            } else {
                cumsum[i + 1] = cumsum[i];
            }
        }
        
        while (q-- > 0) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            int count = cumsum[end] - cumsum[start];
            
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 57596
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, Q = map(int, readline().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, readline().split())
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    P = [0] * N
    (*PX,) = map(int, read().split())
    for p, x in zip(*[iter(PX)] * 2):
        P[p - 1] += x

    stack = deque([0])
    seen = [False] * N
    while stack:
        v = stack.pop()
        seen[v] = True
        for nv in G[v]:
            if seen[nv]:
                continue
            P[nv] += P[v]
            stack.append(nv)

    print(' '.join(map(str, P)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 90808
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
long long f[500010];
long long tot=0;
long long ans=0;
int main()
{
	cin>>s;
	long long len=s.length();
	bool left=false;
	char chr='>';
	long long fuhao=1;
	if (s[0]=='<')
	{
		left=true;
		chr='<';
	}
	for (long long i=1;i<len;++i)
	{
		if (s[i]!=chr)
		{
			tot++;
			f[tot]=fuhao;
			fuhao=1;
			chr=s[i];
		}
		else
		{
			fuhao++;
		}
	}
	if (fuhao!=0)
	{
		tot++;
		f[tot]=fuhao;
	}
	long long root=0;
	if (left)
	{
		root=max(f[2],f[1]);
		ans+=((1+f[1]-1)*(f[1]-1))/2;
		left=false;
	}
	else
	{
		ans=((1+f[1])*f[1])/2;
		root=0;
		left=true;
	}
	for (long long i=2;i<=tot;++i)
	{
		if (left)
		{
			root=max(f[i],f[i+1]);
			ans+=((1+f[i]-1)*(f[i]-1))/2;
			left=false;
		}
		else
		{
			ans+=((1+f[i]-1)*(f[i]-1))/2;
			ans+=root;
			root=0;
			left=true;
		}
	}
	ans+=root;
	cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5672
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[][][] bfr = new int[4][3][10];
        StringBuilder sb = new StringBuilder();

        while (in.hasNext()) {
            int m = in.nextInt();
            int f = in.nextInt();
            int r = in.nextInt();

            if (m == -1 && f == -1 && r == -1) {
                break;
            }

            if (m == -1 || f == -1) {
                sb.append("F").append("\n");
            } else {
                if (m + f < 30) {
                    sb.append("F").append("\n");
                } else if (m + f < 50) {
                    sb.append(r >= 50 ? "C" : "D").append("\n");
                } else if (m + f < 65) {
                    sb.append("C").append("\n");
                } else if (m + f < 80) {
                    sb.append("B").append("\n");
                } else {
                    sb.append("A").append("\n");
                }
            }
        }

        System.out.print(sb.toString());
    }
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  lint n,m; cin >> n >> m;

  vector<int> v(n+1,0);
  for(lint i=0;i<m;i++) {
    lint a,b; cin >> a >> b;

    if(a == 1) {
      if(v[b] == n) {
        cout << "POSSIBLE\n";
        return 0;
      }
      v[b] = 1;
    } else if(b == n) {
      if(v[a] == 1) {
        cout << "POSSIBLE\n";
        return 0;
      }
      v[a] = n;
    }
  }

  cout << "IMPOSSIBLE\n";
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

#define x1 ixunu
#define x2 ixdoi
#define y1 igrecunu
#define y2 igrecdoi

#define MOD 1000000007

#define MAXN 2000009

const long long MARE = 1LL * MOD * MOD;

int fact[MAXN + 1], invFact[MAXN + 1];

struct myc {
    int x1, x2, y1, y2;
} a, b;

int x1, x2, y1, y2;

/*struct punct {
    int x, y;
} v[MAXN], u[MAXN];*/

inline int lgput(int a, int n) {
    int r = 1;
    while (n) {
        if (n % 2)
            r = 1LL * r * a % MOD;
        n /= 2;
        a = 1LL * a * a % MOD;
    }
    return r;
}

inline int comb(int n, int k) {
    if (n < k || n < 0)
        return 0;
    else
        return 1LL * fact[n] * invFact[k] % MOD * invFact[n - k] % MOD;
}

inline int drum(int x, int y) {
    return comb(x + y, x);
}

inline int dreptunghi(int x1, int x2, int y1, int y2) {
    int ans = drum(x2 + 1, y2 + 1) + drum(x1, y1) - drum(x2 + 1, y1) - drum(x1, y2 + 1);
    if (ans >= MOD)
        ans -= MOD;
    if (ans < 0)
        ans += MOD;
    if (ans < 0)
        ans += MOD;
    return ans;
}

inline int A(int x, int y) {
    x = std::min(x, x2);
    y = std::min(y, y2);
    return dreptunghi(x - a.x2, x - a.x1, y - a.y2, y - a.y1);
}

inline int B(int x, int y) {
    x = std::max(x, x1);
    y = std::max(y, y1);
    return dreptunghi(b.x1 - x, b.x2 - x, b.y1 - y, b.y2 - y);
}

inline int solve(int x, int y) {
    return 1LL * A(x, y) * B(x, y) % MOD;
}

int main() {
    scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &a.x1, &a.x2, &x1, &x2, &b.x1, &b.x2, &a.y1, &a.y2, &y1, &y2, &b.y1, &b.y2);

    fact[0] = 1;
    for (int i = 1; i <= MAXN; i++)
        fact[i] = 1LL * fact[i - 1] * i % MOD;
    invFact[MAXN] = lgput(fact[MAXN], MOD - 2);
    for (int i = MAXN - 1; i >= 0; i--)
        invFact[i] = 1LL * invFact[i + 1] * (i + 1) % MOD;

    int ans = 0;
    for (int i = x1; i <= x2; i++)
        ans = (ans + 1LL * solve(i, y2 + 1) * (i + y2 + 1) - 1LL * solve(i, y1 - 1) * (i + y1) + MARE) % MOD;
    for (int i = y1; i <= y2; i++)
        ans = (ans + 1LL * solve(x2 + 1, i) * (i + x2 + 1) - 1LL * solve(x1 - 1, i) * (i + x1) + MARE) % MOD;

    /*int p = 0;
    for (int i = x1; i <= x2; i++)
        v[p++] = {i, y1 - 1};
    for (int i = y1; i <= y2; i++)
        v[p++] = {x1 - 1, i};

    int q = 0;
    for (int i = x1; i <= x2; i++)
        u[q++] = {i, y2 + 1};
    for (int i = y1; i <= y2; i++)
        u[q++] = {x2 + 1, i};

    for (int i = 0; i < p; i++)
        for (int j = 0; j < q; j++)
            if (v[i].x <= u[j].x && v[i].y <= u[j].y)
                ans = (ans + 1LL * A(v[i].x, v[i].y) * B(u[j].x, u[j].y) % MOD * (u[j].x - v[i].x + u[j].y - v[i].y - 1) % MOD * drum(std::min(u[j].x, x2) - std::max(v[i].x, x1), std::min(u[j].y, y2) - std::max(v[i].y, y1))) % MOD;*/

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

    return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;

    int ary[n];
    rep(i,n) cin >> ary[i];

    sort(ary, ary+n, greater<int>());

    int alice = 0;
    int bob = 0;
    rep(i,n)
    {
	    if (i%2 == 0)
	    {
		    alice += ary[i];
	    }
	    else
	    {
		    bob += ary[i];
	    }
    }
    cout << alice - bob << endl;

}


Measured memory_bytes: 256
import fractions

A, B = map(int, input().split())
divisors = []
ans = 0
flag = 0
ans_list = []

myGCD = fractions.gcd(A, B)

for i in range(1, int(myGCD**0.5)+1):
  if myGCD % i == 0:
    divisors.append(i)
    if i != myGCD // i:
      divisors.append(myGCD//i)

divisors.sort()

for j, d in enumerate(divisors):
  for k in range(j):
    if fractions.gcd(d, divisors[k]) != 1:
      flag = 1
      break
    else:
      continue
  if flag != 1:
    ans += 1
  flag = 0

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int solve(int left, int right, vector<int>& X){
    int a = X[right];
    if(left != 0) a -= X[left-1];
    int b = right - left + 1 - a;

    int rem = abs(a-b) % 3;
    if(rem == 2) rem = -1;

    if(b > a) rem *= -1;
    return rem;
}

int main(){
    string S, T;
    cin >> S >> T;
    int NS = S.length();
    int NT = T.length();
    vector<int> SA(NS);
    vector<int> TA(NT);
    SA[0] = S[0] == 'A';
    for(int i = 1; i < NS; i++){
        SA[i] = SA[i-1] + (S[i] == 'A');
    }
    TA[0] = T[0] == 'A';
    for(int i = 1; i < NT; i++){
        TA[i] = TA[i-1] + (T[i] == 'A');
    }

    int Q;
    cin >> Q;
    REP(i,Q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;

        int aa = solve(a, b, SA);
        int bb = solve(c, d, TA);
        //cout << aa << " " << bb << endl;

        if(aa == bb)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
}



Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  if(a%3==0||b%3==0||(a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n, min=100000, wcount=0, ecount = 0;
	cin >> n;
	char s[n];
	REP(i,n) cin >> s[i];
	REP1(i,n){
		if(s[i] == 'E') ecount++;
	}
	min = ecount;
	for(int i = 1; i < n; i++){
		if(s[i-1] == 'W') wcount++;
		if(s[i] == 'E') ecount--;
		if(wcount + ecount < min){
			min = wcount + ecount;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 512
def solve():
    n = int(input())
    d = list(map(int, input().split()))

    print(calc(d, n))


def calc(d, n):
    if d[0] != 0:
        return 0
    else:
        k = max(d)
        a = [0] * (k + 1)
        for i in range(1, n):
            a[d[i]] += 1
        if a[0] > 0:
            return 0
        else:
            r = 1
            for i in range(2, k + 1):
                r *= a[i - 1] ** a[i]
            return r % 998244353


if __name__ == "__main__":
    solve()


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

int main()
{
	int n;
	int num[100];

	cin >> n;

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

	cout << num[n - 1];

	for (int j = n - 2; j >= 0; j--){
		cout << " " << num[j];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N =sc.nextInt();

		switch(String.valueOf(N).length()) {
		case 1:
			System.out.println(N);
			break;
		case 2:
			System.out.println(9);
			break;
		case 3:
			System.out.println(9 + (N - 100) + 1);
			break;
		case 4:
			System.out.println(909);
			break;
		case 5:
			System.out.println(909 + (N - 10000) + 1);
			break;
		default:
			System.out.println(90909);
			break;
		}
	}

}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    long x, y;

    void Read()
    {
        var line = ReadLine(long.Parse);
        x = line[0];
        y = line[1];
    }

    void Write(bool firstWins)
    {
        WriteLineOne(firstWins ? "Alice" : "Brown");
    }

    public void Run()
    {
        Read();
        Write(Math.Abs(x - y) > 1);
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int k;
  cin >> k;
  if (k <= 9) {
    cout << k << '\n';
    return 0;
  }
  k -= 9;
  vector<string> res;
  for (int i = 1; i <= 9; i++) res.push_back(to_string(i));
  vector<string> nex;
  while (true) {
    for (string &n : res) {
      char d = n[n.size()-1];
      for (int i = -1; i < 2; i++) {
        char tail = d + i;
        if (tail < '0' || tail > '9') continue;
        nex.push_back(n + tail);
        k--;
        if (k == 0) {
          cout << nex[nex.size()-1] << '\n';
          return 0;
        }
      }
    }
    res = nex;
    nex.clear();
  }
}

Measured memory_bytes: 5752
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int slova [30];
long long int rj = 0;

int main()
{
    string s;
    cin >> s;
    long long int d = s.size();
    for (int i = 0; i < s.size(); i++)
    {
        slova [s [i] - 'a']++;
    }
    for (int j = 0; j < 27; j++)
    {
        if (slova [j] == 0) continue;
        rj += ((long long)slova [j] * (slova [j] - 1)) / 2;
    }
    printf("%lld", (d * (d - 1)) / 2 - rj + 1);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 1e9+7;
int la, ra;
ll l, r, ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MD) if(n%2) (res *= b) %= MD;
	return res;
}
int main(){
	scanf("%lld%lld", &l, &r);
	for(; l>>la; la++); la--;
	for(; r>>ra; ra++); ra--; r = ~r;
	if(ra != la) for(int i = la; i <= ra; i++){
		if(la < i && i < ra) (ans += exp(3,i)) %= MD;
		else{
			ll dp1 = 1, dp2 = 0;
			for(int j = i-1; j >= 0; j--){
				if((la == i ? l : r)>>j&1) (dp2 *= 3) %= MD;
				else{
					dp2 = (dp2*3 + dp1) % MD;
					(dp1 *= 2) %= MD;
				}
			}
			(ans += dp2 + dp1) %= MD;
		}
	}else{
		ll dp1 = 1, dp2 = 0, dp3 = 0, dp4 = 0;
		r = ~r;
		int j = ra-1;
		for(; j >= 0; j--) if((r^l)>>j&1) break;
		for(; j >= 0; j--){
			int lb = l>>j&1, rb = r>>j&1;
			if(lb && rb){
				dp4 =(dp4*3 + dp2) % MD;
				(dp2 *= 2) %= MD;
			}else if(!lb && rb){
				dp4 = (dp4*3 + dp2 + dp3) % MD;
				dp2 = (dp2*2 + dp1) % MD;
				dp3 = (dp3*2 + dp1) % MD;
			}else if(lb && !rb){
				(dp4 *= 3) %= MD;
				dp1 = 0;
			}else if(!lb && !rb){
				dp4 =(dp4*3 + dp3) % MD;
				(dp3 *= 2) %= MD;
			}
		}
		ans = (dp1 + dp2 + dp3 +dp4) % MD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n,d;
    cin>>n>>d;
    ll one_cover = (2*d)+1;
    ll q = n/one_cover;
    if(n%one_cover!=0){
        q++;
    }
    cout<<q;

    return 0;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

long long modpow(long long a, int p){
    if(p == 0) return 1;
    if(p % 2 == 0){
        int halfP = p / 2;
        long long half = modpow(a, halfP);
        return half * half % MOD;
    }else{
        return a * modpow(a, p-1) % MOD;
    }
}

long long calcComb(int a, int b){
    if(b > a - b) return calcComb(a, a - b);

    long long ansMul = 1;
    long long ansDiv = 1;
    for(int i = 0; i < b; i++){
        ansMul *= (a - i);
        ansDiv *= (i + 1);
        ansMul %= MOD;
        ansDiv %= MOD;
    }

    long long ans = ansMul * modpow(ansDiv, MOD - 2) % MOD;
    return ans;
}

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

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

    int Mnokori = M;
    long long ans = 1;
    for(int i = 2; i * i <= Mnokori; i++){
        if(Mnokori % i == 0){
            int cnt = 0;
            while(Mnokori % i == 0){
                cnt++;
                Mnokori /= i;
            }
            ans *= calcComb(N + cnt - 1, N - 1);
            ans %= MOD;
        }
    }
    if(Mnokori != 1){
        ans *= calcComb(N + 1 - 1, N - 1);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int varied(char *str)
{
	int i;
	int j;
	char temp;
	int flag;

	i = 0;
	flag = 0;
	while (str[i])
	{
		j = i + 1;
		while (str[j])
		{
			if (str[i] == str[j])
			{
				flag = 1;
				return (1);
			}
			j++;
		}
		i++;
	}
	return (0);
}

int		main(void)
{
	char s[27];
	int res;

	scanf("%s", s);
	res = varied(s);
	if (res == 1)
	{
		printf("no\n");
	}
	else if(res == 0)
	{
		printf("yes\n");
	}
}

Measured memory_bytes: 1660
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n,k int
    fmt.Scan(&n,&k)
    ans := 1
    if n % k == 0{
        ans = 0
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    #define P pair<int,int>
    using ll=int64_t;
    using namespace std;
    #define ketasuu(n) fixed<<setprecision(n)
    #define btoe(p) p.begin(),p.end()
    #define etob(p) p.rbegin(),p.rend()




    int main(){
        int h,w; cin>>h>>w;
        vector<vector<int>> p(h,vector<int>(w));
        rep(i,h) rep(j,w) cin>>p[i][j];
        vector<tuple<int,int,int,int>> ans;
        rep(i,h){
            rep(j,w-1){
                if(p[i][j]%2==1){
                    ans.emplace_back(i,j,i,j+1);
                    p[i][j+1]++;
                }
            }
        }
        rep(i,h-1){
            if(p[i][w-1]%2==1){
                ans.emplace_back(i,w-1,i+1,w-1);
                p[i+1][w-1]++;
            }
        }
        int n=ans.size();
        cout<<n<<endl;
        for(auto& v: ans){
            cout<<get<0>(v)+1<<" "<<get<1>(v)+1<<" "<<get<2>(v)+1<<" "<<get<3>(v)+1<<endl;
        }
        return 0;
    }

Measured memory_bytes: 5232
n,  t = map(int, input().split())

best_c = 1001
best_t = t

for _ in range(n):
  c_i, t_i = map(int, input().split())
  if (t_i <= t) & (c_i < best_c):
    best_c = c_i
    
print(best_c if best_c != 1001 else 'TLE')

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a>0)
    {
    	cout<<"Positive";
	}
    else 
    {
		if(a==0||(a<0&&b>0))
		{
			cout<<"Zero";
		}
		else 
		{
			if((b-a)%2!=0)
	    	{
	    		cout<<"Positive";
			} 
			else 
			cout<<"Negative";
		} 
    	
	}
	 
		
    
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> P(N);
    rep(i, N) {
        double p; cin >> p;
        P[i] = p * (p + 1) / 2.0;
        P[i] /= p;
    }
    vector<double> sum(P.size() + 1);
    for(int i = 0; i < P.size(); ++i) sum[i + 1] = sum[i] + P[i];
    double ans = 0;
    for(int i = 0; i + K <= N; ++i) {
        ans = max(ans, sum[i + K] - sum[i]);
    }
    printf("%.10lf\n", ans);
    return 0;
}

// overflow
// corner cases


Measured memory_bytes: 3328
# include "iostream"
# include "cstdio"
# include "cmath"
# include "algorithm" 

using namespace std;

const int maxm=1000+10; 

int n,	//n个蛋糕 
	m; 	//取出m个蛋糕 

long long 
	dp[5][maxm], 
	ans,now1,now2; 

int main(){
	long long x,y,z;
	register int i,j; 
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%lld%lld%lld",&x,&y,&z); 
		dp[1][i]=x+y+z; //-x-y-z
		dp[2][i]=x+y-z;	//-x-y+z
		dp[3][i]=x-y+z;	//-x+y-z
		dp[4][i]=x-y-z;	//-x+y+z
	}
	for(i=1;i<=4;i++){
		sort(dp[i]+1,dp[i]+1+n,greater<long long>());
		now1=now2=0; 
		for(j=1;j<=m;j++){
			now1+=dp[i][j];
			now2+=dp[i][n-j+1]; 
		}
		ans=max(ans,max(abs(now1),abs(now2))); 
	}
	printf("%lld",ans); 
	return 0; 
} 

Measured memory_bytes: 256
import collections

MOD=998244353
N=int(input())
D=list(map(int, input().split()))
c=collections.Counter(D)
counter=sorted(c.items(), key=lambda x:x[0])
if D[0]!=0 or counter[0][1]>1:
  print(0)
else:
  flag=True
  pre=0
  for i in range(1, len(counter)):
    if pre+1!=counter[i][0]:
      flag=False
      break
    pre+=1
  if not flag:
    print(0)
  else:
    ans=1
    for i in range(2, len(counter)):
      for j in range(counter[i][1]):
        ans=(ans*counter[i-1][1])%MOD
      #ans=(ans*(counter[i-1][1]**counter[i][1])%MOD)%MOD
    print(ans)

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

int main(){
    int H , A , ans = 0;
    cin >> H >> A;
    for(int i = 0; 1 ; i++){
        H = H - A;
        ans++;
        if( H <= 0){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 100002

ll maxi(ll a,ll b){
	if(a>=b)return a;
	return b;
}

ll mini(ll a,ll b){
	if(a>=b)return b;
	return a;
}


int main(){
	Fio;
	ll n,k;
	cin>>n>>k;
	ll H[n+1];
	fo(i,1,n)cin>>H[i];
	ll dp[n+1];
	fo(i,0,n)dp[i] = inf;
	dp[1] = 0;
	fo(i,1,n){
		fo(j,i+1,i+k){
			if(j<=n)
			dp[j] = mini(dp[j],dp[i]+abs(H[i]-H[j])); 
		}
	}
	cout<<dp[n];

	return 0;
}

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

int main()
{
    int n, k;
    cin >> n;

    long long min = 1LL<<60;
    long long v[200010];
    v[0] = 0;
    for(int i = 1; i <= n; ++i){
        long long a;
        cin >> a;
        v[i] = v[i-1] + a;
    }


    for(int i = 1; i < n; ++i){
        if(abs((long long)(v[n] - 2*v[i])) < min) min = abs((long long)(2*v[i]-v[n]));
    }

    cout << min;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <limits>
#include <string>
#include <regex>

#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


int
main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string s;
  std::cin >> s;

  auto maxlen = std::numeric_limits<std::size_t>::min();
  std::regex pattern{"[^ACGT]"};
  for (std::sregex_token_iterator itr{std::cbegin(s), std::cend(s), pattern, -1}, end; itr != end; ++itr) {
    maxlen = std::max(maxlen, static_cast<std::size_t>(itr->length()));
  }
  std::cout << maxlen << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a;
  int b;
  int h;

  scanf("%d\n",&a);
  scanf("%d\n",&b);
  scanf("%d\n",&h);

  int ans;
  ans = (a+b) * h /2;
  printf("%d\n",ans);

  return 0;
}


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

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

template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) { cin >> A[i]; }

    long long ans = 0;

    for (int i = 0; i <= 60; i++) {
        long long n = 0, m = 0;
        REP(j, N) {
            if ((A[j] >> i) & 1)
                n++;
            else
                m++;
        }
        long long tmp = (1ll << i) % MOD, cnt = (n * m) % MOD;
        tmp = tmp * cnt % MOD;
        ans += tmp;
        ans %= MOD;
    }

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

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

void func(int c, int n, string s) {
  if(c == n) {
    printf("%s\n", s.c_str());
    return;
  }
  char m = 0;
  for(auto x : s) m = max(m, x);
  for(int i = 'a'; i <= m + 1; i++) {
    string ns = s;
    ns.push_back(i);
    func(c + 1, n, ns);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  func(1, n, "a");
}

Measured memory_bytes: 1536
/*
The year is 2050, league is played by less than 100 people. T1 has finally reached Masters,
"Macaiyla I did it!" he yells excitedly. The sound echoes through the empty trailer. Macaiyla left long ago...
 */
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int n = sc.nextInt();
        int t = sc.nextInt();
        double a = sc.nextDouble();
        double min = Double.MAX_VALUE;
        int idx = 0;

        for(int i=0;i<n;i++) {
            double cur = t - (0.006 * sc.nextDouble());
            double diff = Math.abs(cur - a);
            if(diff < min) {
                min = diff;
                idx = i + 1;
            }
        }

        pw.println(idx);
        pw.close();
    }
}

// ceil(a/b) = (a+b-1)/b
// PRO TIP: THE BEST ANSWER IS THE RIGHT ANSWER


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

using namespace std;

int local;

void solve(){
    int n;
    cin>>n;

    int ct = 1;

    while(1000*ct < n){
        ct++;
    }

    cout<<(1000*ct)-n<<endl;
}

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

    local = 0;

    if(local){
        int tc; cin>>tc; while(tc--) solve();
    }
    else solve();

    return 0;
}




Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
    int n;
    int ans=0;
    int tmp = -1;
    cin >> n;
    int a[n];
    bool f=true;
    for(int i=0; i<n;i++){
        cin >> a[i];
        if(a[i]==tmp && f){
            ans ++;
            f=false;
            tmp = a[i];
            continue;
        }else{
            f=true;
            tmp = a[i];
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    string s,t;
    cin >> s >> t;


    vector<vector<int>> v(26,vector<int>(200002));
    vector<vector<int>> g(26,vector<int>(200002));
    for(int i = 0 ; i < 26 ; i++ ){
        v[i][0] = 0; 
        g[i][0] = 0;
    }
    // cout << "Hello" << endl;

    rep(i,t.size()){
        int m = t[i] -'a';
        v[m][0]++;
        v[m][v[m][0]] = i;
    }
    rep(i,s.size()){
        int m = s[i] -'a';
        g[m][0]++;
        g[m][g[m][0]] = i;
    }

    rep(i,26){
        // cout << i << endl;
        if(v[i][0]>1){
            bool flag = false;
            char c;
            rep(j,v[i][0]){
                if(!flag){
                    c = s[v[i][j+1]];
                    flag = true;
                }else{
                    if(c!=s[v[i][j+1]]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
        if(g[i][0]>1){
            bool flag = false;
            char c;
            rep(j,g[i][0]){
                if(!flag){
                    c = t[g[i][j+1]];
                    flag = true;
                }else{
                    if(c!=t[g[i][j+1]]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
        // else if(v[i][0]==1){
        //     char c = s[v[i][1]];
        //     rep(j,g[i][0]){
        //         if(c!=t[g[i][j+1]]){
        //             cout << "No" << endl;
        //             return 0;
        //         }
        //     }
        // }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 45020
#include <iostream>

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

using namespace std;

int main() {
	while (1) {
		int n, m, a, h, p, q, k;
		int mp[1003][102];

		cin >> n >> m >> a;
		if (n == 0 && m == 0 && a == 0) break;

		REP(j, 1003) { REP(l, 102) mp[j][l] = 0; }

		REP(i, m) {
			
			/*REP(j, 1003) {
				REP(l, 102) {
					if (mp[j][l]) {
						cout << j << " " << l << endl;
					}
				}
			}
			// cerr << "------------" << endl;*/
			
			cin >> h >> p >> q;
			mp[1003 - h][p] = q;
			mp[1003 - h][q] = p;
		}

		k = a;

		REP(j, 1003) {
			REP(l, 102) {
				if (mp[j][l]) {
					// cerr << j << " " << l << endl;
				}
			}
		}
		// cerr << "------------" << endl;

		REP(j, 1003) {
			if (mp[j][k]) {
				k = mp[j][k];
				// cerr << j << " " << k << endl;
			}
			
		}

		cout << k << endl;
	}
}


Measured memory_bytes: 3404
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))

const int MAX = 5100000;
const long long MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



ll T(ll r, ll c) {
	return COM(r + c + 2, r + 1) - 1;
}

ll mod(ll x) {
	return (x % MOD + MOD) % MOD;
}

int main() {
	COMinit();
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	--r1; --c1;
	ll ans = T(r2, c2);
	ans = mod(ans);
	ans -= T(r2, c1);
	ans = mod(ans);
	ans -= T(r1, c2);
	ans = mod(ans);
	ans +=T(r1, c1);
	ans = mod(ans);
	PRI(ans);
	return 0;
}




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

int main() {
  int n;
  cin >> n;
  
  vector<int64_t> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  int64_t ans = 1;
  
  bool z = true;
  
  for (int i = 0; i < n; i++){
    if (a.at(i) == 0){
      z = false;
    }
  }
  
  bool x = true;
  
  if (z){
    for (int i = 0; i < n; i++){
      if (a.at(i) <= 1000000000000000000LL / ans){
        ans *= a.at(i);
      }
      else{
        cout << -1 << endl;
        x = false;
        break;
      }
    }
  }
  else {
    cout << 0 << endl;
  }
  
  if (z && x){
    cout << ans << endl;
  }
}

Measured memory_bytes: 4044
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000];
int main()
{
	while(~scanf("%s",a))
	{
		int len=strlen(a);
		printf("%c%d%c\n",a[0],len-2,a[len-1]);	
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
const int INF = 1001001001;
const ll LINF = 1e18;

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


int main(){
    ll N; cin >> N;
    vl xs(N, 0), t_xs(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> xs[i];
        t_xs[i] = xs[i];
    }
    
    sort(xs.begin(), xs.end(), less<ll>());
    ll l_max = xs[N / 2 - 1];
    ll r_min = xs[N / 2];
    
    for (ll i = 0; i < N; i++) {
        ll res = 0;
        if(t_xs[i] <= l_max) res = r_min;
        else res = l_max;
        cout << res << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int main() {

	int n;
	cin>>n;
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		if(a>b&&a>c&&a*a==b*b+c*c)cout<<"YES"<<endl;
		else if(a<b&&b>c&&b*b==a*a+c*c)cout<<"YES"<<endl;
		else if(c>b&&a<c&&c*c==b*b+a*a)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    vector<pii> v(n);
    rep(i, n) { cin >> v[i].F; v[i].S = i; }
    sort(all(v));
    
    set<int> s; // index
    s.insert(-1);
    s.insert(n);
    
    ll ans = 0;
    rep(i, n) {
        auto it = s.upper_bound(v[i].S);
        auto it2 = it;
        --it2;
        ans += (ll)v[i].F * (*it - v[i].S) * (v[i].S - *it2);
        
        s.insert(v[i].S);
        // cout << *it << " " << *it2 << endl;
        // for (auto e : s) cout << e << " "; cout << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11264
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
// const int N = ;
int a, b;
int main() {
	cin >> a >> b;
	cout << a + b / 2 << '\n';
	return 0;
}

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

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x-k+1; i <= x+k-1; i++) {
        if (i != x+k-1) cout << i << " ";
        else cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;

  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  
  int result = 1;
  int maxH = v.at(0);
  for(int i = 1; i < n; i++){
    if(v.at(i) >= maxH){
      maxH = v.at(i);
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int war = x/100;
    int ama = x%100;
    int a5 = ama/5;
    int a4 = (ama-a5*5)/4;
    int a3 = (ama-a5*5-a4*4)/3;
    int a2 = (ama-a5*5-a4*4-a3*3)/2;
    int a1 = (ama-a5*5-a4*4-a3*3-a2*2)/1;
    //cout<<a1<<endl<<a2<<endl<<a3<<endl<<a4<<endl<<a5<<endl;
    int sum=a1+a2+a3+a4+a5;
    //cout << war <<endl<<ama<<endl<<sum<<endl;
    if(war<sum){
        cout << 0<<endl;
        return 0;
    }else{
        cout << 1 <<endl;
    }
    return 0;
}


Measured memory_bytes: 256