akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#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(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	if ((a < c and c < b) or (b < c and c < a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
const int INF = 0x3f3f3f3f;
typedef long long LL;

string s;

int main(void)
{
    cin>>s;
    int len = s.length();
    if(s[len-1]=='s') s+="es";
    else s+="s";
    cout<<s<<endl;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, v[5010], cnt, C[5010], CK[5010];
long long Mod = 1000000007, po[5010], D[5010][5010], P[5010], F[5010];
int w[5010];
vector<int>E[5010];
void DFS(int a){
    v[a]=cnt;
    C[cnt]++;
    for(auto &x : E[a]){
        if(!v[x])DFS(x);
    }
}
long long Pow(long long a, long long b){
    long long r=1;
    while(b){
        if(b&1)r=r*a%Mod;
        a=a*a%Mod;b>>=1;
    }
    return r;
}
int main(){
    int i, j;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        if(w[i]!=-1){
            E[w[i]].push_back(i);
            E[i].push_back(w[i]);
        }
    }
    for(i=1;i<=n;i++){
        if(!v[i]){
            cnt++;
            DFS(i);
        }
    }
    int cc=0;
    for(i=1;i<=n;i++){
        if(w[i]==-1){
            CK[v[i]]=1;
            cc++;
        }
    }
    po[0]=1;
    F[0]=1;
    for(i=1;i<=n;i++)po[i]=po[i-1]*(n-1)%Mod, F[i]=F[i-1]*i%Mod;
    long long res=po[cc]*(n-cnt)%Mod;
    D[0][0]=1;
    for(i=1;i<=cnt;i++){
        for(j=0;j<=i;j++)D[i][j]=D[i-1][j];
        if(CK[i]){
            res=(res+(n-C[i])*po[cc-1])%Mod;
            P[i] = Pow(n-1,Mod-2)*C[i]%Mod;
            for(j=1;j<=i;j++)D[i][j]=(D[i][j]+D[i-1][j-1]*P[i])%Mod;
        }
    }
    for(i=2;i<=cnt;i++){
        res-=po[cc]*D[cnt][i]%Mod*F[i-1]%Mod;
        res=(res+Mod)%Mod;
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 120076
#include<cstdio>
#include<cstring>

int n;
int A[31];
/*DP????????????????????????*/
int solve(int k){
        if(A[k]>=0) return A[k];
        if(k==0) return A[k]=1;
        if(k==1) return A[k]=solve(k-1);
        if(k==2) return A[k]=solve(k-1)+solve(k-2);
        return A[k]=solve(k-1)+solve(k-2)+solve(k-3);
}

int main(){
        while(1){
                scanf("%d",&n);
                if(n==0) break;
                memset(A,-1,sizeof(A));
                printf("%d\n",solve(n)/10/365+1);
        }
        return 0;
}

Measured memory_bytes: 2564
classes = %w(light_fly fly bantam feather light light_welter welter light_middle middle light_heavy heavy)
upper_bound = [48,51,54,57,60,64,69,75,81,91, Float::INFINITY]
puts $<.map {|s|
    classes[upper_bound.index{|ub| s.to_f <= ub}].sub(?_, ' ')
}

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

int main(){
    long long int n;
    cin >> n;

    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    vector<int> b;
    int p = 1;
    while(n != 0){
        if(n % (long long int)pow(2,p) == 0){
            b.push_back(0);
        }
        if(n % (long long int)pow(2,p) != 0){
            b.push_back(1);
            n -= pow(-2,p-1);
        }
        p += 1;
    }

    for(int i=p-2; i>=0; i--){
        cout << b[i];
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
#define ll long long
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	char a, b; cin >> a >> b;
	if (a == 'H') {
		cout << b;
	}
	else {
		if (b == 'H') cout << 'D';
		else cout << 'H';
	}
	cout << endl;
}

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

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

  map<string, int> mp;
  int mx = 1;
  for(int i = 0; i < n; i++){
    string e; cin>>e;
    mp[e]++;
    if(mp[e] > mx) mx = mp[e];
  }

  for(auto i: mp){
      if(i.second == mx) cout<<i.first<<'\n';
    }
  return 0;
  }


Measured memory_bytes: 25216
from collections import defaultdict

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

R = defaultdict(set)

for i in range(M):
    a,b = map(int,input().split())
    R[a].add(b)
    
isok = False
for r in R[1]:
    if N in R[r]:
        isok = True
        break
        
if isok:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 74280
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]

from collections import defaultdict
d = defaultdict(int)
for i in range(m):
    d[ab[i][0]] += 1
    d[ab[i][1]] += 1

for i in range(1, n + 1):
    print(d[i])

Measured memory_bytes: 9468
#
# n, x, y = (int(x) for x in input().split())
# if y < x:
#     x, y = y, x
#
# def count(k):
#     sol = 0
#     sol += max(0, n - (y-x-1) - k)
#     d = y-x+1
#     if 2*k <= d:
#         if d > 2:
#             sol += d
#
#             if k == 1:
#                 sol -= 1
#     d//2
#
#
#
#

x, y, a, b, c = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort()
q.sort()
r.sort()
i = a-x
j = b - y
k = c-1
sol = sum(p[-x:])+sum(q[-y:])
while k>= 0 and i <a and j < b:
    d1 = r[k] - p[i]
    d2 = r[k] - q[j]
    if d1 < 0 and d2 < 0:
        break
    if d1 > d2:
        sol += d1
        i += 1
        k-=1
    else:
        sol += d2
        j += 1
        k -= 1

while k>=0 and i < a:
    d1 = r[k] - p[i]
    if d1 < 0:
        break

    sol += d1
    i += 1
    k-=1

while k>=0 and j < a:
    d1 = r[k] - q[j]
    if d1 < 0:
        break

    sol += d1
    j += 1
    k-=1

print(sol)

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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, unsigned int index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

long long ans = 0;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, 1, n) cin >> a[i];
    int flg = 0;
    rep(i, 1, n) {
        if(a[i] < 0) {
            flg++;
        }
    }

    rep(i, 1, n) {
        if (a[i] > 0) ans += a[i];
        else ans += a[i] * (-1);
    }

    if (flg%2) {
        int minm = abs(0-a[1]);
        rep(i, 2, n) {
            minm = min(minm, abs(0-a[i]));
        }
        ans = ans - minm * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

ll n,buf,ans;
int main() {
    cin>>n;
    REP(i,n){
        cin>>buf;
        ans+=buf-1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let r: usize = read!();
    let d: usize = read!();
    let x: usize = read!();

    let mut x = x;
    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
//T+N
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

ll inf = 4523372036854775807ll;

bool over(ll a, ll b) {
    return b > inf / a;
}

ll pow5util(ll x) {
    if(x == 0) {return 0;}
    ll now = 1;
    for(int i = 0; i < 5; i ++) {
        if(over(now, x)) {return inf;}
        now *= x;
    }
    return now;
}

ll pow5(ll x) {
    ll r = pow5util(abs(x));
    if(x < 0) {
        return r * -1;
    } else {
        return r;
    }
}

ll root5(ll x) {
    ll l = -mod, r = mod;
    while(l < r - 1) {
        ll m = (l + r) / 2ll;
        if(pow5(m) > x) {
            r = m;
        } else {
            l = m;
        }
    }
    return l;
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin >> x;
    for(ll a = 0; a <= 1e4; a ++) {
        for(ll b = -5e3; b <= 5e3; b ++) {
            if(pow5(a) - pow5(b) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3640
from functools import reduce
l = [int(input()) for _ in range(5)]
r = [10 if i % 10 == 0 else i %  10 for i in l]
m = [i  if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print(reduce(lambda a, b: a + b, m) + min(r) - 10)

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

typedef pair<int, int> P;
int H, W;
string grid[50];
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
int INF = 3000;

int bfs() {
	int d[50][50];
	for (int y = 0; y < H; y++)for (int x = 0; x < W; x++) d[y][x] = INF;

	queue<P> que;
	que.push(P(0, 0));
	d[0][0] = 0;
	while (!que.empty()) {
		P now = que.front();
		que.pop();
		if (now.first == H-1 && now.second == W-1) break;
		int y = now.first, x = now.second;
		for (int i = 0; i < 4; i++) {
			int ny = y + dy[i], nx = x + dx[i];
			if (0 <= ny && ny < H && 0 <= nx && nx < W && grid[ny][nx] != '#') {
				if (d[ny][nx] == INF) {
					d[ny][nx] = d[y][x] + 1;
					que.push(P(ny, nx));
				}
			}
		}
	}

	if (d[H - 1][W - 1] != INF) {
		return d[H - 1][W - 1];
	}
	else {
		return -1;
	}

}

int main() {
	cin >> H >> W;
	for (int y = 0; y < H; y++) {
		cin >> grid[y];
	}

	if (bfs() != -1) {
		int nDot = 0;
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				if (grid[y][x] == '.') nDot++;
			}
		}
		cout << nDot - (bfs() + 1) << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

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

using lint = long long;
using ldouble = long double;

struct Item {
    int a, b;
};

int main() {
    int n, t;
    std::cin >> n >> t;

    std::vector<Item> items(n);
    for (auto& x : items) {
        std::cin >> x.a >> x.b;
    }

    std::sort(items.begin(), items.end(),
              [](Item x, Item y) { return x.a < y.a; });

    std::vector<int> dp(t, 0);
    int ans = 0;
    for (auto& x : items) {
        ans = std::max(ans, dp.back() + x.b);
        for (int w = t - 1; w >= x.a; --w) {
            dp[w] = std::max(dp[w], dp[w - x.a] + x.b);
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,k,a[100],dp[2][100001];
int dfs(int p,int x){
    int y;
    if(dp[p][x]){
        return dp[p][x];
    }
    if(x<a[n-1]){
        if(p){
            dp[p][x]=1;
            return 1;
        }
        else{
            dp[p][x]=-1;
            return -1;
        }
    }
    for(int i=0;i<n;i++){
        if(x>=a[i]){
            y=dfs((p+1)%2,x-a[i]);
            if(y==1&&p==0){
                dp[p][x]=y;
                return y;
            }
            if(y==-1&&p==1){
                dp[p][x]=y;
                return y;
            }
        }
    }
    if(p){
        dp[p][x]=1;
        return 1;
    }
    else{
        dp[p][x]=-1;
        return -1;
    }
}
int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a[n-1-i]);
    }
    if(dfs(0,k)==1){
        printf("First\n");
    }
    else{
        printf("Second");
    }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

	int s=a+b;
	int ans=0;

	//????????????????????????????????§??????????????¢?´¢
	rep(t,5000000)
	{
		int now=60*t+c;
		if(now%s<=a)
		{
			ans=now;
			break;
		}

	}

	if(ans==0) ans=-1;

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf                        scanf    
 
const ll M=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % M;
        a = a * a % M;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

long long binpower(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpower(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

///////////// TEMPLATE END /////////////////////////////////



void solve()
{
	ll n;
	cin>>n;
	ll ans=(power(10,n,M)+power(8,n,M)-(2*power(9,n,M))%M+M)%M;
	
	cout<<ans<<endl;
}



int main()
{
    fastio

//    int t;
//    cin>>t;
//    fr1(i,t)
    {
//        cout<<"Case #"<<i<<": ";
        solve();
    }
   
    return 0;
}

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

void solve() {
    int n;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes\n";
            return;
        }
        n /= 10;
    }
    cout << "No\n";
}

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



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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    ll k, n;
    cin >> k >> n;
    ll arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    ll ans = 1e9;
    ans = min(ans, arr[n-1] - arr[0]);
    for(int i=0; i<n-1; i++)
        ans = min(ans, k - arr[i+1] + arr[i]);
    cout << ans;

    return 0;
}



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

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

    int s;
    cin>>s;
    int h,m;
    m=s/60;
    h=m/60;
    m=m-h*60;
    s=s-(h*3600+m*60);
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3172
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	int[][] map;
	int[][][] min;
	int[] c;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h) == 0) break;
			
			map = new int[h][w];
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) 
				map[i][j] = sc.nextInt();
			
			c = new int[4];
			for(int i=0;i<4;i++) c[i] = sc.nextInt();
			
			min = new int[h][w][4];
			for(int[][] a: min) for(int[] b: a) fill(b, INF);
			
			System.out.println(solve());
		}
	}
	
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	
	int solve() {
		PriorityQueue<Element> que = new PriorityQueue<Element>();
		que.add(new Element(0,0,2,0));
		min[0][0][2] = 0;
		for(;;) {
			Element e = que.remove();
			if( e.x == w-1 && e.y == h-1) return e.c;
			if(min[e.y][e.x][e.d] != e.c) continue;
			
			for(int i=0;i<4;i++) {
				int nx = e.x + dx[(i+e.d)%4];
				int ny = e.y + dy[(i+e.d)%4];
				if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
				if(i == map[e.y][e.x]) {
					if(min[ny][nx][(i+e.d)%4] <= e.c )continue;
					que.add(new Element(nx, ny, (i+e.d)%4, e.c));
					min[ny][nx][(i+e.d)%4] = e.c;
				}
				else {
					if(min[ny][nx][(i+e.d)%4] <= e.c+c[i])continue;
					que.add(new Element(nx, ny, (i+e.d)%4, e.c+c[i]));
					min[ny][nx][(i+e.d)%4] = e.c+c[i];
				}
			}
		}
	}
	
	class Element implements Comparable<Element>{
		int x, y, d, c;
		Element(int x, int y, int d, int c) {
			this.x = x;
			this.y = y;
			this.d = d;
			this.c = c;
		}
		@Override
		public int compareTo(Element o) {
			// TODO 自動生成されたメソッド・スタブ
			return c-o.c;
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
red, green, blue = gets.split.map(&:to_i)
K = gets.to_i

#  red < green < blue => TRUE
count = 0

def check(k, red, green, blue)
  K.times {
    if green > red && blue > green # red < green < blue
      return 'Yes'
    end
    # 2 2 1
    if blue <= green || blue <= red
      blue *= 2
    elsif green <= red
      green *= 2
    end
    #puts "red:#{red} green:#{green} blue:#{blue}"
  }
  return 'Yes' if green > red && blue > green # red < green < blue
  return 'No'
end

puts check(K, red, green, blue)


Measured memory_bytes: 14336
from itertools import combinations_with_replacement

N,M,Q=map(int,input().split())
abcd=[tuple(map(int,input().split())) for _ in range(Q)]

ans=0
for A in combinations_with_replacement(range(1,M+1),N):
  score = 0
  for i in range(Q):
    a,b,c,d=abcd[i]
    if A[b-1]-A[a-1]==c:
      score += d
  ans = max(ans,score)
  
print(ans)

Measured memory_bytes: 9172
#include <iostream>
using namespace std;
int main()
{
	int W = 0;
	int H = 0;
	int x = 0;
	int y = 0;
	int r = 0;
	cin >> W >> H >> x >> y >> r;

	if (-100 <= x && 100 >= x && -100 <= y && 100 >= y && 0 <= W && 100 >= W && 0 <= H && 100 >= H && 0 <= r && 100 >= r) {
		if ((x + r) <= W && (y + r) <= H && (x + r) >= 0 && (y + r) >= 0 && (x - r) >= 0 && (y - r) >= 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}



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

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
			return ;
		}
		
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
	char rotation[8][8] = {0};
	char dummy[80];
	int i, j;

	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
			scanf("%c", &rotation[i][j]);
		gets(dummy);
	}

	printf("90\n");
	for (j = 0; j < 8; j++)
	{
		for (i = 7; i >= 0; i--)
			printf("%c", rotation[i][j]);
		printf("\n");
	}

	printf("180\n");
	for (i = 7; i >= 0; i--)
	{
		for (j = 7; j >= 0; j--)
			printf("%c", rotation[i][j]);
		printf("\n");
	}

	printf("270\n");
	for (j = 7; j >= 0; j--)
	{
		for (i = 0; i < 8; i++)
			printf("%c", rotation[i][j]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    pair<pair<string, int>, int> p[110];

    cin >> n;
    REP(i, n)
    {
        cin >> p[i].first.first >> p[i].first.second;
        p[i].first.second *= -1;
        p[i].second = i + 1;
    }

    sort(p, p + n);

    REP(i, n)
    {
        cout << p[i].second << endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

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

  int x,t;
  cin>>x>>t;
   if(x<=t) cout<<0<<'\n';
   else 
  cout<<x-t<<'\n';
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-29(Wed)
   note   
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

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

  if (S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(3)){
    cout << "Good" << endl;
  }
  else {
    cout << "Bad" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())
As = list(map(int, input().split()))

s1 = 0
s2 = sum(As)

ans = 1e15
for i in range(N-1):
    s1 += As[i]
    s2 -= As[i]
    ans = min(ans, abs(s1 - s2))
print(ans)


Measured memory_bytes: 25808
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

int main() {
    ll N,K;
    cin >> N >> K;
    auto a = InputVec(N);
    vector<vector<ll>> memo(N + 1);
    for (int i = 0; i < N + 1; ++i) {
        memo[i] = vector<ll>(K + 1);
    }
    for (int i = 0; i <= N; ++i) {
        memo[i][0] = 1;
    }
    for (int i = 0; i < N; ++i) {
        vector<ll> memoSum(K + 1);
        memoSum[0] = memo[i][0];
        for (int j = 1; j <= K; ++j) {
            memoSum[j] = memoSum[j-1] + memo[i][j];
        }
        for (int j = 1; j <= K; ++j) {
            if(j - a[i] <= 0){
                memo[i + 1][j] = memoSum[j] % MOD7;
            }else{
                memo[i + 1][j] = (memoSum[j] - memoSum[j - a[i] - 1] + MOD7) % MOD7;
            }
        }
//        for (int j = 0; j <= K; ++j) {
//            for (int k = 0; k <= a[i-1]; ++k) {
//                if(j - k >= 0){
//                    memo[i][j] = (memo[i][j] + memo[i - 1][j - k]) % MOD7;
//                }
//            }
//        }
    }
    //OutputVec2d(memo);
    cout << memo[N][K] << endl;


}


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

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

        public static void Solve()
        {
            var (N, X, M) = Scanner.Scan<long, long, long>();
            static long F(long x, long m) => x % m;
            var a = X;
            var dict = new Dictionary<long, int>();
            var agg = new List<long>() { 0, a };
            var tmp = a;
            var loopStart = 0;
            var loopEnd = 0;
            dict[a] = 1;
            var isBreaked = false;
            for (var n = 2; n <= N && !isBreaked; n++)
            {
                tmp = F(a * a, M);
                if (dict.ContainsKey(tmp))
                {
                    loopStart = dict[tmp];
                    loopEnd = n;
                    isBreaked = true;
                }
                else
                {
                    dict[tmp] = n;
                }
                a = tmp;
                agg.Add(agg[agg.Count - 1] + tmp);
            }
            var answer = agg[agg.Count - 1];
            var remains = N - loopEnd;
            if (isBreaked && remains > 0)
            {
                answer += (agg[loopEnd] - agg[loopStart]) * (remains / (loopEnd - loopStart));
                var rem = (int)(remains % (loopEnd - loopStart));
                answer += agg[loopStart + rem] - agg[loopStart];
            }
            // Console.WriteLine(string.Join(" ", agg));

            Console.WriteLine(answer);
        }

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


Measured memory_bytes: 32316
fn main() {
    let (h, w, k) = read_tuple::<usize>();
    let cho: Vec<Vec<char>> = (0..h).map(|_|read::<String>().chars().collect::<Vec<char>>()).collect();


    let mut ans = 1e9 as usize;

    for div in 0..(1 << h-1) {
        let mut group_id = 0;
        let mut group = Vec::new();
        for i in 0..h {
            group.push(group_id);
            if div >> i & 1 == 1 {
                group_id += 1;
            }
        }
        group_id += 1;

        let mut c = vec![vec![0; w]; h];
        for (i, line) in cho.iter().enumerate() {
            for (j, v) in line.iter().enumerate() {
                c[group[i]][j] += v.to_digit(10).unwrap();
            }
        }

        let mut current_ans = Some(group_id - 1);
        let mut counter = vec![0; group_id];

        let add = |j: usize, counter: &mut Vec<_>| {
            for i in 0..group_id {
                counter[i] += c[i][j];
            }
            for i in 0..group_id {
                if counter[i] as usize > k {
                    return false
                }
            }
            true            
        };

        for j in 0..w {
            if !add(j as usize, &mut counter) {
                current_ans = current_ans.and_then(|v| Some(v + 1));
                counter = vec![0; group_id];
                if !add(j, &mut counter) {
                    current_ans = None;
                    break;
                }
            }
        }

        ans = match current_ans {
            Some(v) => std::cmp::min(ans, v),
            None => ans,
        };
    }

    println!("{:?}", ans);

}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T, T) {
    let temp = read_vec();
    (temp[0], temp[1], temp[2])
}



Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(M)]
    ans = [0 for _ in range(N)]
    if N > 1:
        ans[0] = 1
    for i, s in enumerate(S):
        if s[0] == 1 and s[1] == 0:
            if N > 1:
                print(-1)
                return
        for i2, s2 in enumerate(S):
            if i == i2:
                continue
            if s[0] == s2[0]:
                if s[1] != s2[1]:
                    print(-1)
                    return
        ans[s[0] - 1] = s[1]
    ans = int(''.join([str(n) for n in ans]))
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
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; }

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9+7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;


void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

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

void solve(){
    int N, K;
    cin >> N >> K;
    vector<ll> bill(N);
    rep(i, N) cin >> bill[i];
    ll ans = lnf;
    // とりあえず高くする建物を決める
    int up_cnt;
    set<int> up_bill;
    ll ans_tmp;
    for (int bit = 0; bit < (1 << (N-1)); bit++){
        ans_tmp = 0;
        up_cnt = 1; // bill[0]は必ず見える
        up_bill ={};
        for (int i = 0; i < N-1; i++){
            if ((bit >> i) & 1){
                up_cnt++;
                up_bill.insert(i+1);
            }
        }

        if (up_cnt != K) continue;      // 見る個数が K 以外は除外

        ll now_high = bill[0];
        for (int i = 1; i < N; i++){
            if (up_bill.count(i)){  // bill[i] を見る時
                if (now_high >= bill[i]){
                    // bill[i] の高さを上げる
                    ans_tmp += (now_high - bill[i] + 1);
                    now_high += 1;
                }else{
                    // あげなくて良いが，現在の高さを更新する．
                    now_high = max(bill[i], now_high);
                }
            }else{                  // 見るビルでない時
                now_high = max(now_high, bill[i]);
            }
        }
        ans = min(ans, ans_tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
num = gets.to_i
b = gets.split(" ").map(&:to_i)
result = Array.new(num)
count = 0

(num - 1).times do |i|
  if i == 0
    result[i] = b[i]
    result[i + 1] = b[i]
  else
    result[i + 1] = b[i]
    result[i] = b[i] if result[i] > b[i]
  end
end

result.each{|x| count += x}
puts count

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int a,b;
	cin >> a>>b;
	
	if (a>b) {int c=a;a=b;b=c;};

	string s=string(b, '0'+a);
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>


int main(void)
{
	int a, b;

	while(scanf("%d%d", &a, &b)==2)
	{
		int k=(a+b)/2;

		if(k*2!=a+b) printf("IMPOSSIBLE\n");
		else printf("%d\n", k);
	}

	return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    arc066a()
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long, m: Long): Long {
    var x = n
    var y = p
    var result = 1L

    x %= m
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }

    return result
}

fun arc066a() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toInt() }.sorted()

    if (n % 2 == 0) {
        if (!aList.withIndex().all { (it.index / 2 * 2) + 1 == it.value }) return println(0)
    } else {
        if (!(aList.first() == 0 &&
                    aList.drop(1).withIndex().all { (it.index / 2 * 2) + 2 == it.value })
        ) return println(0)
    }

    val answer = modPow(2, n / 2L, MOD)

    println(answer)
}


Measured memory_bytes: 52528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>
//#include <stack>
//#include <tuple>

using namespace std;


const double Inf = numeric_limits<double>::infinity();



int main(int argc, char** argv){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int redcount = 0;
    int bluecount = 0;
    for (int i=0; i<N; i++){
        if (s[i] == 'R') redcount++;
        if (s[i] == 'B') bluecount++;
    }
    if (redcount > bluecount) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
N,M,NR = map(int,input().split())

R = list(map(lambda x: int(x) - 1 ,input().split()))

import scipy.sparse as ss
import numpy as np

G = ss.dok_matrix((N,N), dtype=np.uint32)

def it():
  for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    yield ((a,b),c)
    yield ((b,a),c)

G.update(it())

D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)

def it2():
  from itertools import permutations
  for p in permutations(R):
    pp = iter(p)
    next(pp)
    yield sum(D[a,b] for a,b in zip(p,pp))

print(int(min(it2())))

Measured memory_bytes: 24512
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x1 - x2;
  int dy = y1 - y2;
  cout << x2 + dy << " " << y2 - dx << " " << x1 + dy << " " << y1 - dx << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    long long int hen[n];
    for(int i = 0; i < n; i++)
        cin >> hen[i];
    sort(hen, hen+n);
    long long int qq[n];
    long long int seihou[n];
    int count = 0;
    int COUNT = 0;
    int check = 1;
    for(int i = 1; i < n; i++){
        if(hen[i]!=hen[i-1])
            check=0;
        check++;
        if(check>=2&&qq[count-1]!=hen[i]){
            qq[count]=hen[i]; count++;
        }
        if(check>=4&&qq[COUNT-1]!=hen[i]){
            seihou[COUNT]=hen[i]; COUNT++;
        }
    }
    sort(qq, qq+count);
    sort(qq, qq+COUNT);
    long long int ans = 0;
    if(count>=2 && COUNT>=1)
        ans = max(qq[count-1]*qq[count-2], seihou[COUNT-1]*seihou[COUNT-1]);
    else if(count < 2 && COUNT==0)
        ans = 0;
    else if(count >=2 && COUNT==0)
        ans = qq[count-1]*qq[count-2];
    else if(count < 2 && COUNT > 0)
        ans = seihou[COUNT-1]*seihou[COUNT-1];
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, c;
    cin >> n >> c;
    vector<int> a(n), b(n);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> b[i];
    vector<vector<ll>> x(n, vector<ll>(c+1, 0));
    ll mod = 1000000007;
    rep(i, n){
        for(ll xi = a[i]; xi <= b[i]; xi++){
            ll xj = 1;
            rep(j, c+1){
                (x[i][j] += xj) %= mod;
                (xj *= xi) %= mod;
            }
        }
    }
    
    vector<vector<ll>> dp(n+1, vector<ll>(c+1, 0));
    dp[0][0] = 1;
    rep(i, n){
        rep(j, c+1){
            ll sum = 0;
            rep(k, j+1){
                (sum += dp[i][k] * x[i][j-k] % mod) %= mod;
            }
            dp[i+1][j] = sum;
        }
    }
    cout << dp[n][c] << endl;
}

Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	long long k;
	cin >> k;
	long long tmp = 7%k;
	set<int> s;
	s.insert(7);
	if (tmp == 0) {
		cout << 1 << endl;
		return 0;
	}
	s.insert(tmp);
	for (long long i = 2; ; i++) {
		tmp = ((tmp*10)%k + 7%k)%k;
		if (tmp == 0) {
			cout << i << endl;
			return 0;
		}

		if (s.find(tmp) != s.end()) {
			cout << -1 << endl;
			return 0;
		}
		s.insert(tmp);
	}
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

void cocomp(VLL & v){
  VLL tmp(v);
  sort(all(tmp));
  map<ll,int> mp;
  rep(i,tmp.size()) mp[tmp[i]] = i;
  rep(i,v.size()) v[i] = mp[v[i]];
}

struct segTree{
  int n;
  VLL nodes;
  void init(int _n){
    n = 1;
    while(n < _n) n*=2;
    nodes.resize(2*n-1,0);
  }

  void update(int i, ll x){
    i += n-1;
    nodes[i] = x;
    while(i > 0){
      i = (i-1)/2;
      nodes[i] = max(nodes[i*2+1], nodes[i*2+2]);
    }
  }

  ll getmax(int x, int y, int k = 0, int l = 0, int r = -1){
    if(r < 0) r = n;
    if(r <= x || y <= l) return 0;
    if(x <= l && r <= y) return nodes[k];
    ll vl = getmax(x,y,k*2+1,l,(r+l)/2);
    ll vr = getmax(x,y,k*2+2,(r+l)/2,r);
    return max(vl,vr);
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL a(n),h(n);
  rep(i,n) cin >> h[i];
  rep(i,n) cin >> a[i];
  segTree t;
  t.init(n);
  // i番目まで見たときに高さがjであるときの最大の美しさ
  cocomp(h);

  rep(i,n){
    ll tmp = t.getmax(0,h[i]);
    //cout << tmp << endl;
    t.update(h[i],tmp+a[i]);
  }
  cout << t.getmax(0,n) << endl;
  return 0;
}


Measured memory_bytes: 21504
#include <iostream>

int main() {
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  if (
      x + r <= w &&
      x - r >= 0 &&
      y + r <= h &&
      y - r >= 0
      ) {
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0,tmp;
  cin >> n;
  for(int i=1;i<=n;i++){
    sum+=i;
    if(sum>=n){
      tmp=sum-n;
      break;
    }
  }
  int a=0;
  for(int i=1;i<=n;i++){
    if(a==n)break;
    if(i!=tmp){
      cout << i << endl;
      a+=i;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc136_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var h = CIn.ReadIntArray(n);

      for (var i = n - 1; i > 0; i--)
      {
        if (h[i] + 1 == h[i - 1])
        {
          h[i - 1]--;
        }
        else if (h[i] + 1 < h[i - 1])
        {
          Console.WriteLine("No");
          return;
        }
      }

      Console.WriteLine("Yes");
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 32988
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{

	int n;
	cin >> n;
	map<int, int> d;
	REP(i, n){
		int a;
		cin >> a;
		d[a]++;
	}
	
	int m;
	cin >> m;
	REP(i, m){
		int a;
		cin >> a;
		if (d[a]){
			d[a]--;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
map<int,int>m;
int main(){
	cin>>N;
	REP(i,N-1){
		int a;
		cin>>a;
		m[a]++;
	}
	REP(i,N){
		cout<<m[i+1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13008