akhauriyash/Code-Regression huggingface dataset:
import math
import sys

INF = 10**10
(N, K) = list(map(int,input().split()))
(R, S, P) = list(map(int,input().split()))
T = input()

#print(N,K)
#print(R,S,P)
#print(T)

def maxp(s):
    vr = 0
    vs = 0
    vp = 0
    for i in range(0,len(s)):
        if s[i] == 'r':
            nvr = 0 + max(vs,vp)
            nvs = 0 + max(vp,vr)
            nvp = P + max(vr,vs)
        elif s[i] == 's':
            nvr = R + max(vs,vp)
            nvs = 0 + max(vp,vr)
            nvp = 0 + max(vr,vs)
        else:
            nvr = 0 + max(vs,vp)
            nvs = S + max(vp,vr)
            nvp = 0 + max(vr,vs)
        vr = nvr
        vs = nvs
        vp = nvp
        #print(s[i],vr,vs,vp)
    return(max(vr,vs,vp))
ans=0
for i in range(0,K):
    p = ""
    for k in range(i,len(T),K):
        p = p + T[k]
    #print(p)
    ans  = ans + maxp(p)
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define INF 9223372036854;
#define ll long long
const long int m = 1000000007;


int main()
{
    int n,k;
    cin>>n>>k;
    int dp[2][k+1];
    memset(dp,0,sizeof(dp));
    int arr[n] = {0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int i,j,x,l,c;
    for(i=0;i<2;i++)
    {
        dp[i][0] = 1;
    }
    for(i=0;i<=k;i++)
    {
        dp[0][i] = 1;
    }
    for(c=1;c<=n;c++)
    {
        for(j=1;j<=k;j++)
        {
            x = min(arr[c-1],j);
            i = c%2;
            if(x==j)
            {
                if(i==0)
                dp[i][j] = dp[i+1][j];
                else
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                if(i==0)
                dp[i][j] = (dp[i+1][j] - dp[i+1][j-x-1] + m)%m;
                else
                dp[i][j] = (dp[i-1][j] - dp[i-1][j-x-1] + m)%m;
            }
            dp[i][j] = (dp[i][j]%m+dp[i][j-1]%m)%m;
        }
    }
    if(k==0) cout << dp[n%2][k];
    else cout << (dp[n%2][k]-dp[n%2][k-1] + m)%m;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1005;
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int A[100000];
 int main() {
	 int N;
	 cin >> N;
	 for (int i = 0; i < N; i++) cin >> A[i];
	 multiset<int> S;
	 for (int i = N - 1; i >= 0; i--) {
		 auto itr = S.upper_bound(A[i]);
		 if (itr == S.end()) {
			 S.insert(A[i]);
		 }
		 else {
			 S.erase(itr);
			 S.insert(A[i]);
		 }
	 }
	 cout << S.size() << endl;
}

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

int main() {
	long long n,i,c;
	cin >> n;
	deque<long long> a;
	if(n%2==0){
		for(i=0; i<n; i+=2){
			cin >> c;
			a.push_back(c);
			cin >> c;
			a.push_front(c);
		}
	}else{
		cin >> c;
		a.push_front(c);
		for(i=1; i<n; i+=2){
			cin >> c;
			a.push_back(c);
			cin >> c;
			a.push_front(c);
		}
	}
	for(i=0; i<n; i++){
		cout << a[i] << ' ';
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    int dx[]={0,1,0,-1};
    int dy[]={1,0,-1,0};
    vector<vector<char> > c(h,vector<char>(w));
    int cnt=0;
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        if (c[i][j]=='#') cnt++;
    }
    queue<pi> que;
    vector<vi> dist(h,vi(w,-1));
    dist[0][0]=0;
    que.emplace(0,0);
    while(que.size()){
        int y,x;
        tie(y,x) = que.front(); que.pop();
        rep(i,4){
            int tx = x+dx[i];
            int ty = y+dy[i];
            if (!(0<=tx&&tx<w&&0<=ty&&ty<h)) continue;
            if (c[ty][tx]=='#') continue;
            if (dist[ty][tx]!=-1) continue;
            dist[ty][tx]=dist[y][x]+1;
            que.emplace(ty,tx);
        }
    }
    if (dist[h-1][w-1]==-1){
        cout<<"-1\n";
    }else{
        cout<<h*w-(dist[h-1][w-1]+1)-cnt<<endl;
    }
    return 0;
}


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

bool check(const string &s) {
	int sum = 0;
	for(int i = 1; i < s.size(); ++i) {
		const int p = s[i] - '0';
		const int q = (i <= 6 ? i + 1 : i - 5);
		sum += p * q;
	}

	sum %= 11;

	if(sum <= 1) {
		return s[0] == '0';
	}
	else {
		return s[0] - '0' == 11 - sum;
	}
}

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

	reverse(begin(s), end(s));

	set<int> S;
	for(int i = 0; i < s.size(); ++i) {
		if(s[i] == '?') {
			for(char c = '0'; c <= '9'; ++c) {
				s[i] = c;
				if(check(s)) {
					S.emplace(c - '0');
				}
			}
		}
	}

	if(S.size() > 1) {
		cout << "MULTIPLE" << endl;
	}
	else {
		cout << *S.begin() << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n), b(n);
  cin >> a >> b;
  rep(i, n) a[i]--, b[i]--;
  using T = tuple<int, int, int>; // count, last, used set
  pqasc<T> q;
  q.emplace(0, 0, 0);
  vector<vi32> dp(50, vi32(bit32(n), 1e9));
  while (sz(q)) {
    int cnt, prev, used;
    tie(cnt, prev, used) = q.top();
    q.pop();
    if (dp[prev][used] != 1e9) {
      continue;
    }
    dp[prev][used] = cnt;
    if (used == bit32(n) - 1) {
      cout << cnt << endl;
      return;
    }
    int c = __builtin_popcount(used);
    rep(i, n) {
      if (used & bit32(i)) continue;
      int now;
      if (c % 2 == i % 2) {
        now = a[i];
      } else {
        now = b[i];
      }
      if (prev > now) continue;
      int from = i + __builtin_popcount(used & ((bit32(n) - 1) ^ (bit32(i) - 1)));
      q.emplace(cnt + from - c, now, used | bit32(i));
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 54396
#include<cstdio>

int main(){
  int sosu[1001]={};

  for(int i=2;i*i<=1000;i++){
    if(sosu[i]==0){
      for(int j=2;i*j<=1000;j++){
        sosu[i*j]=1;
      }
    }
  }

  int n;
  scanf("%d",&n);
  int yaku[10000]={};

  for(int i=2;i<=n;i++){
    for(int j=2;j<=i;j++){
      if(sosu[j]==0 && i%j==0){
        int k = i;
        while(k%j==0){
          yaku[j]++;
          k/=j;
        }
      }
    }
  }

  unsigned long long ans=1;

  for(int i=n;i>=2;i--){
    ans*=(yaku[i]+1);
    ans%=1000000007;
  }

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

  

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

int main(){

  int n;
  char s;
  set<char> st;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    st.insert(s);
  }

  if(st.size()==3) cout<<"Three"<<endl;
  else cout<<"Four"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
	int a=0,b=0;  //??°?????\?????¨?????°
	int ans=0;    //????????¨?????°
	char op;      //???????????¨?????°

	

	while(1){
		cin >> a >> op >> b;      //??°?????????????????\???
	if(op == '+'){             //???
		ans = a + b;
		cout << ans << endl;
	}
	
	else if(op == '-'){        //???
		ans = a - b;
		cout << ans << endl;
	}

	else if(op == '*'){        //???
		ans = a * b;
		cout << ans << endl;
	}

	else if(op == '/'){        //???
		ans = a / b;
		cout << ans << endl;
	}
	else{
		break;                 //???????????????
	}
	}
	
	return 0;

}

Measured memory_bytes: 1164
N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = (ans * ((2*i) - (count*2)))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = (ans * ((2*i + 1) - (count*2)))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)

Measured memory_bytes: 3516
#include<stdio.h>
int main()
{
    long long int a,b;
    char ch;
    scanf("%lld %c %lld",&a,&ch,&b);
    if(ch=='+')
    {
        printf("%lld",(a+b));
    }
    else
    {
        printf("%lld",(a-b));
    }

return 0;
}


Measured memory_bytes: 128
/*
  Contest 073
  B - Theater
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    std::vector<std::pair<int, int>> log;
    while (n--) {
        int s = 0, e = 0;
        std::cin >> s >> e;
        log.emplace_back(std::make_pair(s, e));
    }

    std::sort(log.begin(), log.end(), [](const std::pair<int, int>& s,
                                         const std::pair<int, int>& e) {
                                          return s.second < e.second;
                                      });
    int chal_chitra_seats = 0;
    std::pair<int, int> p = log[0];
    for (std::size_t i = 1; i < log.size(); ++i) {
        if (log[i].first <= p.second) {
            p = std::make_pair(p.first, log[i].second);
        } else {
            chal_chitra_seats += p.second - p.first + 1;
            p = log[i];
        }
    }
    chal_chitra_seats += p.second - p.first + 1;
    std::cout << chal_chitra_seats << std::endl;

    return 0;
}


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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int n; cin >> n; n %= 10;

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A + B >= C) {
		printf("%d", B + C);
	}
	else {
		printf("%d", B + C - (C - A - B - 1));
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int dp[200100][3];//dp[i][j]で直前にj個の数を使いi文字目まで分割した時の最大値
int main() {
	string s; cin >> s;
	int n;
	n = s.size();
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	dp[1][1] = 1;
	for (int i = 1; i <= n-1; ++i) {
		for (int j = 1; j <=2; ++j) {
			if (s[i-1] != s[i]) {
				dp[i + 1][1] = dp[i][1] + 1;
				dp[i + 1][2] = dp[i - 1][1] + 1;
			}
			else {
				dp[i + 1][2] = dp[i - 1][1] + 1;
				dp[i + 1][1] = dp[i][2] + 1;
			}
		}
	}
	cout << max(dp[n][1], dp[n][2]) << endl;
	return 0;
}

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

ll x[100];
ll check[60][60][3000];

ll dp(ll j, ll k, ll a){
    if(check[j][k][a] != -1){
        return check[j][k][a];
    }

    if(j == 0 && k == 0 && a == 0){
        check[j][k][a] = 1;
        return 1;
    }
    else if(j >= 1 && a < x[j - 1]){
        check[j][k][a] = dp(j - 1, k, a);
        return check[j][k][a];
    }
    else if(j >= 1 && k >= 1 && a >= x[j - 1]){
        check[j][k][a] = dp(j - 1, k, a) + dp(j - 1, k - 1, a - x[j - 1]);
        return check[j][k][a];
    }
    else
        check[j][k][a] = 0;
        return 0;
}

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

    rep(i, 60)
        rep(j, 60)
            rep(k, 3000)
                check[i][j][k] = -1;

    rep(i, n){
        cin >> x[i];
    }

    ll sum = 0;
    for(int i = 1; i <= n; i++){
        sum += dp(n, i, i * a);
    }

    cout << sum << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n+2];
    for(int i=0; i<n; i++){
        cin >> a[i+1];
    }
    a[0] = 0; a[n+1] = 0;
    long long sum[n+2];
    sum[0] = 0;
    for(int i=0; i<n+1; i++){
        sum[i+1] = sum[i] + abs(a[i+1]-a[i]);
    }
    for(int i=0; i<n; i++){
        cout << sum[i] + abs(a[i]-a[i+2]) + (sum[n+1]-sum[i+2]) << 
            endl;
    }
    return 0;
}


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

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

    string digits = to_string(a) + to_string(b);
    int number = stoi(digits);

    int MAX_NUMBER = 100100;

    int i = 0;
    bool isPower = false;
    while (pow(i, 2) <= MAX_NUMBER) {
        if (pow(i, 2) == number) isPower = true;
        i++;
    }

    string ans = isPower ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


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

const int maxn=1e5+1;
int n,i,dir,times;
long long C,ans,x[2][maxn],v[2][maxn],sum[3][2][maxn];

int main()
{
	cin>>n>>C;
  	for(i=1;i<=n;i++)
    {
      	cin>>x[0][i]>>v[0][i];
      	x[1][n+1-i]=C-x[0][i];
      	v[1][n+1-i]=v[0][i];
    }
  	for(dir=0;dir<2;dir++)
    	for(i=1;i<=n;i++)
      		v[dir][i]+=v[dir][i-1];
  	for(times=0;times<2;times++)
    	for(dir=0;dir<2;dir++)
    		for(i=1;i<=n;i++)
	  			sum[times][dir][i]=max(sum[times][dir][i-1],v[dir][i]-(times+1)*x[dir][i]);
  	for(i=0;i<=n;i++)
    ans=max(ans,max(sum[0][0][i]+sum[1][1][n-i],sum[0][1][i]+sum[1][0][n-i]));
  	cout<<ans;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

const int MS = 1005;
int n, m;
char s[MS], t[MS];

int main()
{
	scanf("%s%s", s, t);
	n = strlen(s);
	m = strlen(t);
	int ans = 2000;
	F(i, 0, n - m)
	{
		int tmp = 0;
		F(j, 0, m - 1) tmp += (s[i + j] != t[j]);
		ans = min(ans, tmp);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<P>r(n), b(n);
	rep(i, n)cin >> r[i].first >> r[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int x = b[i].first; int y = b[i].second;
		int tmp = -1; int idx = -1;
		rep(j, r.size()) {
			if (r[j].first < x&&r[j].second < y) {
				if (r[j].second > tmp) {
					tmp = r[j].second; idx = j;
				}
			}
		}
		if (idx >= 0) {
			ans++; r.erase(r.begin() + idx);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int n,m;
  cin>>n>>m;
  int a[n],b[n];
  r(i,n)cin>>a[i];
  b[n-1]=a[n-1];
  for(int i=n-1;i>0;i--){
    b[i-1]=max(a[i-1],b[i]);
  }
  int MAX=0;
  for(int i=0;i<n;i++){
    MAX=max(MAX,b[i]-a[i]);
  }
  int sum=0;
  r(i,n){
    if(b[i]-a[i]==MAX)sum++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ").map{x -> x.toInt()}
    val X = input[0]
    val A = input[1]
    val B = input[2]

    fun taste(x: Int) : String {
        if (x >= 0) return "delicious"
        else if (x+X >= 0) return "safe"
        else return "dangerous"
    }

    println(taste(A-B))
}

Measured memory_bytes: 37864
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        List<long> has = Enumerable.Range(0, N).Select(v => NextLong()).ToList();
        // X = B - A
        //双方からXで進むと考える
        long ans = 0;
        for (int x = 1; x < N; x++)
        {
            long sum = 0;
            int L = 0, R = N - 1;
            if ((N - 1) % x == 0)
            {
                //落ちるので L < R を保つ
                while (L < R)
                {
                    sum += has[L] + has[R];
                    ans = Math.Max(sum, ans);
                    L += x;
                    R -= x;
                }
            }
            else
            {
                //交わらないので L < R じゃなくてok
                int A = (N - 1) - L;
                while (x < A)
                {
                    sum += has[L] + has[R];
                    ans = Math.Max(sum, ans);
                    L += x;
                    R -= x;
                    A = (N - 1) - L;
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 31836
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define int long long int 
using namespace std;

// Author: Ashish

set<int> nums;
int maxn=10000000000;
void num(int d)
{
	if(d>=maxn) return;
	if(nums.count(d)) return;
	nums.insert(d);
	int digit=d%10;
	if(digit>0) num(d*10+digit-1);
	num(d*10+digit);
	if(digit<9) num(d*10+digit+1);
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for(int i=1;i<10;i++) num(i);
  int k;
	cin>>k;
	k--;
	while(k--)
	{
		int val=*nums.begin();
		nums.erase(val);
	}
	cout<<*nums.begin();


 	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<long long int> a(3 * N);
	for (int i = 0; i < 3 * N; i++){
		std::cin >> a[i];
	}

	std::sort(a.begin(), a.end(), std::greater<long long int>());
	long long int ans = 0;
	for (int i = 0; i < N; i++){ ans += a[2 * i + 1]; std::cerr << i << std::endl; }

	std::cout << ans << std::endl;

	return  0;
}

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

int main() {
  char s_1, s_2, s_3;
  cin >> s_1 >> s_2 >> s_3;
  
  int ans = s_1 - '0' + s_2 - '0' + s_3 - '0';
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    cout<<(s.substr(0,4)=="YAKI" ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
import java.util.*;


class Main{

     public static void main(String []args){
        Scanner sc= new Scanner(System.in);
        int x = sc.nextInt();
        int t = 0;
        int[] v= new int[x];
        int[] c= new int[x];
        
        for(int i = 0 ; i < x; i++){
            v[i]=sc.nextInt();
            
        }
        for(int i = 0 ; i < x; i++){
            c[i]=sc.nextInt();
            
        }
        for(int i = 0 ; i < x; i++){
        
            if( v[i] > c[i] ){
                t = t + v[i]-c[i];
            }
        }
        System.out.println(t);
        
        
     }
}

Measured memory_bytes: 22868
#include <cstdio>
#include <iostream>

using namespace std;

int F[50];

int fib(int n) {

	if (n == 0 || n == 1)
		return 1;
	if (F[n] != 0)
		return F[n];

	F[n] = fib(n - 1) + fib(n - 2);

	return F[n];
}

int main() {

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		F[i] = 0;
	}

	cout << fib(n) << endl;

	return 0;

}

Measured memory_bytes: 3144
lines = input().split()
last_a = lines[0][len(lines[0])-1]
first_b = lines[1][0]
last_b = lines[1][len(lines[1])-1]
first_c = lines[2][0]

if last_a == first_b and last_b == first_c:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
ll N, C;
ll D[500][500];
int c[500][500];
////////////

int main()
{
	cin >> N >> C;
	for (i = 0; i < C; i++) {
		for (j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			cin >> c[i][j];
		}
	}
	vector<ll> zero(C, 0);
	vector<ll> one(C, 0);
	vector<ll> two(C, 0);
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			for (k = 0; k < C; k++) {
				if ((i + j + 2) % 3 == 0) {
					zero[k] += D[c[i][j]-1][k];
				}
				else if ((i + j + 2) % 3 == 1) {
					one[k] += D[c[i][j]-1][k];
				}
				else {
					two[k] += D[c[i][j]-1][k];
				}
			}
		}
	}
	ll ans = 10000000000;
	for (i = 0; i < C; i++) {
		for (j = 0; j < C; j++) {
			for (k = 0; k < C; k++) {
				if (i != j && j != k && k != i) {
					ans = min(ans, zero[i] + one[j] + two[k]);
				}
			}
		}
	}
	cout << ans;

}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

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

	vll accum(N);

	ll ans = LLINF;


	// +-+-+....
	ll local_ans = 0;
	if (A[0] <= 0)
	{
		local_ans += abs(A[0]) + 1;
		accum[0] = 1;
	}
	else
	{
		accum[0] = A[0];
	}
	for (int i = 1; i < N; i++)
	{
		accum[i] = accum[i - 1] + A[i];
		if (i % 2 == 0)
		{
			// +
			if (accum[i] <= 0)
			{
				local_ans += abs(accum[i]) + 1;
				accum[i] = 1;
			}
		}
		else
		{
			if (accum[i] >= 0)
			{
				local_ans += abs(accum[i]) + 1;
				accum[i] = -1;
			}
		}
	}
	ans = min(ans, local_ans);

	// -+-+....
	local_ans = 0;
	if (A[0] >= 0)
	{
		local_ans += abs(A[0]) + 1;
		accum[0] = -1;
	}
	else
	{
		accum[0] = A[0];
	}

	for (int i = 1; i < N; i++)
	{
		accum[i] = accum[i - 1] + A[i];
		if (i % 2 == 0)
		{
			// -
			if (accum[i] >= 0)
			{
				local_ans += abs(accum[i]) + 1;
				accum[i] = -1;
			}
		}
		else
		{
			if (accum[i] <= 0)
			{
				local_ans += abs(accum[i]) + 1;
				accum[i] = 1;
			}
		}
	}
	ans = min(ans, local_ans);

	cout << ans << endl;

}





Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib> 

int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(a - c) <= d){
		printf("Yes");	
		return 0;
	}
	else{
		if((abs(a - b) <= d) && (abs(c - b) <= d)) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 128
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str="";
		String[] dset;
		double[] moji=new double[6];
		double[] kotae=new double[2];

		while(sc.hasNext()) {
			str=sc.next();
			dset=str.split(",");
			for(int i=0; i<6; i++) {
				moji[i]=Double.parseDouble(dset[i]);
			}
			kotae=kotae(moji);
			System.out.println(kotae[0]+" "+kotae[1]);
			moji=new double[6];
			kotae=new double[2];
		}
	}

	public static double[] kotae(double[] a) {
		double[] ansary=new double[2];
		ansary[0]=0;
		ansary[1]=0;
		double difx=0;
		double dify=0;
		double ktm1=0;

		double[] cyokusen = new double[3];		// katamuki suihei_ka_suicyoku_ka  y_spn
												//y jiku ni heikou -1  x jikuni heikou 1
		double[] suisen=new double[3];		//	suise wo hiku

		difx=a[2]-a[0];
		dify=a[3]-a[1];

		if(Math.abs(dify)==0) {
			cyokusen[0]=0;
			cyokusen[1]=4;
			cyokusen[2]=a[3];		// y seppen

			suisen[0]=0;
			suisen[1]=-4;
			suisen[2]=a[4];		// y jiku heikou nara   x seppen

			ansary[0]=a[4];
			ansary[1]=cyokusen[2]*2-a[5];

			return ansary;


		}
		else if(Math.abs(difx)==0) {
			cyokusen[0]=0;
			cyokusen[1]=-4;
			cyokusen[2]=a[2];		// x seppen

			suisen[0]=0;
			suisen[1]=4;
			suisen[2]=a[5];				//垂線のあたりが微妙

			ansary[0]=cyokusen[2]*2-a[4];
			ansary[1]=suisen[2];

			return ansary;
		}
		else {
			cyokusen[0]=dify/difx;
			cyokusen[1]=0;
			cyokusen[2]=a[3]-cyokusen[0]*a[2];

			ktm1=-1/cyokusen[0];

			suisen[0]=ktm1;
			suisen[2]=a[5]-suisen[0]*a[4];

			ansary[0]=-1*(cyokusen[2]-suisen[2])/(cyokusen[0]-suisen[0]);
			ansary[1]=ansary[0]*cyokusen[0]+cyokusen[2];		//交点

			//System.out.println(ansary[0]+","+ansary[1]);
			ansary[1]=ansary[1]*2-a[5];
			ansary[0]=ansary[0]*2-a[4];

		}
		return ansary;
	}
}


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

using namespace std;
using ll = long long;

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

int main() {
    ll N, L, T;
    cin >> N >> L >> T;

    auto x = Vec<ll>(N, 0LL), w = Vec<ll>(N, 0LL);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> w[i];
        w[i] = 3 - w[i] * 2;  // (1, 2) -> (1, -1)
    }

    ll confl = 0;  // 蟻0の衝突回数
                   // 最後に同じ場所についたときはカウントしない
    for (int i = 1; i < N; ++i) {
        if (w[0] == w[i]) continue;
        if (w[0] > 0) {
            confl += iceil(x[0] - x[i] + T * 2, L);
        } else {
            confl += iceil(x[i] - x[0] + T * 2, L) - 1;
        }
    }

    confl %= N, T %= L;
    ll id0 = (confl * w[0] + N) % N;  // 蟻0の最終的な番号

    for (int i = 0; i < N; ++i) {
        x[i] = (x[i] + T * w[i] + L) % L;
    }
    ll x0 = x[0];  // 蟻0の最終的な位置

    sort(x.begin(), x.end());
    auto itr = lower_bound(x.begin(), x.end(), x0);
    if (w[0] < 0) itr = --upper_bound(x.begin(), x.end(), x0);
    // 同じ位置に蟻が2匹いるとき、回る方向によってどっちを蟻0にするかが変わる

    auto ans = Vec<ll>(N, 0LL);
    for (int j = 0; j < N; ++j) {
        ans[(id0 + j) % N] = *itr;
        if (++itr == x.end()) itr = x.begin();
    }

    for (auto& e : ans) cout << e << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    
    if(s == "RRR"){
        cout << "3" << endl;
    }
    else if(s == "RRS" || s == "SRR"){
        cout << "2" << endl;
    }
    else if(s == "SSS"){
        cout << "0" << endl;
    }
    else
    {
        cout << "1" << endl;
    }
    
}

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

int main() {
    char c;
    
    cin >> c;
    
    if(c=='a' || c=='i'||c=='u'||c=='e'||c=='o'){
        cout <<"vowel"<<endl;
    }else{
        cout <<"consonant"<<endl;
    }
    
    return 0;
}


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

int main(void){
  string sen;
  int n;
  cin >> n;
  cin.ignore();
  for(int i = 0; i < n; i++){
    getline(cin, sen);
    int k = 0;
    while(true){
      k = sen.find("Hoshino", k);
      if(k < 0) break;
      sen[k+6] = 'a';
      k++;
    }
    cout << sen << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

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

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll N, M;

int main(){
	while(cin >> N >> M && N > 0 && M > 0){
		priority_queue<ll> q[110];
		ll ans = 0;
		REP(i,0,N){
			ll d, v;
			cin >> d >> v;
			d--;
			q[d].push(v);
		}
		REP(i,0,M){
			ans += q[i].top();
		}
		p(ans);
	}

	return 0;
}


Measured memory_bytes: 3156
N,P = [int(hoge) for hoge in input().split()]
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

S = factorization(P)
ans = 1
for p in S:
    ans *= p[0]**(p[1]//N)
print(ans)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int fl=1;
  for(int i=0;i<s.length();i++)
  {
   if(i%2==0){
      if(s[i]=='R'|| s[i]=='U'|| s[i]=='D')
      {
         fl=fl*1;
      }
      else fl=fl*0;
   }
   else
   {
      if(s[i]=='L'|| s[i]=='U'|| s[i]=='D')
      {
         fl=fl*1;
      }
      else fl=fl*0;

   }
  }
  if(fl) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
bool chmin(long long &a, long long b) { if (a > b) {a = b; return true;} return false;}
using Edge = pair<int, long long>;
int N, M;
vector<vector<Edge> > G;
int main(){
    cin >> N >> M;
    G.clear(); G.resize(N);
    for (int i = 0; i < M; ++i) {
        int a, b; long long w;
        cin >> a >> b >> w; --a, --b;
        G[a].push_back(Edge(b, -w));
    }

    vector<long long> dist(N, INF);
    bool negative = false;
    dist[0] = 0;
    for (int iter = 0; iter <= N*2; ++iter) {
        for (int v = 0; v < N; ++v) {
            if (dist[v] >= INF/2) continue;
            for (auto e : G[v]) {
                if (chmin(dist[e.first], dist[v] + e.second)) {
                    if (e.first == N-1 && iter == N*2) negative = true;
                }
            }
        }
    }
    if (!negative) cout << -dist[N-1] << endl;
    else cout << "inf" << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int fact[N], invfact[N];

void pre() {
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	invfact[N - 1] = modpow(fact[N - 1], mod - 2, mod);
	for(int i = N - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1) % mod;
	}
}
 
int ncr(int x, int y) {
	if(y < 0 || y > x)
		return 0;
	int res = fact[x] * invfact[y] % mod * invfact[x - y] % mod;
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	pre();
	int r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = 0;
	for(int i = c1; i <= c2; i++) {
		ans = (ans + ncr(r2 + i + 1, i + 1)) % mod;
		ans = (ans - ncr(r1 + i, i + 1) + mod) % mod;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 31488
D = int(input())
C = list(map(int, input().split()))
SS = [list(map(int, input().split())) for i in range(D)]

Last = [-1] * 26


for d in range(D):
    S = SS[d]
    t = -1
    x = -1e100
    minus=sum(c * (d-max(last, 0)) for c, last in zip(C, Last))
    for i, s in enumerate(S):
        score = s - minus + C[i] * (d - max(Last[i], 0))

        if score > x:
            x = score
            t = i

    print(t + 1)


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int pblist[10001]={0};
void makeList(int x)
{
	for(int i=2;i<=sqrt(x);i++)
	{
		int j=i;
		while((j*=i)<=x)
		  pblist[j]=1; 
	}
} 

int main()
{
	int a;
	cin>>a;
	makeList(a);
	bool flag=false;
	for(int i=a;i>=1;i--)
	{
		if(pblist[i])
		{
			cout<<i<<endl;
			flag=true;
			break;
	    }
	}
	if(!flag)
	  cout<<1<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A,B,C,D,s,t;

    scanf("%d %d %d %d",&A ,&B ,&C ,&D);


    if(A>B)
       s=B;
    else
       s=A;

    if(C>D)
       t = s+D;
    else
       t = s+C;
 
    printf("%d\n",t);
    return 0;
}

Measured memory_bytes: 128
from math import gcd

N, M = map(int, input().split())
A = list(map(int, input().split()))

memo = {}

def lcm(a,b):
    return a//gcd(a,b)*b

b = 1

for a in A:
    b = lcm(a//2, b)
    if b > M:
        break

if any([2 * b // a % 2 == 0 for a in A]):
    print(0)
else:
    ans = M // b
    print(ans - ans // 2)

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

#define ll long long
#define N (ll)(2*1e5)
#define EPS (double)(1e-12)
#define M (ll)(1e9+7)

using namespace std;


int main() {
    // 176 algorithm design manual
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s;

    cin >> s;

    map<char, int> teste;
    for(auto a : s) {
        teste[a]++;
    }

    if(teste.size() == 2)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include <unordered_map> 
#include<vector>
#include<queue>
#include <bits/stdc++.h> 
#include<string>
#define ll long long int
#define N 100005
using namespace std;
string s1,s2;
template <typename T> void max_self(T &a, T b){
	if(b>=a){
		a = b;
	}
}
int vis[N];
int dis[N];
vector<int>g[N];

void dfs(int r, int p){
    vis[r] = 1;
    int m = -1;
    for(auto v: g[r]){
        if(!vis[v])
            dfs(v,r);
        m = max(m,dis[v]);
    }
    dis[r] = m+1;
}
int main(){
	int n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++){
	    cin>>x>>y;
	    g[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
	    g[n+1].push_back(i);
	}
	dis[0] = -1;
	dfs(n+1,0);
	int ans =0;
	for(int i=0;i<=n+1;i++){
	   // cout<<i<<" "<<dis[i]<<endl;
	    ans = max(ans,dis[i]);
	}
	cout<<ans-1;
}


Measured memory_bytes: 9720
n = int(input())
s = input()
ans = 0
for pin in range(10**3):
    str_pin = str(pin)
    str_pin = str_pin.zfill(3)
    nex = 0
    for i in range(n):
        searching_for = str_pin[nex]
        now_s = s[i]
        if searching_for == now_s:
            nex += 1
            if nex == 3:
                ans += 1
                break
print(ans)



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


int main()
{
	int a, b;
	char op;
	
	while (true)
	{
		cin >> a >> op >> b;

		if (op == '?') {
			break;
		}
		else if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a * b << endl;
		}
		else {
			cout << a / b << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <set>
#include <cmath>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int tos(string s){
  int n = 0;
  rep(i,s.size()){
    n = n * 10 + s[i] - '0';
  }
  return n;
}

int main(void){
  string a,b;
  cin>>a>>b;
  int n = tos(a+b);
  bool f = false;
  rep(i,sqrt(n) + 1){
    if(i * i == n)f = true;
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 950527
using namespace std;
typedef unsigned long long ll;
map <ll,ll> map;

int main(){
  string a,b;
  cin>>a>>b;
  
  ll hs=0,n=0,t=1;
  for(int i=0;i<b.size();i++){
    hs=hs*base+b[i];
    n=n*base+a[i];
    t*=base;
  }
  
  if(hs==n) cout <<0<<endl;
  for(int i=b.size();i<a.size();i++){
    n=n*base-t*a[i-b.size()];
    n+=a[i];
    if(hs==n) cout <<i-b.size()+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3944
import java.util.Scanner;

public class Main {

    private static int board[][] = new int[8][8];

    private static int[][][] mino  = {{{0, 1},{1, 0},{1, 1}},
                                      {{1, 0},{2, 0},{3, 0}},
    	                              {{0, 1},{0, 2},{0, 3}},
    	                              {{1, 0},{1,-1},{2,-1}},
    	                              {{0, 1},{1, 1},{1, 2}},
    	                              {{1, 0},{1, 1},{2, 1}},
    	                              {{0, 1},{1, 0},{1,-1}}};

public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);

        char[] c;
        char ret;
        while(sc.hasNext()){
            for(int i=0;i<8;i++){
                c = sc.next().toCharArray();
                for(int j=0;j<8;j++){
                    board[i][j] = Character.digit(c[j],10);
                }
            }

            ret = 'N';
            loop:for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                    if(board[i][j] == 1){
                    	for(int k=0;k<7;k++){
                            if((ret = check(i,j,k)) != 'N'){
                            	break loop;
                            }
                    	}
                    }
                }
            }
            System.out.println(ret);
        }
    }

    private static char check(int i,int j,int kind){

        char ret = 'N';

        int i_2 = i + mino[kind][0][0],
            j_2 = j + mino[kind][0][1],
            i_3 = i + mino[kind][1][0],
            j_3 = j + mino[kind][1][1],
            i_4 = i + mino[kind][2][0],
            j_4 = j + mino[kind][2][1];

        if ( 0 <= i_2 && i_2 < 8 &&
             0 <= j_2 && j_2 < 8 &&
             0 <= i_3 && i_3 < 8 &&
             0 <= j_3 && j_3 < 8 &&
             0 <= i_4 && i_4 < 8 &&
             0 <= j_4 && j_4 < 8    ) {

            if(board[i_2][j_2]   == 1 &&
        	   board[i_3][j_3]   == 1 &&
          	   board[i_4][j_4]   == 1) {
                ret = chg(kind);
            }
        }
        return ret;
    }

    private static char chg(int i){

    	char ret = 'N';

    	switch(i){
    		case 0: { ret = 'A'; break;}
    		case 1: { ret = 'B'; break;}
    		case 2: { ret = 'C'; break;}
    		case 3: { ret = 'D'; break;}
    		case 4: { ret = 'E'; break;}
    		case 5: { ret = 'F'; break;}
    		case 6: { ret = 'G';       }
    	}
    	return ret;
    }
}

Measured memory_bytes: 20088
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	int n;
	cin >> n;
	int d;
	cin >> d;
	d = d * d;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		int dist = x * x + y * y;
		if (dist <= d)
			cnt++;
	}
	cout << cnt << "\n";
}


signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


// 2整数の最大公約数を求める関数
ll gcd(ll x, ll y) {
  if (y == 0)
    return (x);
  else
    return (gcd(y, x % y));
}

// 2整数の最小公倍数を求める関数
ll lcm(ll x, ll y) {
  return y / gcd(x, y) * x;
}

// 3個以上の整数の最大公約数を求める関数
ll gcdary(ll a[], ll n) {
  if (n == 1)
    return (a[0]);
  else if (n == 2)
    return (gcd(a[0], a[1]));
  else
    return (gcd(a[0], gcdary(&a[1], n - 1)));
}

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

  int n;
  cin>>n;
  ll t[n];
  rep(i,n) cin>>t[i];
  sort(t, t + n);
  ll now = t[0];
  rep(i,n) {
    now = lcm(now, t[i]);
  }
  cout << now << endl;


  return 0;
}


Measured memory_bytes: 256