akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using Edge = pair<ll,ll>;
using Graph =vector<vector<int>>;
ll inf=1e18;

int main() {
  __int128_t ans,c;
  ll a;
  double b;
  cin>>a>>b;
  b=(b*100+0.001);
  c=(ll)b;
  ans=(a*c)/100;
  cout<<(ll)ans<<endl;
}


Measured memory_bytes: 3708
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
1 2 3
---+/
/+---test
10
3 1 4 1 5 9 2 6 5 3
---+/
/+---test
10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820
---+/

enum MOD = 1000000007;

void main(string[] args) {
  const N = readln.chomp.to!long;
  const A = readln.split.map!(to!long).array;

  long ans;
  foreach (i; 0..60) {
    long x;
    foreach (a; A) if ((a >> i) & 1) ++x;

    long cnt = x * (N-x);
    foreach (j; 0..i) cnt = cnt*2%MOD;
    ans = (ans+cnt)%MOD;
  }
  ans.writeln;
}


Measured memory_bytes: 18480
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = STR()
if n[-1] in ['2', '4', '5', '7', '9']:
    print('hon')
elif n[-1] in ['0', '1', '6', '8']:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 68296
#include <stdio.h>
#include <string.h>

int main()
{
  char str1[100] = {};
  char str2[100] = {};
  char seq[200] = {};

  scanf("%s %s", str1, str2);
  strcpy(seq, str1);
  strcat(seq, str1);
  if(strstr(seq, str2) != NULL)
    printf("Yes\n");
  else
    printf("No\n");
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll mod = pow(10,9)+7;

int main(){
    ll N, K; cin >> N >> K;
    vi h(N);
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    ll dp[N+1];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=1; i<N-1; i++){
        ll mini = dp[i]+abs(h[i+1]-h[i]);
        for(int k=1; k<K&&i-k>=0; k++){
            ll d = dp[i-k] + abs(h[i+1]-h[i-k]);
            if(d < mini){mini = d;}
        }
        dp[i+1] = mini;
    }
    cout << dp[N-1];
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                             \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL << 60;

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

  ll slen = s.size();
  ll tlen = t.size();

  ll ans = inf;
  for (int i=0; i<slen-tlen+1; i++) {
    ll tmp = 0;
    for (int j=0; j<tlen; j++) {
      if (s[i+j] != t[j]) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n,m; cin>>n>>m;
  int maxl=0,minr=1000000;
  for(int i=0;i<m;i++){
    int a,b; cin>>a>>b;
    maxl=max(maxl,a);
    minr=min(minr,b);
  }
  if(minr<maxl){
    cout<<0<<endl;
  }else{
    cout<<minr-maxl+1<<endl;
  }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define b push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef vector<P> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  V a(5);
  rep(i,5)cin>>a[i];
  int n;
  cin>>n;
  bool can=true;
  rep(i,5){
      rep(j,5){
          if(i==j)continue;
          if(abs(a[i]-a[j])>n)can=false;
      }
      
  }
  cout<<(can?"Yay!":":(")<<endl;
   
 
  return 0;
}



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

int main() {
  int N,K,ans=0;
  cin >> N >> K;
  vector <int>x(N);
  for (int i=0;i<N;i++){
    cin >> x.at(i);
    if(x.at(i)>=abs(K-x.at(i)))
      ans+=abs(K-x.at(i));
    else
      ans+=x.at(i);
  }
  cout <<ans*2<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,m,h[100005],f[100005],ans;
struct ac{
	int a,b;
}a[100005];
bool cmp(ac a,ac b){
	if(a.a==b.a)return a.b<b.b;
	else return a.a<b.a;
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);in(m);for(int i=1;i<=n;i++)in(h[i]);
	for(int i=1;i<=m;i++){
		in(a[i].a);in(a[i].b);
	}
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=m;i++){
		if(h[a[i].a]<h[a[i].b])f[a[i].a]=1;
		if(h[a[i].b]<h[a[i].a])f[a[i].b]=1;
		if(h[a[i].a]==h[a[i].b])f[a[i].a]=f[a[i].b]=1;
//		for(int j=1;j<=n;j++)printf("%d ",f[j]);
//		printf("\n");
	}
	for(int i=1;i<=n;i++)
	if(f[i]==0)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{
//	int t;
//	cin>>t;
// 	while(t--)
//	{
		int n;
		cin>>n;
		int a[n];
		long long int i,j;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		j=0;
		for(i=0;i<n-1;i++)
		{
			if(a[i]>a[i+1])
			{
				j+=(a[i]-a[i+1]);
				a[i+1]=a[i];
			}
		}
		cout<<j;
//	}
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 5005, mod = 1e9 + 7;

	int n, F[N][N][2], V[N], Siz[N];
	vector<int> E[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	void dfs(const int u, const int f)
	{
		Siz[u] = 1;
		F[u][1][0] = 1;
		for (int v : E[u])
			if (v != f)
			{
				dfs(v, u);
				static int tmp[N][2];
				for (int i = 0; i <= Siz[u]; i++)
					for (int j = 0; j < 2; j++)
					{
						tmp[i][j] = F[u][i][j];
						F[u][i][j] = 0;
					}
				for (int a = 1; a <= Siz[u]; a++)
					for (int x = 0; x < 2; x++)
						for (int b = 0; b <= Siz[v]; b++)
							for (int y = 0; y < 2; y++)
								(F[u][a + b][x ^ y] += int((ll)tmp[a][x] * F[v][b][y] % mod)) %= mod;
				Siz[u] += Siz[v];
			}
		for (int i = 2; i <= Siz[u]; i += 2)
			for (int j = 0; j < 2; j++)
				(F[u][0][j ^ 1] += int((ll)F[u][i][j] * V[i] % mod)) %= mod;
	}

	void work()
	{
		n = read();
		for (int i = 1; i < n; i++)
		{
			int u = read(), v = read();
			E[u].push_back(v);
			E[v].push_back(u);
		}
		V[2] = 1;
		for (int i = 4; i <= n; i += 2)
			V[i] = int((ll)V[i - 2] * (i - 1) % mod);
		dfs(1, 0);
		printf("%d\n", (F[1][0][1] - F[1][0][0] + mod) % mod);
	}
}

int main()
{
	TYC::work();
	return 0;
}

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

using namespace std;

int n, l;

int main() {
  scanf("%d %d", &n, &l);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int last = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] + a[i] >= l) {
      last = i;
      break;
    }
  }
  if (!last) {
    puts("Impossible");
  } else {
    puts("Possible");
    for (int i = 1; i < last; i++) {
      printf("%d\n", i);
    }
    for (int i = n - 1; i >= last; i--) {
      printf("%d\n", i);
    }
  }
  return 0;
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=map(int,input().split())
    from fractions import gcd
    from functools import reduce
    print(reduce(gcd,A))
resolve()

Measured memory_bytes: 74772
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int main() {
	string s;
	cin >> s;
	bool ans=false;
	for(int i = 0; i < 3; i++) ans|=(s[i]=='7');
	if(ans) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
    cin >>N;
    vector<int>vec(N);
    REP(i,N){
        cin>>vec[i];
    }
    int check=1;
    int ok=0;
    REP(i,N){
        if(vec[i]==check){
            ok++;
            check++;
        }
    }
    if(ok==0){
        cout <<-1 <<endl;
    }
    else{
        cout << N-ok << endl;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
	int N, K, m;
	char S[50];

	scanf("%d %d", &N, &K);
	scanf("%*c", S);
	scanf("%s", S);

	S[N] = '\0';
	m = K-1;
	S[m] = S[m] + 32;
	printf("%s\n", S);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void)
{
	int D;
	cin >> D;
	if (D == 25) cout << "Christmas" << endl;
	if (D == 24) cout << "Christmas Eve" << endl;
	if (D == 23) cout << "Christmas Eve Eve" << endl;
	if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
 
B = []
for i in range(len(A) - 1):
    B.append(A[i + 1] - A[i])
B.append(A[0] + K - A[-1])
 
print(sum(sorted(B)[:-1]))

Measured memory_bytes: 32116
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]


ab.sort(key=lambda x: x[1])
ans = 1
pre = ab[0][1]
for ele in ab[1:]:
    if pre > ele[0]:
        continue
    pre = ele[1]
    ans += 1
print(ans)






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

using ll = long long;

const int MAX_N = 2010;

ll a[MAX_N];
ll cost[MAX_N];

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

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

    ll ans = (1ll << 60ll);
    for (int move = 0; move < n; move++) {
        for (int i = 0; i < n; i++) {
            int id = (i - move + n) % n;
            cost[i] = min(cost[i], a[id]);
        }
        ll sum = move * x;
        for (int i = 0; i < n; i++) {
            sum += cost[i];
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  _int64 ans,tmp;
  int a,b,n,k;
  scanf("%d%d",&n,&k);
  ans=0;
  for (b=k+1;b<=n;b++)
  {
    ans+=(n/b)*(b-k);
    tmp=n%b;
    if (tmp>=k) ans+=tmp-k+1;
    if (k==0) ans--;
  }
  printf("%lld\n",ans);
  return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c;
    string s, t, u;
    cin >> a >> b;
    if(a>b && b != 1 || a == 1 && b != 1) P("Alice");
    else if (a<b && a != 1 || b==1 && a!=1) P("Bob");
    else P("Draw");
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.IOException;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String[] B = new String[] {"000","001","010","011","100","101","110","111"};
    public static void main(String[] args) {
    	int n = sc.nextInt();
    	String m = sc.next();
    	int[][] dp = new int[n][1 << 3];
    	//000 JOI
    	for(int i = 0; i < 1 << 3; i++) {
    		
    		if(B[i].charAt(JOI(m.charAt(0))) == '1' && B[i].charAt(0) == '1') {
    			dp[0][i] = 1;
    		}
    	}
    	
    	for(int i = 1; i < n; i++) {
    		for(int j = 0; j < 1 << 3; j++) {
    			if(B[j].charAt(JOI(m.charAt(i))) == '1') {
    				for(int k = 0; k < 1 << 3; k++) {
    					if((k & j) != 0) {
    						dp[i][j] += dp[i-1][k] % 10007;
    					}
    				}
    			}
    		}
    	}
    	int sum = 0;
    	for(int i = 0; i < 1 << 3; i++) {
    		sum += dp[n-1][i] % 10007;
    	}
    	System.out.println(sum % 10007);
    	
    	
    	
    }
    
    static int JOI(char a) {
    	if(a == 'J') return 0;
    	if(a == 'O') return 1;
    	return 2;
    }
    
    static String B(String a) {
    	StringBuilder sb = new StringBuilder();
    	for(int i = 0; i < 3- a.length(); i++) {
    		sb.append("0");
    	}
    	sb.append(a);
    	return sb.toString();
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

const int mod = 1e9+7;

int mpow(int a, int b)
{
  if(b == 0) return 1; 
  return mpow(a*a%mod, b/2)*(b%2?a:1)%mod;
}

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

  vi x(n);
  rep(i, 0, n) cin >> x[i];

  vi d(n-1);
  rep(i, 0, n-1) d[i] = x[i+1] - x[i];

  vi fac(n), inv(n);
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  rep(i, 2, n) fac[i] = fac[i-1]*i%mod, inv[i] = mpow(i, mod-2)%mod;

  int ans = 0, s = 0;
  rep(i, 0, n-1){
    (s += inv[i+1]) %= mod;
    (ans += d[i]*s%mod) %= mod;
  }
  cout << ans*fac[n-1]%mod << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int N=1e5+55;
vector < int > vec[N];
ll dp[N][2];
int m=1e9+7;

void bt(int u , int p)
{
    dp[u][0]=dp[u][1]=1;
    for(auto v:vec[u])
    {
        if(v==p)
            continue ;
        bt(v,u);
        dp[u][0]*=dp[v][1]+dp[v][0];
        dp[u][0]%=m;
        dp[u][1]*=dp[v][0];
        dp[u][1]%=m;
    }

}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        u--;
        v--;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    bt(0,0);
    cout<<(dp[0][0]+dp[0][1])%m<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int a, b, c, d;
    string s;
    cin >> s;
    a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    for (int i = -1; i <= 1; i += 2) {
        for (int j = -1; j <= 1; j += 2) {
            for (int k = -1; k <= 1; k += 2) {
                if (a + b * i + c * j + d * k == 7) {
                    cout << a;
                    cout << (i == 1 ? '+' : '-');
                    cout << b;
                    cout << (j == 1 ? '+' : '-');
                    cout << c;
                    cout << (k == 1 ? '+' : '-');
                    cout << d;
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 3620
{-# LANGUAGE MultiWayIf #-}

import qualified Data.ByteString.Char8 as B
import Data.Char (isSpace)
import Data.List (unfoldr)

readInt = B.readInt . B.dropWhile isSpace
readInts = unfoldr readInt

inf = 10000

a#b = abs (a-b)

solv :: Int -> Int -> Int -> [Int] -> Int
solv a b c ls = go ls (0,0,0) 0 where
  go [] (la,lb,lc) cost
    | la==0 || lb==0 || lc==0 = inf
    | otherwise = cost + a#la + b#lb + c#lc
  go (l:ls) (la,lb,lc) cost = minimum [forA, forB, forC, unuse] where
    forA = if
      | la/=0 && la#a < div l 2 -> inf
      | otherwise -> go ls (la+l, lb, lc) $ if la>0 then cost+10 else cost
    forB = if
      | lb/=0 && lb#b < div l 2 -> inf
      | otherwise -> go ls (la, lb+l, lc) $ if lb>0 then cost+10 else cost
    forC = if
      | lc/=0 && lc#c < div l 2 -> inf
      | otherwise -> go ls (la, lb, lc+l) $ if lc>0 then cost+10 else cost
    unuse = go ls (la,lb,lc) cost

main = do
  [n,a,b,c] <- readInts <$> B.getLine
  ls <- readInts <$> B.getContents
  print $ solv a b c ls


Measured memory_bytes: 892
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String a=sc.next();
String b=sc.next();
char c=b.charAt(b.length()-1);
String z=a+(String.valueOf(c));
if(z.equals(b))
System.out.println("Yes");
else
System.out.println("No");

}

}


Measured memory_bytes: 26988
#!/usr/bin/env python3

from collections import defaultdict

def main():
    n, k = map(int, input().split())
    td = []
    for i in range(n):
        ti, di = map(int, input().split())
        td.append((ti, di))
    td = list(reversed(sorted(td)))
    tdd = defaultdict(list)
    for t, d in td:
        tdd[t].append(d)

    a = []; b = []
    for _, v in tdd.items():
        a.append(v[0])
        b += v[1:]

    a = list(reversed(sorted(a)))
    b = list(reversed(sorted(b)))
    for i in range(1, len(a)):
        a[i] += a[i - 1]
    for i in range(len(a)):
        a[i] += (i + 1) ** 2
    for i in range(1, len(b)):
        b[i] += b[i - 1]

    a = [0] + a
    b = [0] + b

    res = 0
    for i in range(1, k + 1):
        if i >= len(a) or (k - i) >= len(b):
            continue
        ts = a[i] + b[k - i]
        res = max(res, ts)

    print(res)

if __name__ == "__main__":
    main()


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

ll n,a,b,c,d;
map<ll, ll> mp;
ll rec(ll x){
    if(x == 0) return 0ll;
    if(x == 1) return d;
    if(mp.count(x)) return mp[x];
    ll a1 = (x/2)*2;
    ll a2 = ((x+1)/2)*2;
    ll b1 = (x/3)*3;
    ll b2 = ((x+2)/3)*3;
    ll c1 = (x/5)*5;
    ll c2 = ((x+4)/5)*5;

    ll res = 1e18;
    if(x < res/d) res = x * d;
    res = min(res, llabs(x-a1)*d + a + rec(a1/2));
    res = min(res, llabs(x-a2)*d + a + rec(a2/2));
    res = min(res, llabs(x-b1)*d + b + rec(b1/3));
    res = min(res, llabs(x-b2)*d + b + rec(b2/3));
    res = min(res, llabs(x-c1)*d + c + rec(c1/5));
    res = min(res, llabs(x-c2)*d + c + rec(c2/5));
    return mp[x] = res;
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int t; cin >> t;
    while(t--){
        mp.clear();
        cin >> n >> a >> b >> c >> d;
        cout << rec(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  if((A+B) < 2*C){
    cout << A*X + B*Y << endl;
  }else if(A > 2*C && X >= Y){
    cout << 2*C*X << endl;
  }else if(B > 2*C && X < Y){
    cout << 2*C*Y << endl;
  }else if(X > Y && (A+B) > 2*C){
    cout << 2*C*Y + A*(X-Y) << endl;
  }else{
    cout << 2*C*X + B*(Y-X) << endl;
  }
}

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

int main(void){
    int d,l;
    cin>>d>>l;
    cout<<int(d/l)+d%l<<endl;
    return 0;
}





Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
ll ans[3000];
int  main()
{
    int r,d,x;
    scanf("%d%d%d",&r,&d,&x);;
    ans[x]=x;
    for(int i=x+1;i<=x+10;i++)
    {
        ans[i]=ans[i-1]*r-d;
        printf("%lld\n",ans[i]);
    }
}



Measured memory_bytes: 256
//

fun main() {
    aising2020b()
}

fun aising2020b() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    for ((i, v) in a.withIndex()) {
        if (i % 2 == 0 && v % 2 == 1) count++
    }
    println(count)
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solver() {
    int n = input(), k = input();
    vector< int > ps(n);
    cin >> ps;

    whole(sort, ps);
    int ans = 0;
    range(i, 0, k) ans += ps[i];
     
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N = read_a_int()
A = read_ints()
ans = 1
if 0 in A:
    print(0)
    exit()


for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

inline
bool can_it_make(int A[], int n){
    int res = A[0];
    REP(i, 3){
        if((n & 1) == 0) res += A[i + 1];
        else res -= A[i + 1];
        n >>= 1;
    }
    return res == 7;
}

int main(void){
    int A[4];
    char numb_chr;
    REP(i, 4){
        cin >> numb_chr;
        A[i] = (numb_chr - '0');
    }
    REP(i, 8){
        if(can_it_make(A, i)){
            REP(j, 3){
                cout << A[j] << (((i & 1) == 0) ? '+' : '-');
                i >>= 1;
            }
            cout << A[3] << "=7\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	int h, w;
	static const int v{ 10 };
	int H, W, C[10][10];

public:
	D()
	{
		cin >> H >> W;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				cin >> C[i][j];
			}
		}
	}

	void init()
	{
		//for (int k = 0; k < 10; k++) {
		//	for (int i = 0; i < 10; i++) {
		//		for (int j = 0; j < 10; j++) {
		//			C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
		//		}
		//	}
		//}

		REP(k, v)
			REP(i, v)
			REP(j, v)
			C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
	}
	void solve()
	{
		init();

		long long ret = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int x;
				cin >> x;
				if (~x) ret += C[x][1];
			}
		}

		cout << ret << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N; cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	vector<pair<int, int>> v(N);
	for(int i=0; i<N; i++) v[i] = {A[i], i};
	sort(v.begin(), v.end());

	for(int i=0; i<N; i++){
		cout << v[i].second+1 << (i==N-1?'\n':' ');
	}

	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,m,l,r,a,b;
int main(){
	cin>>n>>m;
	cin>>a>>b;
	for (int i=0;i<m-1;i++){
		cin>>l>>r;
		if (a<l) a=l;
		if (b>r) b=r;
	}
	if (b<a) b=a-1;
	cout<<b-a+1<<endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 058_arc_b / Link: https://arc058.contest.atcoder.jp/tasks/arc058_b?lang=en ----- */
/* ------問題------

縦 H マス、横 W マスのマス目があります。 いろはちゃんは、今一番左上のマス目にいます。 そして、右か下に1マス移動することを繰り返し、一番右下のマス目へと移動します。 ただし、下から A 個以内、かつ左から B 個以内のマス目へは移動することは出来ません。
移動する方法は何通りあるか求めてください。
なお、答えは非常に大きくなることがあるので、答えは 109+7 で割ったあまりを出力してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */




const long long mod = 1e9 + 7;

long long modpow(long long a, long long b) {
	if (b == 0) return 1;
	return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}

vector<long long> fact, inv_fact;

void init_fact(int n) {
	fact.resize(n);
	fact[0] = 1;
	for (int i = 1; i < n; i++) {
		fact[i] = i * fact[i - 1] % mod;
	}
	inv_fact.resize(n);
	inv_fact[n - 1] = modinv(fact[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[n - r] % mod;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

long long nHr(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return nCr(n + r - 1, r);
}
LL H, W, A, B;
LL ans = 0LL;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> H >> W >> A >> B;
	init_fact(300000);
	FOR(h, 0, H - A) {
		ans += (nCr(B - 1 + h, B - 1) * nCr(W - 1 - B + H - 1 - h, W - 1 - B)) % MOD;
		ans %= MOD;
	}


	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
  ll x; cin >> x;
  if(x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3560
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
int main(){
   long long  int n,i=1,mul=1;
    vector<int> v;
    scanf("%lld",&n);
    if(n==0){
        printf("0\n");
        return 0;
    }
    while(n!=0){
        if(n%(i<<1)!=0){
            v.PB(1);
            n-=mul*i;
        }
        else v.PB(0);
        mul=-mul;
        i<<=1;
    }
    for(int i=(int)v.size()-1;i>=0;i--)printf("%d",v[i]);
    printf("\n");
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	int a, b;
	cin >> a >> b;
	string ret = "x";
	if (a + b == 15)ret = "+";
	if (a * b == 15)ret = "*";
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t count = 0;

    bool cont = false;
    for (int64_t i = 1; i <= N; ++i) {
        int64_t a;
        std::cin >> a;

        if (a == i) {
            if (cont) {
                cont = false;
            }
            else {
                count++;
                cont = true;
            }
        }
        else {
            cont = false;
        }
    }


    std::cout << count << std::endl;

    return 0;
}


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

int main() {
    int n, c = 0, b;
    string s;
    cin >> n >> s;
    vector<int>as(n);
    vector<int>ms(n);
    for (int i = 0; i < n; i++){
        if (s[i] == 'W'){
            c++;
        }
        as[i] = c;
    }
    for (int i = 1; i < n; i++){
        ms[i] = as[i - 1] + n - i - 1 - (as[n - 1] - as[i]);
    }
    ms[0] = n - 1 - (as[n - 1] - as[0]);
    // for (int a : ms){
    //   cout << a << endl;
    // }
    sort(ms.begin(), ms.end());
    cout << ms[0] << endl;
} 

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

using namespace std;

int n, m, p;
long long x[2505], ans = LLONG_MIN, best;
vector<pair<int, long long>> v[2505];

int main() {
	scanf("%d%d%d", &n, &m, &p);
	for (int i = 2; i <= n; i++)
		x[i] = LLONG_MIN;
	while (m--) {
		int ta, tb, tc;
		scanf("%d%d%d", &ta, &tb, &tc);
		v[ta].emplace_back(tb, tc);
	}
	for (int i = 0; i <= n * 4; i++) {
		for (int j = 1; j <= n; j++)
			if (x[j] != LLONG_MIN)
				for (auto& k : v[j])
					x[k.first] = max(x[k.first], x[j] + k.second - p);
		ans = max(ans, x[n]);
		if (i == n * 3)
			best = ans;
		if (i != n * 4)
			continue;
		if (best == ans)
			printf("%lld\n", max(0LL, ans));
		else
			puts("-1");
	}
}


Measured memory_bytes: 512
l = list(map(int, input().split()))
#print(l)
ans = 0

mm = l[0]//(l[1]+l[2])
nn = l[0]%(l[1]+l[2])

ans += mm*l[1]

if nn >= l[1]:
  ans += l[1]
else:
  ans += nn

print(ans)

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

int main(){
    int a, b, tmp;
    int len = 0;
    vector<int> data;
    while (1) {
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        len+=2;
        if (b < a){
            tmp = b;
            b = a;
            a = tmp;
        }
        data.push_back(a);
        data.push_back(b);
    }
    for (int i = 0; i < len; i+=2){
        cout << data[i] << " " <<data[i + 1] << endl;
    }
}



Measured memory_bytes: 3120
h,w = gets.split.map{|n|n.to_i}
array = Array.new
h.times do |i|
    array.push(gets.chomp)
end
w.times do |i|
    print("#")
end
print("##\n")
h.times do |i|
    print("#")
    print(array[i])
    print("#\n")
end
w.times do |i|
    print("#")
end
print("##\n")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << (a * b % 2 == 1 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n, k, i, j;
 cin>>n>>k;
 long long arr[100001];
 long long dp[100001];
 for(i=0;i<n;i++)
   cin>>arr[i];
 for(i=0;i<n;i++)
   dp[i]=INT_MAX;
 dp[0]=0;
 dp[1]=abs(arr[1]-arr[0]);
 for(i=2;i<n;i++)
 {
   //dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
   for(j=i-1;i-j<=k && j>=0;j--)
   {
     dp[i]=min(dp[i], dp[j]+abs(arr[i]-arr[j]));
   }
 }
 cout<<dp[n-1]<<endl;
 return 0;
}
  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 4294967296
#define MAX 100001
#define forn(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
int main()
{   
      boost;
            int a,b;
            cin>>a>>b;
            if(b>a)
            swap(a,b);
 int d=2*a-1;
            if(a>8)
            {
                  cout<<":(";
                  return 0;
            }
            else
            {
                  int unused=d-a;
                  unused+=abs(16-d);
                  if(unused>=b)
                  {
                        cout<<"Yay!"<<endl;
                  }
                  else
                  {
                        cout<<":(";
                  }
            }
}

Measured memory_bytes: 256