akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<string>
#include<climits>
using namespace std;
typedef long long ll;
#define INF (LLONG_MAX)
typedef pair<ll,int> P;
#define F first
#define S second
int N;
ll H;
P d[400001];
ll h[400001];
int n;
void update(int k,ll a){
  int i=k;
  k += n-1;
  d[k].F = a;
  d[k].S = i;
  while( k > 0 ){
    k=(k-1)/2;
    d[k] = max( d[k*2+1] ,d[k*2+2] );
  }
}  
void init(){
  n = 1;
  while( n < N-1 ) n *= 2;
  /*  for(int i=0;i<2*n-1;i++){
    h[i]=H;
    }*/
}

void add(int a,int b,ll x,int k,int l,int r){
  if( r<=a || b<=l ) return;
  if( a<=l && r<=b ){
    h[k] += x;
    return;
  }
  add(a,b,x,k*2+1,l,(l+r)/2);
  add(a,b,x,k*2+2,(l+r)/2,r);
}

P qmax(int a,int b,int k, int l,int r){
  //  printf("qmax:%d %d %d %d %d\n",a,b,k,l,r);
  if( r<=a || b<=l ) return P(-1,-1);
  if( a<=l && r<=b ) return d[k];
  P vl = qmax(a,b,k*2+1,l,(l+r)/2);
  P vr = qmax(a,b,k*2+2,(l+r)/2,r);
  return max(vl,vr);
}

ll sum(int k){
  k += n-1;
  ll ret = h[k];
  while ( k > 0 ){
    k = (k-1)/2;
    ret += h[k];
  }
  return ret;
}

pair<ll,ll> proc(int &st,int i){
  bool r = true;
  P p;
  ll s;
  while(r){
    p = qmax(st,i+1,0,0,n);
    s = sum(p.S);
    if( s < p.F ){
      update(p.S,s);
    } else
      r = false;
    st = p.S;
    //printf("proc check : %lld %d  許容量:%lld st:%d i:%d\n",p.F,p.S,s,st,i);
    //    sleep(1);
  }
  return pair<ll,ll>(p.F,s);
}

int main(){
  scanf("%d %lld",&N,&H);
  ll dm = 0;
  int st = 0;
  ll res = 0;
  init();
  for(int i=0;i<N-1;i++){
    ll a,b;
    scanf("%lld %lld",&b,&a);
    update(i,a);
    if( dm+b >= H ){
      ll nd = (dm+b) - H + 1;
      while(nd>0){
	pair<ll,ll> p = proc(st,i);
	ll c;
	//	if( p.S >= nd ){
	c = (nd-1) / p.F + 1;
	if( c*p.F > p.S ){
	  ///	} else {
	  c= p.S / p.F;
	}
	res+=c;
	add( st, i+1, -c*p.F, 0, 0, n);
	nd -= c*p.F;
	//	printf("dm+b check : %lld 残り回復量:%lld 回復量:%lld st:%d i:%d\n",res,nd,c*p.F,st,i);     
      }
      dm = max( 0LL, H + nd -1 );
    } else
      dm+=b;
    h[i+n] = dm;
    //  printf("check: %lld ダメージ総量:%lld %d %d\n",res,dm,st,i);
  }
  printf("%lld\n",res);
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string S;
    cin >> S;

    // 処理
    // 出力
    if (S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(2) == S.at(3)) {
        cout << "No" << endl;
    } else if ((S.at(0) == S.at(1) && S.at(2) == S.at(3)) ||
               (S.at(0) == S.at(2) && S.at(1) == S.at(3)) ||
               (S.at(0) == S.at(3) && S.at(1) == S.at(2))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		// 頂点の数
		int n = sc.nextInt();

		int[][] matrix = new int[n][n];

		// 各頂点
		for (int i = 0; i < n; i++) {

			// 頂点の番号(読み捨てる)
			int u = sc.nextInt();
			// 頂点の出次数
			int k = sc.nextInt();

			for (int j = 0; j < k; j++) {
				// 入力側の頂点番号 - 1
				int v = sc.nextInt() - 1;
				matrix[i][v] = 1;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j == n - 1) {System.out.print(matrix[i][j]); continue; }
				System.out.print(matrix[i][j] + " ");
			}
			System.out.print("\n");
		}
		sc.close();

	}

}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
  
  






  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int lower, upper, c;
	cin >> lower >> upper >> c;

	int divisor = 0;

	for (int i = lower; i <= upper; i++){
		if (!(c % i))
			divisor++;
	}

	cout << divisor << endl;

	return 0;
}




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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;
using lint=long long;

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

	lint ans=n;
	for(lint d=1;d*d<=n;d++) if(n%d==0) {
		ans=min(ans,d+n/d-2);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
bool prime(int n){
	if(n<2) re 0;
	for(int i=2;i*i<=n;i++) if(n%i==0) re 0;
	re 1;
}
vector<int> v;
signed main(){
	ios_base::sync_with_stdio(0);
	for(int i=3;i<1e5;i+=2)
		if(prime(i)&&prime((i+1)/2))
			v.pb(i);
	int q;
	cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<(upper_bound(all(v),r)-v.begin())-(lower_bound(all(v),l)-v.begin())<<"\n";
	}
	re 0;
}

Measured memory_bytes: 3672
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
int a[100];
void solve(){
    for (int i = 0; i < 5; ++i) {
        cin>>a[i];
        if (a[i]==0)
            cout<<i+1<<endl;
    }
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const int N=2e5+10;
string A;
int R[N], L[N], ans[N];
int main() {
    cin >> A;
    int n=A.length();
    REP(i, n) {
        if(A[i]=='R') L[i]=0;
        else L[i] = L[i-1]+1;
    }
    for(int i=n-1; i>=0; i--) {
        if(A[i]=='L') R[i]=0;
        else R[i] = R[i+1]+1;
    }

    REP(i, n) {
        if(A[i]=='L') {
            if(L[i]%2) ans[i-L[i]+1]++;
            else ans[i-L[i]]++;
        } else {
            if(R[i]%2) ans[i+R[i]-1]++;
            else ans[i+R[i]]++;
        }
    }

    REP(i, n) cout << ans[i] << (i==n-1? '\n':' ');
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<deque>
using namespace std;
char a[100001],y[9];int q,op,x,now;deque<char>ans;
main()
{
	scanf("%s",a);
	for(register int i=0;a[i];++i)ans.push_back(a[i]);
	for(scanf("%d",&q);q--;)
	{
		scanf("%d",&op);
		if(op==1)now^=1;
		else
		{
			scanf("%d%s",&x,y);--x;x^=now;
			if(x)ans.push_back(y[0]);
			else ans.push_front(y[0]);
		}
	}
	if(now)for(;ans.size();putchar(ans.back()),ans.pop_back());
	else for(;ans.size();putchar(ans.front()),ans.pop_front());
	putchar('\n');
}

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

int main() {

  int i, N,temp, fx=0;
  
  cin >> N;
  
  temp = N;
  while (temp > 0) {
  	fx += temp % 10;
  	temp /= 10;
  }
  
  if (N % fx == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
using namespace std;
int main()
{
  ll n,m,k,t,sum=0;
  cin>>n>>m>>k;
  sum=(n/m)*k;
  if(n%m!=0)
    sum+=k;
  cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

	int K, Q, origD[5000], D[5000]; cin >> K >> Q;
	REP(i, K) cin >> origD[i];
	int N, X, M;
	REP(_, Q){
		cin >> N >> X >> M;
		int cnt = 0, sum = 0;
		REP(i, K){
			D[i] = origD[i] % M;
			if(D[i] == 0){
				if(i >= (N-1)%K) cnt += (N-1) / K;
				else cnt += (N-1)/K + 1;
			}
			sum += D[i];
		}
		int div = (N-1) / K;
		int md = (N-1) % K;
		sum *= div;
		REP(i, md) sum += D[i];
		int num = (X + sum)/M - X/M;
		cout << N-1-cnt-num << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  int a[N], cnt = 0, button = 0;
  bool used[N], can = false;
  for (int i=0; i<N; i++) {
    cin >> a[i];
    a[i]--;
    used[i] = false;
  }
  while (!used[button]) {
    cnt++;
    used[button] = true;
    button = a[button];
    if (button == 1) {
      can = true;
      break;
    }
  }
  if (can)
    cout << cnt << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

string dp[20][2];

int digitsum(string n)
{
	int res=0;
	rep(i,n.size())
	{
		res += n[i]-'0';
	}
	return res;
}

int main()
{
	fill(dp[0],dp[20],'0');
	string n;
	cin >> n;
	dp[0][0].push_back(n[0]);
	dp[0][1].push_back(n[0]-1);
	for(int i = 1;i<n.size();i++)
	{
		for(char c = '0';c<='9';c++)
		{
			string next;
			if(n[i]>c)
			{
				next = dp[i-1][0]+c;
				if(digitsum(dp[i][1])<digitsum(next))
				{
					dp[i][1]=next;
				}
			}
			next = dp[i-1][1]+c;
			if(digitsum(dp[i][1])<digitsum(next))
			{
				dp[i][1]=next;
			}
		}
		dp[i][0] = dp[i-1][0]+n[i];
	}
	cout<<max(digitsum(dp[n.size()-1][0]),digitsum(dp[n.size()-1][1]))<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> b(n), c(n);
    rep(i,n){
        b[i] = -a[i] - i;
        c[i] = a[i] - i;
    }
    ll ans = 0;
    unordered_map<ll, ll> counter;
    rep(i, n) {
        ans += counter[c[i]];
        counter[b[i]]++;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans = a-b*2;
    cout<<max(0LL,ans)<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();

       long[] a = new long[N];
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextLong();
       }
       
       long[] min = new long[N];
       int cnt=0;
       for(int i=0;i<N;i++) {
    	   int right=cnt;
    	   int left=-1;
    	   while(right-left>1) {
    		   int mid=left+(right-left)/2;
    		   if(min[mid]<a[i]) right=mid;
    		   else left=mid;
    	   }
    	   min[right]=a[i];
    	   cnt=Math.max(cnt, right+1);
       }

    System.out.println(cnt); 	
              		
   }

}

Measured memory_bytes: 60136
#include<bits/stdc++.h>
using namespace std;
#define reg register

const int a[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};

int K;

int main(void){
	scanf("%d",&K);
	printf("%d\n",a[K-1]);
	return 0;
}

Measured memory_bytes: 256
import Text.Printf

main = getLine >>= putStrLn . solve . input

-- 入力
input :: String -> [Int]
input = map read . words

-- 解答
solve [a, b] = printf "%d %d %.8f" x y z
  where
    (x, y, z) = (div a b, mod a b, (fromIntegral a / fromIntegral b) :: Double)
solve xs = "Error parsing input"


Measured memory_bytes: 3972
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;
string s;
int totalE, totalW;

int main() { 

  scanf("%d\n", &n);
  getline(cin, s);
  for (int i = 0; i < sz(s); i++) {
    if (s[i] == 'E') {
      totalE++;
    } else {
      totalW++;
    }
  }

  int ans = n;
  int curE = 0, curW = 0;
  for (int i = 0; i < sz(s); i++) {
    int cur = curW + totalE - curE;
    if (s[i] == 'E') {
      cur--;
    }
    ans = min(ans, cur);

    if (s[i] == 'E') {
      curE++;
    } else {
      curW++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 900
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  ll ans;
  if (x < 0) x = -x;
  ll div = x / d, mod = x % d;
  if (div > k)
    ans = x - d * k;
  else {
    if ((k - div) % 2 == 0)
      ans = mod;
    else
      ans = -(mod - d);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    int l = 0;
    for(int i = b - a - 1;i > 0;i--){
        l += i;
    }
    cout << l - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
     cin >> s;

     if( s == "ABC" ) cout << "ARC\n";
     else cout << "ABC\n";
}

int32_t main()
{
     FAST;     
     int t=1; 
     // cin>>t;
     test(t) go();
}

 

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = 0;
  if (n % 2 == 0) {
    result = n / 2;
  } else {
    result = n / 2 + 1;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.LongStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BColorfulSlimes solver = new BColorfulSlimes();
        solver.solve(1, in, out);
        out.close();
    }

    static class BColorfulSlimes {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextLong();
            long[][] a = new long[n][n];
            a[0] = LongStream.range(0, n).map(z -> in.nextInt()).toArray();
            long ans = LongStream.of(a[0]).sum();
            for (int k = 1; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    a[k][i] = Math.min(a[k - 1][(i + n - 1) % n], a[0][i]);
                }
                ans = Math.min(ans, LongStream.of(a[k]).sum() + k * x);
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 84420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ask= 0;
    if(a + b > 2*c)
    {
        int u = min(x,y);
        ask += 2*c*u;
        x-=u,y-=u;
        ask += min(x*a + y*b,2*c*(x?x:y));
    }
    else ask += x*a + y*b;
    cout<<ask<<endl;
    return 0;
}

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

int main () 
{
    int a, b, c;
    int count = 0;
    
    std::cin >> a >> b >> c;
    
    for (int i = a; i <= b; i++) 
    {
        if ( c % i == 0) count++;
    }
    
    std::cout << count << std::endl;
    
    return 0;
}


Measured memory_bytes: 3092
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> vec(r, vector<ll>(c, 0));
    rep(i, k) {
        int x, y, v;
        cin >> x >> y >> v;
        --x; --y;
        vec[x][y] = v;
    }
    
    vector<vector<vector<ll>>> dp(r + 1, vector<vector<ll>>(c + 1, vector<ll>(4, 0)));
    for (int i = r - 1; i >= 0; --i) for (int j = c - 1; j >= 0; --j) rep(k, 4) {
        if (k) chmax(dp[i][j][k], dp[i][j + 1][k - 1] + vec[i][j]);
        if (k) chmax(dp[i][j][k], dp[i + 1][j][3] + vec[i][j]);
        if (k) chmax(dp[i][j][k], dp[i][j][k - 1]);
        chmax(dp[i][j][k], dp[i + 1][j][3]); chmax(dp[i][j][k], dp[i][j + 1][k]);
    }
    cout << dp[0][0][3] << "\n";
}


Measured memory_bytes: 706772
#include <iostream>
#include <vector>
 
using namespace std;
 
#define INF 1e9
 
int main(){
    int P,Q;
    while(cin >> P >> Q, (P | Q)){
	int ind[10];
	int ro[10],rc[10],co[10],cc[10],so[10],sc[10];
	int ro2[10],rc2[10],co2[10],cc2[10],so2[10],sc2[10];
	string s;
	for(int i = 0 ; i < 10 ; i++){
	    ind[i] = 0;
	    ro[i] = rc[i] = 0;
	    co[i] = cc[i] = 0;
	    so[i] = sc[i] = 0;
	}
	for(int i = 0 ; i < P ; i++){
	    cin >> s;
	    bool rd = true;
	    for(int j = 0 ; j < (int)s.size() ; j++){
		if(s[j] == '(') ro[i]++; 
		if(s[j] == ')') rc[i]++; 
		if(s[j] == '{') co[i]++; 
		if(s[j] == '}') cc[i]++; 
		if(s[j] == '[') so[i]++;
		if(s[j] == ']') sc[i]++;
		if(s[j] != '.') rd = false;
		if(rd){ ind[i]++; }
	    }
	}
	for(int i = 1 ; i < P ; i++){
	    ro[i] += ro[i-1];
	    rc[i] += rc[i-1];
	    co[i] += co[i-1];
	    cc[i] += cc[i-1];
	    so[i] += so[i-1];
	    sc[i] += sc[i-1];
	}
	for(int i = 0 ; i < 10 ; i++){
	    ro2[i] = rc2[i] = 0;
	    co2[i] = cc2[i] = 0;
	    so2[i] = sc2[i] = 0;
	}
	for(int i = 0 ; i < Q ; i++){
	    cin >> s;
	    for(int j = 0 ; j < (int)s.size() ; j++){
		if(s[j] == '(') ro2[i]++; 
		if(s[j] == ')') rc2[i]++; 
		if(s[j] == '{') co2[i]++; 
		if(s[j] == '}') cc2[i]++; 
		if(s[j] == '[') so2[i]++; 
		if(s[j] == ']') sc2[i]++; 
	    }
	}
	for(int i = 1 ; i < Q ; i++){
	    ro2[i] += ro2[i-1];
	    rc2[i] += rc2[i-1];
	    co2[i] += co2[i-1];
	    cc2[i] += cc2[i-1];
	    so2[i] += so2[i-1];
	    sc2[i] += sc2[i-1];
	}
	vector<int> res(10,INF);
	res[0] = 0;
	for(int i = 1 ; i < Q ; i++){
	    vector<int> v;
	    for(int R = 1 ; R <= 20 ; R++){
		for(int C = 1 ; C <= 20 ; C++){
		    for(int S = 1 ; S <= 20 ; S++){
			bool ok = true;
			for(int j = 1 ; j < P ; j++){
			    int rd = ro[j-1]-rc[j-1];
			    int cd = co[j-1]-cc[j-1];
			    int sd = so[j-1]-sc[j-1];
			    if(R*rd+C*cd+S*sd != ind[j]){
				ok = false;
				break;
			    }
			}
			if(ok){
			    int rd = ro2[i-1]-rc2[i-1];
			    int cd = co2[i-1]-cc2[i-1];
			    int sd = so2[i-1]-sc2[i-1];
			    int val = R*rd+C*cd+S*sd;
			    if(res[i] == INF){
				res[i] = val;
			    }else{
				if(res[i] != val && res[i] != -1){
				    res[i] = -1;
				}
			    }
			}
		    }
		}
	    }
	}
	for(int i = 0 ; i < Q ; i++){
	    if(i) cout << " "; 
	    cout << res[i];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
n, l = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
for i in range(n-1):
    b.append(a[i] + a[i+1])
if max(b) >= l:
    ans = "Possible"
else:
    ans = "Impossible"
print(ans)
if ans == "Possible":
    k = b.index(max(b))
    ans = list(range(1, k + 1)) + list(range(n - 1, k + 1, -1)) + [k + 1]
    for i in ans:
        print(i)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int s = 0;
    rep(i,n) s += a[i];
    int cnt = 0;
    rep(i,n) {
      if (a[i]*(4*m) >= s) cnt++;
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
         
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define ss(a) scanf("%s",a)
#define mem(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
const double pi = acos(-1.0);
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
map<int, int>mp;
int main(){
	int n, x;
	sc(n);
	for(int j = 1; j <= n; j ++){
		sc(x);
		if(x == 1) mp[1] ++;
		for(int i = 2; i * i <= x; i ++){
			if(x % i == 0){
				int cnt = 0;
				while(x % i == 0){
					cnt ++;
					x /= i;
				}
				mp[i] ++;
			}
		}
		if(x > 1) mp[x] ++;
	}
	int f1 = 0, f2 = 0;
	for(auto i : mp){
		//cout << i.first << " " <<i.second << endl;
		if(i.first == 1)continue;
		if(i.second > 1) f1 = 1;
		if(i.second == n) f2 = 1;
	}
	if(!f1 || mp[1] == n) puts("pairwise coprime");
	else if(f2) puts("not coprime");
	else puts("setwise coprime");
	return 0;
}


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

int main(){
  int tax8,tax10;
  cin >> tax8 >> tax10;

  bool is_satisfied= false;
  int price= 10* tax10;
  while(price < 10*(tax10+1)){
    int t= price* 0.08;
    if(t==tax8){
      is_satisfied= true;
      break;
    }
    price++;
  }
  
  if(is_satisfied){
    cout << price << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
	stack<int> S;
	string s;
	int a, b;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		} else if (s[0] == '-') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(b - a);
		} else if (s[0] == '*') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		} else {
			S.push(atoi(s.c_str()));
        }
	}

	cout << S.top() << endl;

	return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
const int MOD=1000000007;
const int size=100005;
long long inv[size],fac[size],finv[size];
void make()
{
	inv[0]=inv[1]=fac[0]=fac[1]=finv[0]=finv[1]=1;
	for (int i=2;i<size;i++)
	{
		inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*(long long)i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
long long C(int a,int b)
{
	if (a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
    make();
    int n,id[size],t,s;
    cin>>n;
    memset(id,-1,sizeof(id));
    for (int i=0;i<=n;i++)
    {
    	int a;
    	cin>>a;
    	a--;
    	if(id[a]==-1)
    	{
    		id[a]=i;
    	}
    	else
    	{
    		s=id[a];
    		t=i;
    	}
    }
    for (int i=1;i<=n+1;i++)
    {
    	long long ans;
    	ans=(C(n+1,i)-C(s+n-t,i-1));
    	if (ans<0) ans+=MOD; 
    	cout<<ans<<endl;
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    ll ans = 1;
    ll bad = 1;
    vector<int> A(N);
    for (int i = 0; i < N;i++)
    {
        cin >> A[i];
        ans *= 3;
        if(A[i] % 2== 0){
            bad *= 2;
        }
    }
    cout << ans- bad << endl;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    p,q,r=INTM()
    print(min(p+q,q+r,r+p))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <tuple>
#define maxn 55
#define maxV 105
#define mt make_tuple

using namespace std;
typedef long long ll;
typedef tuple<int, int, int> T;
struct node{
  int chi[4], fail;
  bool forbid;
  node(){
    memset(chi, 0, sizeof(chi));
    fail = forbid = 0;
  }
}a[maxV]; int V;
// root: node 1.
namespace acAuto{
  void init(){
    for(int i = 1;i <= V;i++) a[i] = node();
    V = 1;
  }
  void ins(int* s, int n){ // |S| = n.
    int u = 1;
    for(int i = 1;i <= n;i++){
      if(!a[u].chi[s[i]]) a[u].chi[s[i]] = ++V;
      u = a[u].chi[s[i]];
    }
    a[u].forbid = true;
  }
  void build(){
    queue<int> que;
    que.push(1);
    while(!que.empty()){
      int u = que.front();
      que.pop();
      for(int i = 0;i < 4;i++){
        int v = a[u].chi[i], f = a[u].fail;
        if(v){
          if(f) a[v].fail = a[f].chi[i];
          else a[v].fail = 1;
          if(a[a[v].fail].forbid) a[v].forbid = true;
          que.push(v);
        }else{
          if(f) a[u].chi[i] = a[f].chi[i];
          else a[u].chi[i] = 1;
        }
      }
    }
  }
}
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int idx[135], n, m, p, sidx[15], rs, cs, rg, cg;
char grid[maxn][maxn], s[15];
int f[maxn][maxn][maxV];
void solve(){
  acAuto::init();
  for(int i = 1;i <= n;i++) scanf("%s", grid[i] + 1);
  scanf("%d", &p);
  for(int i = 1;i <= p;i++){
    scanf("%s", s + 1);
    int l = strlen(s + 1);
    for(int j = 1;j <= l;j++) sidx[j] = idx[(int)s[j]];
    acAuto::ins(sidx, l);
  }
  acAuto::build();
  for(int i = 0;i <= n + 1;i++) grid[i][0] = grid[i][m + 1] = '#';
  for(int i = 1;i <= m;i++) grid[0][i] = grid[n + 1][i] = '#';
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      if(grid[i][j] == 'S') rs = i, cs = j;
      else if(grid[i][j] == 'G') rg = i, cg = j;
    }
  }
  memset(f, 0x3f, sizeof(f));
  f[rs][cs][1] = 0;
  queue<T> que;
  que.push(mt(rs, cs, 1));
  while(!que.empty()){
    int x = get<0>(que.front()), y = get<1>(que.front()), u = get<2>(que.front());
    que.pop();
    if(x == rg && y == cg){
      printf("%d\n", f[x][y][u]);
      return;
    }
    for(int d = 0;d < 4;d++){
      int cx = x + dx[d], cy = y + dy[d], cu = a[u].chi[d];
      if(grid[cx][cy] != '#' && !a[cu].forbid && f[x][y][u] + 1 < f[cx][cy][cu]){
        f[cx][cy][cu] = f[x][y][u] + 1;
        que.push(mt(cx, cy, cu));
      }
    }
  }
  puts("-1");
}
int main(){
  idx['U'] = 0, idx['R'] = 1, idx['D'] = 2, idx['L'] = 3;
  while(~scanf("%d%d", &n, &m) && n) solve();
  return 0;
}



Measured memory_bytes: 4564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		if (A * N > B) {
			ans = B;
		} else {
			ans = A * N;
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <fstream>   

using namespace std;

int main() {

	int n, x, t;

	cin >> n >> x >> t;

	int time = 0;
	while (n > 0) {
		time = time + t;
		n = n - x;
	}
	cout << time;

	return 0;
}

Measured memory_bytes: 3636
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  L, R = input_list()
  ans = []
  for x in range(L, R+1):
    for y in range(x+1, R+1):
      ans.append((x*y)%2019)
      if (x*y) % 2019 == 0:
        print(0)
        exit(0)
  print(min(ans))  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 69356
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i=0; i<n; i++) {
            h[i] = sc.nextInt();
        }
        int ans = 0;
        int count = 0;
        for(int i=0; i<n-1; i++) {
            if(h[i] >= h[i+1]) {
                count++;
                if(count > ans) ans = count;
            } else count = 0;
        }
        System.out.println(ans);
    }
}

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

int main(){
  int n;
  int s=0;
  cin >> n;
  vector<int> d(n);
  for(int i;i<n;i++){
    cin >> d[i];
  }
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      s+=d[i]*d[j];
    }
  }
  cout << s;
  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 reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int m, d;
void solve() {
    cin >> m >> d;

    int ans = 0;
    reps(i, m) reps(j, d) {
        auto d1 = j % 10, d10 = (j % 100 - d1) / 10;

        if (d1 >= 2 && d10 >= 2 && d1 * d10 == i)
            ++ans;

    }

    cout << ans << endl;

    return;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main (){
    int n;
    cin >> n;
    int sum=0;
    int l[10000],r[10000];
    for (int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        sum+=r[i]-l[i]+1;
    }

    cout << sum << endl;



   return 0;
}

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

int main(){

	int x,y;

	while (1) {
		cin >> x >> y;
		if (x ==0 && y==0) break;
		if (x > y) cout << y << " " << x<<endl;
		if (x <= y) cout << x << " " << y <<endl;
	}

	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
#define rep(i) for(int i = 0; i < 10; ++i)

int main(void) {
  int n, i, ar[60], b, c, d, e;
  for(i = 1; i < 52; ++i) ar[i] = 0;
  for(i = 1; i < 52; ++i) {
    rep(b) rep(c) rep(d) rep(e) {
      if(b + c + d + e == i)ar[i]++; 
    }
  }
  while(scanf("%d", &n) != EOF) {
    printf("%d\n", ar[n]);
  }
  return 0;
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  ll a[N], ma = 0, mi = 1000000001;
  rep(i, N){
    cin >> a[i];
  }
  rep(i, N){
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }
  cout << ma - mi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, ans = 0, tot = 0;
	scanf("%d", &n);
	set <int> S;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		int y = (x^(x-1));
		S.insert(y);
		tot^=x;
	}
	for (int i = 29; i >= 0; --i)
	{
		if((tot & (1<<i)))
		{
			int need = (1<<(i+1))-1;
			if(S.find(need) != S.end())
			{
				tot^=need;
				ans++;
			}
			else
			{
				printf("-1\n");
				return 0;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
//in the name of Allah
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, mod = 1e9 + 7;
long long x[N], cnt1[N], cnt2[N], dp1[N], dp2[N];

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i ++){
        cin >> x[i];
        if(i > 0){
            cnt1[i] = cnt1[i - 1];
            cnt2[i] = cnt2[i - 1];
            if(x[i] - x[i - 1] < a)
                cnt1[i] ++;
            if(x[i] - x[i - 1] < b)
                cnt2[i] ++;
        }
    }
    dp1[0] = dp2[0] = 1;
    for(int i = 1; i < n; i ++){
        int ind1 = upper_bound(x, x + n, x[i] - a) - x;
        int ind2 = upper_bound(x, x + n, x[i] - b) - x;
        if(ind1 == 0){
            if(cnt2[i - 1] == 0)
                dp1[i] = 1;
        }
        else{
            if(ind1 == i)
                dp1[i] = (dp1[i - 1] + dp2[i - 1]) % mod;
            else{
                if(cnt2[i - 1] - cnt2[ind1] == 0)
                    dp1[i] = dp2[ind1];
            }
        }
        if(ind2 == 0){
            if(cnt1[i - 1] == 0)
                dp2[i] = 1;
        }
        else{
            if(ind2 == i)
                dp2[i] = (dp2[i - 1] + dp1[i - 1]) % mod;
            else{
                if(cnt1[i - 1] - cnt1[ind2] == 0)
                    dp2[i] = dp1[ind2];
            }
        }
    }
    cout << (dp1[n - 1] + dp2[n - 1]) % mod;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  ll alice = 0;
  ll bob = 0;
  for(int i = 0; i < N; ++i){
    if(i % 2 == 0){
      alice += a[i];
    }else{
      bob += a[i];
    }
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int k,t;
    cin>>k>>t;
    vector<int> a(t);
    rep(i,t) cin>>a[i];

    sort(all(a));
    reverse(all(a));

    if(t==1){
        cout<<a[0]-1<<endl;
        return 0;
    }

    if(a[0]-1<=a[1]) cout<<0<<endl;
    else{
        int sum=0;
        for(int i=1;i<t;i++){
            sum+=a[i];
        }
        if(sum>=a[0]-1) cout<<0<<endl;
        else cout<<a[0]-1-sum<<endl;
    }
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cmath>

double x[4],y[4];

struct vektor{
	double x,y;
	vektor(){}
	vektor(double xx,double yy){
		x=xx;
		y=yy;
	}
};

vektor vek[3];

vektor make_vektor(int i,int j){
	return vektor(x[j]-x[i],y[j]-y[i]);
}

bool check(){
	double s=-(vek[2].x*vek[1].y-vek[2].y*vek[1].x)/(vek[1].x*vek[0].y-vek[1].y*vek[0].x);
	double t=(vek[2].x*vek[0].y-vek[2].y*vek[0].x)/(vek[1].x*vek[0].y-vek[1].y*vek[0].x);
	//printf("%.3f %.3f\n",s,t);
	if(s>0 && t>0 && s+t<1)return true;
	return false;
}

int main(void){
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])){
		for(int i=0;i<3;i++){
			vek[i]=make_vektor(0,i+1);
		}
		printf("%s\n",check()?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>

int main(void){
  int n,tt,i;
  int a[101],b[10];
  for(i=0;i<101;i++){
  	a[i]=-1;
  }
  for(i=0;i<9;i++){
  	b[i+1]=0;
	scanf("%d",&n);
	a[n]=i+1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&tt);
  	b[a[tt]]=1;
  }
  if((b[1]*b[2]*b[3])==1||(b[4]*b[5]*b[6])==1||(b[7]*b[8]*b[9])==1||(b[1]*b[4]*b[7])==1||(b[2]*b[5]*b[8])==1||(b[3]*b[6]*b[9])==1||(b[1]*b[5]*b[9])==1||(b[3]*b[5]*b[7])==1){
  	printf("Yes");
  }else{
  	printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int ok[100];

inline bool done(int n){
    while(n>0){
        if(ok[n%10]) return 0;
        n/=10;
    }
    return 1;
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);

    for(int i=1; i<=k; i++){
            int x;
        scanf("%d", &x);
        ok[x]=1;
    }

    while(!done(n)) n++;

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

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
//#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

int gcd(int a,int b)
{
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}




int solve( ){


int n;
cin>>n;
vi a(n);
int b[n+1]={0};
int c[n+1]={0};
int su=0;
rep(i,0,n)cin>>a[i];

int g=0;
rep(i,0,n)
{
  b[i]=g;
  g=gcd(g,a[i]);
}
g=0;
for(int i=n-1;i>=0;i--)
{
   c[i]=g;
   g=gcd(g,a[i]);
}
int mx=0;
rep(i,0,n)
{
  mx=max(mx,gcd(b[i],c[i]));
}
cout<<mx;


return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);

  

 //sieve();
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
 // cout << "Processor time taken is "
   // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
struct unionfind {
	vector<int> rank, par;
	unionfind() {}
	unionfind(int n):rank(n, 1), par(n, 0) {
		iota(par.begin(), par.end(), 0);
	}
	int root(int x) {
		return (x == par[x] ? x : par[x] = root(par[x]));
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if(x == y) return;
		if(rank[x] < rank[y]) swap(x, y);
		rank[x] += rank[y];
		par[y] = x;
	}
};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int h, w;
	cin >> h >> w;
	vector<string> g(h);
	for(int i = 0; i < h; i++) {
		cin >> g[i];
	}
	unionfind u(h * w);
	int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			for(int k = 0; k < 4; k++) {
				int x = i + dx[k];
				int y = j + dy[k];
				if(x < 0 || y < 0 || x >= h || y >= w) continue;
				if(g[i][j] == g[x][y]) continue;
				u.unite(x * w + y, i * w + j);
			}
		}
	}
	vector<vector<long long>> a(2, vector<long long>(h * w));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(g[i][j] == '#') a[0][u.root(i * w + j)]++;
			else a[1][u.root(i * w + j)]++;
		}
	}
	long long ans = 0;
	for(int i = 0; i < h * w; i++) {
		ans += a[0][i] * a[1][i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
ll a[1001];
int main() {
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {
            k += a[i]*a[j];
        }
    }
    cout<<k;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    int cur;
    scanf("%lld",&cur);
    int ans = 0;
    for (int i = 1; i < n; i++){
        int x;
        scanf("%lld",&x);
        ans += min((x-cur)*a, b);
        cur = x;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 256