akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long big = a[0];
	for(int i = 0; i < n; i++) big = max(big, a[i]);
	vector<int> ops;
	if(big <= 0){
		cout << big << endl;
		for(int i = 0; i < n; i++) if(big == a[i]){
			for(int j = n - 1; j > i; j--) ops.push_back(j + 1);
			for(int j = 0; j < i; j++) ops.push_back(1);
			break;
		}
	} else {
		long long q[2] = {};
		for(int i = 0; i < n; i++) q[i&1] += max(a[i], 0ll);
		int id = q[1] > q[0];
		cout << q[id] << endl;
		vector<bool> wanted;
		for(int i = 0; i < n; i++) wanted.push_back((i&1) == id && a[i] > 0);
		while(wanted.size() > 1){
			if(!wanted[0]){
				ops.push_back(1);
				reverse(wanted.begin(), wanted.end());
				wanted.pop_back();
				reverse(wanted.begin(), wanted.end());
			} else if(!wanted.back()){
				ops.push_back(wanted.size());
				wanted.pop_back();
			} else {
				int len = wanted.size() - 1;
				int si = -1;
				for(int i = 1; i < len; i++){
					if(!wanted[i - 1] && !wanted[i + 1] && !wanted[i]){
						si = i;
						break;
					} else if(wanted[i - 1] && wanted[i + 1]) {
						si = i;
						break;
					}
				}
				assert(~si);
				vector<bool> nxt;
				ops.push_back(si + 1);
				for(int i = 0; i < len + 1; i++) 
					if(i == si) nxt.push_back(wanted[i - 1]);
					else if(abs(i - si) != 1) nxt.push_back(wanted[i]);
				wanted = nxt;
			}
		}
	}
	cout << ops.size() << endl;
	for(int v : ops) cout << v << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
a = []
for l in sys.stdin:
    a.append(list(map(int,l.split())))
    
for i in a:
  if i[0]==0 and i[1]==0:
    break

  for x in range(i[0]):
      o=''
      for y in range(i[1]):
        if (y+x)%2==0:
          o+='#'
        else:
          o+='.'
      print(o)
        
        
  print('\r')


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n,k;
   cin>>n>>k;
   long long int ans=k*power(k-1,n-1);
   cout<<ans;
   
    return 0;
}








Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long LL;
typedef double db;
inline LL read() {
    LL x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main() {
    int a, b, c;
    a = read(); b = read(); c = read();
    if (b >= a * c) printf("%d\n", c);
    else printf("%d\n", (int)(b / a));
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while(true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using pii   = std::pair<int, int>;
using vi    = std::vector<int>;
using vd    = std::vector<double>;
using vc    = std::vector<char>;
using vb    = std::vector<bool>;
using vs    = std::vector<std::string>;
using vpii  = std::vector<pii>;
using vvi   = std::vector<vi>;
using vvb   = std::vector<vb>;
using vvpii = std::vector<vpii>;
template<typename A> using fn = std::function<A>;
constexpr int INF   = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD   = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0)
    : src(s), dst(d), weight(w) {
  }
};

using Edges  = std::vector<Edge>;
using Array  = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  // clang-format off
  Graph(const int &size = 0) : g(size) { }

  void addArc(const int &src, const int &dst, const Weight &w = 1) {
    g[src].emplace_back(src, dst, w);
  }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  Graph toRootedTree(int r);
  std::vector<Weight> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
  // clang-format on
};

Weight Graph::solveTSP(const int &inf = std::numeric_limits<Weight>::max() / 8) {
  int n = g.size();
  Matrix dp(1 << n, Array(n, inf));
  dp[0][0] = 0;
  rep(s, 1 << n) {
    for (auto &es : g) {
      for (auto &e : es) {
        if (~s >> e.dst & 1) cmin(dp[s | 1 << e.dst][e.dst], dp[s][e.src] + e.weight);
      }
    }
  }
  return dp.back().front();
}

main {
  int v, e;
  cin >> v >> e;
  Graph g(v);
  while (e--) {
    int s, t, d;
    cin >> s >> t >> d;
    g.addArc(s, t, d);
  }
  Weight x = g.solveTSP(INF);
  cout << (x == INF ? -1 : x) << endl;
}

Measured memory_bytes: 7532
//abc155_e.cpp
//Fri May 29 21:22:38 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int keta[s.length()+1];
	keta[0] = 0;
	for (int i=0;i<s.length();i++){
		keta[i+1] = int(s[i]-'0');
	}

	ll pay[11];
	pay[0] = 0;
	pay[1] = 1;
	pay[2] = 2;
	pay[3] = 3;
	pay[4] = 4;
	pay[5] = 5;
	pay[6] = 4;
	pay[7] = 3;
	pay[8] = 2;
	pay[9] = 1;
	pay[10] = 0;

	ll ans = 0;
	ll ketaagari = 0;
	for (int i=s.length();i>0;i--){
		if (keta[i]>=6){
			ans += pay[keta[i]];
			keta[i-1]++;
		}else if (keta[i]==5){
			if (keta[i-1]<=4){
				ans += pay[keta[i]];
			}else {
				ans += pay[keta[i]];
				keta[i-1]++;
			}
		}else{
			ans += pay[keta[i]];
		}
	}
	if (keta[0]==1){
		ans++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n;
	cin>>n;
	vector<ll> vl(n);
	FOR(i,0,n)cin>>vl[i];
	ll ans = 0;
	FOR(i,0,n-1)
	{
		if(vl[i]>vl[i+1])
		{
			ans+=vl[i]-vl[i+1];
			vl[i+1] = vl[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4840
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,t=MI()
lis=LI()
ans=0
for i in range(n-1):
    ans+=min(t,lis[i+1]-lis[i])
print(ans+t)

Measured memory_bytes: 26900
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let n = read::<i64>();
    let v = read_vec::<i64>();
    let ans = v.into_iter().sum::<i64>() - n;
    println!("{}",ans);
}


Measured memory_bytes: 4352
n = int(input())

arr = []
max_num = 0
label = 1
for i in range(n):
    inp = int(input())
    if inp >= max_num:
       max_num = inp
       label = i
    arr.append(inp)



arr_sub = arr[:]
arr_sub.pop(label)
second_max = max(arr_sub)


for i in range(n):
    if i != label:
        print(max_num)
    else:
        print(second_max)




Measured memory_bytes: 14068
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A == B) {
        cout << A + B << endl;
    } else {
        int m = max(A, B);
        cout << m + m-1 << endl;
    }

    return 0;
}


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

int main(){

    while(1){

        string s; cin >> s;
        int n = (int)s.size();
        if(s == "0") break;

        vector<vector<int> > dp(n + 1, vector<int> (11, 0));

        for(int i = 0; i < n; i++){

            int num = (int)(s[i] - '0');

            //つける
            for(int j = 0; j < 11; j++){
                dp[i + 1][(j * 10 + num) % 11] += dp[i][j];    
            }

            //新たに
            if(num != 0) dp[i + 1][num] += 1;
        }


        int ans = 0;
        for(int i = 1; i <= n; i++) ans += dp[i][0];

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

}


Measured memory_bytes: 9960
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,_;
    cin>>n>>_;
    vector<list<int>> s(n);
    int t,x,u;
    while(_--){
        int Q;
        cin>>Q;
        switch(Q){
        case 0:
            cin>>t>>x;
            s[t].push_back(x);
            break;
        case 1:
            cin>>t;
            irep(i,s[t]){
                if(i==s[t].begin())cout<<*i;
                else cout<<" "<<*i;
            }
            cout<<endl;
            break;
        case 2:
            cin>>u>>t;
            s[t].splice(s[t].end(), move(s[u]));
            break;
        }
    }
}




Measured memory_bytes: 18696
#include <stdio.h>

int main()
{
    int a,b,c,d;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    d = a + b +c;
    if (d >= 22){
        printf("bust\n");
    }
    else {
        printf("win\n");
    }


    return 0;
}


Measured memory_bytes: 128
# 初期入力
N = int(input())
A = list(map(int, input().split()))

#
Numerator=1
for i in range(N):
    Numerator *=A[i]

Denominator =0
for i in range(N):
    Denominator +=Numerator/A[i]

ans =Numerator/Denominator
print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<string> v(n);
	rep(i, n) cin >> v[i];

	sort(all(v));
	string ans = "";
	rep(i, n) ans += v[i];

	cout << ans << endl;

	return (0);
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200010
const ll mod=1e9+7;
int a[2*N],last[N],nxt[2*N];
ll stu[N];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i+n]=a[i];
    }
    for(int i=2*n;i>=1;i--)
    {
        nxt[i]=last[a[i]];
        last[a[i]]=i;
    }

    memset(stu,-1,sizeof stu);
    int x=1;
    while(1)
    {
        if(k<=2)
        {
            vector<int>s;
            int vis[N]={0};
            for(int i=x;i<=k*n;i++)
            {
                int y = i>n?i-n:i;
                if(vis[a[y]])
                {
                    while(vis[a[y]])
                    {
                        vis[s.back()]=0;
                        s.pop_back();
                    }
                }
                else
                {
                    vis[a[y]]=1;
                    s.push_back(a[y]);
                }
            }
            for(int i: s)
                printf("%d ",i);
            break;
        }

        x=nxt[x]+1;
        while(x>n)
        {
            x-=n;
            k--;
        }
        if(stu[x]!=-1)
        {
            ll d=stu[x]-k;
            k%=d;
        }
        stu[x]=k;
    }
    return 0;
}


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

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b){
		cout<<"delicious"<<endl;
	}else if(b-a<x+1){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

def factorial(n) :
    if n == 1:
        return 1
    else :
        return n*factorial(n-1)

num_p = 0
num_q = 0
for i in range(n-1) :
    sort_p = sorted(p[i:],reverse=True)
    index_p = sort_p.index(p[i])
    mp = n - (index_p + 1)
    num_p += mp * factorial(n-(i+1))

    sort_q = sorted(q[i:],reverse = True)
    index_q = sort_q.index(q[i])
    mq = n - (index_q + 1)
    num_q += mq * factorial(n-(i+1))

print(abs(num_p - num_q))


Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

#define MAX 200000
#define INFTY 1<<30

using namespace std;

static const int N = 1000;

int main()
{
  int n, p[N+1], m[N+1][N+1]; cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> p[i-1] >> p[i];
  for(int i = 1; i <= n; i++) m[i][i] = 0;
  for(int l = 2; l <= n; l++)//???????????° l:
  {
    for(int i = 1; i <= n-l+1; i++)//????§???????
    {
      int j = i + l -1;//????????????
      m[i][j] = (1<<21);
      for(int k = i; k <= j-1; k++)
      {
        m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;
  return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+10;
const ll inf =9;
 

int main(){
	fastio;
	ll tc,n;
	cin>>n;
	if(n%10==3) cout<<"bon\n";
	else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout<<"pon\n";
	else cout<<"hon\n";
	
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char b;
    scanf("%c",&b);
    switch(b){

case 'A':
    printf("T");
    break;
case 'G':
    printf("C");
    break;
case 'C':
    printf("G");
    break;
case 'T':
    printf("A");
    break;


    }
    return 0;
}


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

#include <utility>
using namespace std;

#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e9;
using Pii = pair<int, int>;

const int con_type = 26;
int D = 365;
int C[con_type];
int S[365][con_type];
vector<int> ans;
int last[con_type];

struct State {
  int cost;
  vector<int> ans;
  vector<int> last;

  State() {
    cost = 0;
    last = vector<int>(26, -1);
  }

  State(int cost, vector<int> ans, vector<int> last):
    cost(cost), ans(ans), last(last) {};

  bool operator<( const State& s ) const {
    return cost < s.cost;
  }

  bool operator>( const State& s ) const {
    return cost > s.cost;
  }
};

void solve() {
  priority_queue<State> Q;
  Q.push(State());
  REP(d, D) {
    priority_queue<State> nQ;
    while ( !Q.empty() ) {
      State now = Q.top(); Q.pop();
      vector<Pii> add_cost;
      int sum = 0;
      int type_cost[26];
      REP(i, con_type) {
        sum += (d-now.last[i])*C[i];
        type_cost[i] = (d-now.last[i])*C[i];
      }
      REP(i, con_type) {
        add_cost.emplace_back(Pii(S[d][i]+(d-now.last[i])*C[i]-sum, i));
      }
      sort(add_cost.begin(), add_cost.end(), greater<Pii>());
      REP(i, 8) {
        int id = add_cost[i].second;
        State next = now;
        next.cost += S[d][id];
        REP(j, con_type) {
          if ( j == id ) continue;
          next.cost -= (d-next.last[j])*C[j];
        }
        next.ans.emplace_back(id);
        next.last[id] = d;
        nQ.push(next);
      }
    }
    Q = priority_queue<State>();
    REP(i, min(1000, (int)nQ.size())) {
      Q.push(nQ.top()); nQ.pop();
    }
  }

  ans = Q.top().ans;
}

void input() {
  cin >> D;
  REP(i, con_type) {
    cin >> C[i];
    last[i] = -1;
  }
  REP(i, D) REP(j, con_type) cin >> S[i][j];
}

void output() {
  REP(i, D) cout << ans[i]+1 << endl;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  input();
  solve();
  output();

  return 0;
}


Measured memory_bytes: 17192
#define _CRT_SECURE_NO_WARNINGS
#define NOMINMAX
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = (int) 1e9;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.00001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int base = 0, cnt = 0;
	int prev = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < prev) {
			cnt += prev - base;
			base = a[i];
		}
		prev = a[i];
	}
	cnt += a[n - 1] - base;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 305;
const int MOD = 1e9 + 7;
int dp[N][N][N];
int n, m;
int main() {
    scanf("%d%d", &n, &m);
    dp[0][1][0] = 1;
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= min(n, m); j++) {
            for (int k = 0; j + k <= min(n, m); k++) {
                if (!dp[i][j][k]) continue;
                dp[i + 1][j + k][0] =
                    (dp[i + 1][j + k][0] + 1LL * dp[i][j][k] * j) % MOD;
                dp[i + 1][j][k + 1] =
                    (dp[i + 1][j][k + 1] + 1LL * dp[i][j][k] * (n - j - k)) %
                    MOD;
                dp[i + 1][j][k] =
                    (dp[i + 1][j][k] + 1LL * dp[i][j][k] * k) % MOD;
                //printf("(%d,%d,%d):[%d]\n", i, j, k, dp[i][j][k]);
            }
        }
    }
    printf("%d\n", dp[m][n][0]);
    return 0;
}

Measured memory_bytes: 108800
// Copyright 2015 KanatoNagayama
#include <iostream>
#include <algorithm>
using std :: cout;
using std :: cin;
using std :: endl;
using std :: swap;
int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if(a > b)
    swap(a, b);

  if(b > c) {
    swap(b, c);
    if(a > b)
      swap(a, b);
  }

  cout << a << " " <<  b << " " <<  c << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp> //__gnu_pbds::priority_queue
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 400000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

namespace BIT {
#define lowbit(x) (x & -x)
    int c[N + 5];
    void add(int x, int y) {
        while(x <= N) {
            c[x] += y;
            x += lowbit(x);
        }
    }
    int query(int x) {
        int res = 0;
        while(x > 0) {
            res += c[x];
            x -= lowbit(x);
        }
        return res; 
    }
}

int n;
char st[N + 5];
std::deque<int> p[30];
std::set<pair<int, char> > s;

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    ll ans = 0;
    scanf("%s", st); n = strlen(st);
    for(int i = 0; i < n; ++i) { 
        p[st[i] - 'a'].pb(i); 
        s.insert(mp(i, st[i]));
        BIT::add(i+1, 1);
    }

    bool flag = 0;
    for(int i = 0; i < 26; ++i) if(p[i].size()&1){
        if(flag){puts("-1");return 0;}
        else flag=1;
    }

    flag = 0;
    for(int i = 0; i < (n+1)/2; ++i) {
        char cur = (*s.rbegin()).snd;

        if(p[cur-'a'].size() <= 1) {
            if(!flag) flag = 1;
            else return puts("-1"), 0;
        } else {
            ans += BIT::query(p[cur-'a'].front()+1) - 1;
            s.erase(s.find(mp(p[cur-'a'].front(), cur)));

            BIT::add(p[cur-'a'].front()+1, -1);
            p[cur - 'a'].pop_back();
            p[cur - 'a'].pop_front();

            if(flag) ++ ans;
        }
        s.erase(*s.rbegin());
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 11520
// ref: https://img.atcoder.jp/arc086/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int max(const vector<int>& v){
    int m = v[0];
    for(uint i=0; i<v.size(); ++i){ m = (v[i]>m ? v[i] : m); }
    return m;
}
int min(const vector<int>& v){
    int m = v[0];
    for(uint i=0; i<v.size(); ++i){ m = (v[i]<m ? v[i] : m); }
    return m;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vA(N); for(int i=0; i<N; ++i){ cin >> vA[i]; }
    
    int minIdx = min_element(vA.begin(), vA.end()) - vA.begin();
    int maxIdx = max_element(vA.begin(), vA.end()) - vA.begin();
    
    cout << 2*N-1 << endl;
    if(abs(vA[maxIdx]) >= abs(vA[minIdx])){
        for(int i=0; i<N; ++i){
            if(i==maxIdx){ continue; }
            cout << maxIdx+1 << ' ' << i+1 << endl;
        }
        cout << maxIdx+1 << ' ' << maxIdx+1 << endl;
        
        for(int i=1; i<N; ++i){
            cout << (i-1)+1 << ' ' << (i)+1 << endl;
        }
    }else{
        for(int i=0; i<N; ++i){
            if(i==minIdx){ continue; }
            cout << minIdx+1 << ' ' << i+1 << endl;
        }
        cout << minIdx+1 << ' ' << minIdx+1 << endl;
        
        for(int i=N-1; i>=1; --i){
            cout << (i)+1 << ' ' << (i-1)+1 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] E = new int[M];
        for (int i = 0; i < M; i++) {
            E[i] = sc.nextInt();
        }
        boolean[] used = new boolean[N+1];
        for (int i = M-1; i >= 0; i--) {
            if (!used[E[i]]) {
                System.out.println(E[i]);
                used[E[i]] = true;
            }
        }
        for (int i = 1; i <= N; i++) {
            if (!used[i]) System.out.println(i);
        }
    }

}

Measured memory_bytes: 77044
N=int(input())
A=list(map(int,input().split()))
A.sort()
sum_arr=[0]*(N+1)
for i in range(N):
  sum_arr[i+1]=sum_arr[i]+A[i]
count=0
for i in range(1,N):
  if sum_arr[i]*2 >= A[i]:
    count+=1
  else:
    count=0
print(count+1)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	int cost{-1};
	pair<int,int> from;
};

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

	int X=in(),A=in(),B=in();
	
	out((X-A)%B);
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> B;
    B = A;
    sort(B.begin(), B.end());
    int maximum = B[B.size() - 1];
    int submaximum = B[B.size() - 2];
    for (int i = 0; i < N; i++)
    {
        if (A[i] == maximum)
            cout << submaximum << endl;
        else
            cout << maximum << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#define N 100

int main(){
  int n,i,j,m,v,vv;
  int A[N][N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = 0;
    }
  }

   
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&m);
    for(j=0;j<m;j++){
      scanf("%d",&vv);
      A[v-1][vv-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }
  return 0;
}

Measured memory_bytes: 632
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>

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

    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a.at(i);
    }

    std::set<std::string> S;
    int free = 0;

    for(int i = 0; i < n; i++){
        if(1 <= a.at(i) && a.at(i) <= 399){
            S.insert("gray");
        }
        else if(400 <= a.at(i) && a.at(i) <= 799){
            S.insert("brown");
        }
        else if(800 <= a.at(i) && a.at(i) <= 1199){
            S.insert("green");
        }
        else if(1200 <= a.at(i) && a.at(i) <= 1599){
            S.insert("light_blue");
        }
        else if(1600 <= a.at(i) && a.at(i) <= 1999){
            S.insert("blue");
        }
        else if(2000 <= a.at(i) && a.at(i) <= 2399){
            S.insert("yellow");
        }
        else if(2400 <= a.at(i) && a.at(i) <= 2799){
            S.insert("orange");
        }
        else if(2800 <= a.at(i) && a.at(i) <= 3199){
            S.insert("red");
        }
        else if(3200 <= a.at(i)){
            free++;
        }
    }

    int minN = S.size();
    int maxN;
    if(minN == 0) {
        minN = 1;
        maxN = free;
        std::cout << minN << " " << maxN << std::endl;
        return 0;
    }
    maxN = minN + free;
    std::cout << minN << " " << maxN << std::endl;
    return 0;
}

Measured memory_bytes: 256
N,M,K=input().split()
N=int(N)
M=int(M)
K=int(K)
tmp=input().split()
A=[]
Atime=[]
for i in range(len(tmp)):
  A.append(int(tmp[i]))
  if i==0: Atime.append(A[0])
  else: Atime.append(Atime[i-1]+A[i])
tmp=input().split()
B=[]
Btime=[]
for i in range(len(tmp)):
  B.append(int(tmp[i]))
  if i==0: Btime.append(B[0])
  else: Btime.append(Btime[i-1]+B[i])

Blim=len(Btime)
for i in range(len(Btime)):
  if Btime[i]>K:
    Blim=i
    break
result=Blim
#print(Atime)
for i in range(len(Atime)):
  while Blim>0:
    if Atime[i]+Btime[Blim-1]<=K:
      if Blim+i+1>result: result=Blim+i+1
      break
    Blim-=1
  if Blim==0:
    if Atime[i]<=K:
      if i+1>result: result=i+1
print(result)

Measured memory_bytes: 64248
n = input()
ls = list(map(int, input().split()))

cnt = ''
for idx in range(0,len(ls)):
    buf = 0
    while ls[idx] % 2 ==0:
        ls[idx] /= 2
        buf += 1
    if cnt == '' or  buf < cnt:
        cnt = buf
print(cnt)


Measured memory_bytes: 2940
#include<iostream>
#include <string>
#include <stdlib.h>
#include <stdexcept>
#include <math.h>
using namespace std;

int main(){

  	//Mr.infinityの持つ数列
  	std::string S;
  	
  	//5000兆日後に参照すべき文字列の位置
  	long long K;
  	  
  	cin >> S;
  	cin >> K;
  	
  	for(long long i = 0; i< min((long long) S.size() ,K); i++){
    
    	if(S[i] != '1'){
        
        	cout << S[i] << endl;
          	return 0;
        
        }
    	
    
    }
	
   	cout << 1 << endl;
    return 0;
  
}

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

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    {
        vector<int> cntA(n+1), cntB(n+1);
        rep(i,n) cntA[a[i]]++;
        rep(i,n) cntB[b[i]]++;
        rep1(i,n) if(cntA[i]+cntB[i] > n) {
            cout << "No" << endl;
            return 0;
        }
    }
    {
        cout << "Yes" << endl;
        vector<int> ar(n+1, -1), bl(n+1, n+1);
        rep(i,n) {
            chmax(ar[a[i]],i);
            chmin(bl[b[i]],i);
        }
        int k = 0;
        rep1(i,n) {
            chmax(k, ar[i] - bl[i] + 1);
        }
        rep(i,n) {
            cout << b[(i+n-k)%n] << (i<n-1 ? " " : "\n");
        }
    }

    return 0;
}


Measured memory_bytes: 6420
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int arr[300002];
int mo[300001];
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)scanf("%d",&arr[i+1]);
    arr[0]=0;
    sort(arr,arr+n+1);
    arr[n+1]=300001;
    for(int i=0;i<n+1;i++){
        for(int j=arr[i];j<arr[i+1];j++)mo[j]=arr[i];
    }
    while(q--){
        int t;scanf("%d",&t);
        int ma=0;
        for(int i=t;i<=300000;i+=t)ma=max(ma,mo[i-1]%t);
        printf("%d\n",ma);
    }
    return 0;
}

Measured memory_bytes: 3384
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
using namespace std;

int main(){

    long double a,b,h,m;
    cin >> a >> b >> h >> m;

    //角度計算
    long double sh = (long double)360.0 * (long double)h / (long double)12.0;
    sh += (long double)360.0 * (long double) m / (long double)60.0 / (long double)12.0;
    long double ln = (long double)360.0 * (long double)m / (long double)60.0;

    long double deg = fabs(sh-ln);

    long double pi     = (long double)2.0 * asin((long double)1.0);            /* πの値 */
	long double unit   = pi / (long double)180.0;                 /* 度 → ラジアン */
	
	long double deg_r  = deg * unit;

    long double result = std::sqrt((long double)(pow(a,(long double)2.0) + pow(b,(long double)2.0)-(long double)2.0*a*b*cos(deg_r)));

    std::cout << std::fixed;
    std::cout << std::setprecision(20) << result << endl;

    //::system("pause");

    return 0;
}

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

int main(void){
    int n,m;
    int i,j;
    int a[100][100];
    int b[100];
    cin>>n>>m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(i=0;i<m;i++){
        cin>>b[i];
    }
    
    int c;
    for(i=0;i<n;i++){
        c=0;
        for(j=0;j<m;j++){
            c+=(a[i][j]*b[j]);
        }
        cout<<c<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N;
    cin >> N;
    set<pair<pair<string, int>, int>> rest;
    for(int i = 0; i < N; i++){
        string S;
        int P;
        cin >> S >> P;
        rest.insert({{S, -P}, i});
    }
    for(auto i: rest){
        cout << i.second + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>d+c)
        cout<<"Left"<<endl;
    else if(a+b==c+d)
        cout<<"Balanced"<<endl;
    else
        cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000


long long kai[N];
long long rkai[N];
long long xx[30];
int yy[30];

void kaiz(void) {
	kai[0] = 1;
	f(i, N - 1) {
		kai[i + 1] = kai[i] * (i + 1);
		kai[i + 1] = kai[i + 1] % MOD;
	}
	int x = MOD - 2;
	f(i, 30) {
		if (x % 2 == 1)yy[i] = 1;
		else yy[i] = 0;
		x = x / 2;
	}
	f(i, N) {
		xx[0] = kai[i];
		f(j, 29) {
			xx[j + 1] = xx[j] * xx[j];
			xx[j + 1] = xx[j + 1] % MOD;
		}
		rkai[i] = 1;
		f(j, 30) {
			if (yy[j] == 1) {
				rkai[i] = rkai[i] * xx[j];
				rkai[i] = rkai[i] % MOD;
			}
		}
	}
}

long long ni(long long x, long long y) {
	if (x < 0 || y<0 || y>x)return 0;
	long long re = kai[x];
	re = re * rkai[x - y];
	re = re % MOD;
	re = re * rkai[y];
	re = re % MOD;
	return re;
}

int main() {
  kaiz();
	long long x, y, z;
	long long ww, xx, yy, zz;
	long long k, s, ans;
	scanf("%lld %lld %lld %lld",&k, &x, &y, &z);
	if (y % 2 == 1) {
		printf("0\n");
		return 0;
	}
	y /= 2;
	ans = 0;
	for (long long i = 0; (i <= x) && (i <= z); i++) {
		for (long long j = 0; (3 * j) <= (z - i); j++) {
			xx = x - i;
			yy = y;
			ww = j;
			zz = i;
			s = ni(ww + xx + yy + zz, ww);
			k = ni(xx + yy + zz, xx);
			s = (s*k) % MOD;
			k = ni(yy + zz, yy);
			s = (s*k) % MOD;
			if((z - i -(3*j))>0){
              k = ni(z - i -(3*j)+ yy - 1, yy - 1);
			s = (s*k) % MOD;
            }
			ans = (ans + s) % MOD;
		}
	}


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


	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            var aa = a.ToList();
            var bb = b.ToList();
            aa.Sort();
            bb.Sort();
            bb.Reverse();
            var aaa = new String(aa.ToArray());
            var bbb = new String(bb.ToArray());
            var c = string.Compare(aaa, bbb);
            string s;
            if (c < 0)
            {
                 s = "Yes";
            }
            else
                 s = "No";

            Console.Write(s);
        }
    }
}


Measured memory_bytes: 13536
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long int a[10000005]={0};
int main()
{
    long long int n,i,j,t,ans=0,q;

    scanf("%lld",&n);
    for (i = 1; i <= n; ++i)
    {
		for (j = i; j <= n; j+=i) {
			++a[j];
		}
	}
	for (i = 1; i <= n; ++i)ans += i * a[i];
	printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 81892
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	int p[n+1],q[n+1];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	for(int i=0;i<n;i++){
		cin>>q[i];
	}
	int a[n+1];
	for(int i=0;i<n;i++){
		a[i] = i+1;
	}
	int flagp,flagq;
	int posp=0,posq=0;
	int x=1;
	do
	{
		flagp=0,flagq=0;
		for(int i=0;i<n;i++){
			if(p[i]!=a[i]){
				flagp=1;
				break;
			}
		}
		
		for(int i=0;i<n;i++){
			if(q[i]!=a[i]){
				flagq=1;
				break;
			}
		}	
		if(flagp==0){
			posp=x;
		}
		if(flagq==0){
			posq=x;
		}
		x++;
	} while (next_permutation(a,a+n));

	cout<<abs(posq-posp)<<endl;

	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
int a[105];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
  	int x,n,xx;cin>>x>>n;
  	for(int i=0;i<n;i++)
  	{
  		cin>>xx;a[xx]++;	
	}
	
		int i=x,ans,l=0,r=101;
		for(;i>=1;i--)
		{
			if(a[i]==0){
				l=i;break;
			}
		}
		i=x;
		for(;i<=100;i++)
		{
			if(a[i]==0){
				r=i;break;
			}
		}
		
		if(abs(x-r)<abs(x-l)){
			cout<<r;
		}
		else if(abs(x-r)>abs(x-l))
		{
			cout<<l;
		}
		else if(abs(x-r)==abs(x-l)) cout<<l;
	
	
    return 0 ;
}


Measured memory_bytes: 3612
//#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	string s;
	cin >> s;
	if (s <= "2019/04/30")
		cout << "Heisei";
	else
		cout << "TBD";
	return 0;
}



Measured memory_bytes: 256
S = input()
T = input()

n = len(S)

ans = 'No'

for i in range(n):
    if ans == 'Yes':
        break
    if S[i] != T[0]:
        continue
    for j in range(n):
        k = i if i+j < n else i-n
        if S[k+j] != T[j]:
            break
        if j == n-1:
            ans = 'Yes'

print(ans)


Measured memory_bytes: 3060