akhauriyash/Code-Regression huggingface dataset:
K, A, B = map(int, input().split())
cookie = 1
coin = 0

delta = B - A

if delta <= 2 or A >= K:
    print(K+cookie)
    exit()

# hit while able to exchange
fst_hit = A - 1
cookie += fst_hit

# exchange
exchange_count = int((K - A+1)/2)
cookie += (delta * exchange_count)

# hit
cookie += (K-fst_hit) % 2

print(cookie)


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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N; cin >> N;
    VI A(N); REP(i,N) cin >> A[i];
    SORT(A);
    int p = 0, n = 0;
    REP(i,N){
        if(A[i] < 0) n++;
        else p++;
    }
    vector<P> ans;
    int M;
    if(n == 0){
        int x = A[0], y;
        REP(i,p-2){
            y = A[i+1];
            ans.emplace_back(x,y);
            x -= y;
        }
        y = x;
        x = A[N-1];
        ans.emplace_back(x,y);
        M = x - y;
    }
    else if(p == 0){
        int x = A[N-1], y;
        REP(i,n-1){
            y = A[i];
            ans.emplace_back(x,y);
            x -= y;
        }
        M = x;
    }
    else{
        int x = A[0], y;
        REP(i,p-1){
            y = A[n+i];
            ans.emplace_back(x,y);
            x -= y;
        }
        y = x;
        x = A[N-1];
        ans.emplace_back(x,y);
        x -= y;
        REP(i,n-1){
            y = A[i+1];
            ans.emplace_back(x,y);
            x -= y;
        }
        M = x;
    }
    cout << M << endl;
    REP(i,N-1) cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

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

    int k;
    cin >> k;

    vector<int> a(k);
    REP(i, k) cin >> a[i];
    reverse(a.begin(), a.end());

    int l, r;
    l = r = 2;
    REP(i, k) {
        int val = a[i];
        int lt = (l + val - 1) / val * val;
        int rt = r / val * val;
        if (lt > r || rt < l) {
            cout << -1 << endl;
            return 0;
        }
        l = lt;
        r = rt + val - 1;
    }
    cout << l << " " << r << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }


int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector< vector<int> > A(N, vector<int>(M));
    vector<int> level(M);
    REP(i, N) {
        cin >> C[i];
        REP(j, M) {
            cin >> A[i][j];
            level[j] += A[i][j];
        }
    }

    REP(i, M) {
        if(level[i] < X) {
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 1e9;
    for(int bit=0; bit<(1<<N); ++bit) {
        int total = 0;
        vector<int> level_this(M);
        for(int i=0; i<N; ++i) {
            if(bit & (1<<i)) {
                total += C[i];
                for(int j=0; j<M; ++j) {
                    level_this[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for(int j=0; j<M; ++j) if(level_this[j] < X) ok = false;
        if(ok && total < ans) ans = total; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import numpy as np
import fractions

def main():
    abcd = list(map(int, input().split(' ')))
    al = abcd[1] - abcd[0] + 1
    cc = abcd[1] // abcd[2] - (abcd[0]-1) // abcd[2]
    dd = abcd[1] // abcd[3] - (abcd[0]-1) // abcd[3]
    skbs = (abcd[2] * abcd[3]) // fractions.gcd(abcd[2], abcd[3])
    dis = cc + dd - (abcd[1] // skbs - (abcd[0]-1) // skbs)
    print(int(al - dis))

if __name__ == "__main__":
    main()

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

using namespace std;

const int VALUE[] = {1, 5, 10, 50, 100, 500};
int coins[6];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    while(true) {
        int P;
        cin >> P;
        int max_val = 0;
        for(int i = 0; i < 6; ++i) {
            cin >> coins[i];
            max_val += VALUE[i] * coins[i];
        }
        if(!P) break;

        int ans = max_val;
        for(int total = P; total <= max_val; ++total) {
            int use_coins = 0;
            int tmp = total;
            for(int i = 5; i >= 0; --i) {
                const int cost = VALUE[i] * coins[i];
                if(cost <= tmp) {
                    use_coins += coins[i];
                    tmp -= cost;
                } else {
                    const int use = tmp / VALUE[i];
                    use_coins += use;
                    tmp -= VALUE[i] * use;
                }
                if(tmp == 0) break;
            }
            if(tmp != 0) continue; // Cannot make #{total} yen.
            int residue = total - P;
            for(int i = 5; i >= 0; --i) {
                use_coins += residue / VALUE[i];
                residue %= VALUE[i];
            }
            ans = min(ans, use_coins);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#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<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int z=1;
    string s;
    cin>>s;
    if(s.size()%2) z=0;
    rep(i,s.size()/2) if(!(s[2*i]=='h'&&s[2*i+1]=='i') ) z=0;
    if(z) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int N, s, d, t, s_, mx, i;
    std::cin >> N;
    
    while(N--){
        std::cin >> s >> d;

        t = 0;
        while(s != d){
            s_ = std::abs(s);
            mx = s_ & -s_;
            if(!s){mx = 1 << 30;}
            for(i=mx;;i/=2){
                if(s + i <= d){s += i; break;}
            }
            t++;
        }
        
        printf("%d\n", t);
    }
}

Measured memory_bytes: 1136
import qualified Data.Map as Map 

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  let l = list n
  let a = map (get l) s
  putStrLn a

listA :: String
listA = take 52 $  cycle ['A'..'Z']

listB :: Int -> String
listB n = drop n listA

list :: Int -> Map.Map Char Char
list a= Map.fromList . zip listA $ listB a

get :: Map.Map Char Char -> Char -> Char
get l k = Map.findWithDefault '0' k l 



Measured memory_bytes: 1404
#C問題

#計算量の意識(O(N^2)では間に合わない)
#合同式-あまりの計算の性質
#a≡b ならば、a + c ≡　b + c, a - c ≡　b - c , a * c ≡　b * c 　つまり和差積については途中であまりを取って計算可能

MOD = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

S = sum(A) % MOD

ans = 0

#MODはいちいち取る癖をつける
for x in A:
    S -= x
    S %= MOD
    ans += S * x
    ans %= MOD
    
#MODは必要以上に取りすぎてもOK 忘れないためにもう一度
ans %= MOD

print(ans)


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

int main()
{
    bool P = false;
    bool W = false;
    bool G = false;
    bool Y = false;

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if (s == "Y")
        {
            Y = true;
        }
    }

    if (Y)
    {
        cout << "Four" << endl;
    }
    else
    {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;


const int SIZE = 101;
int N, a[SIZE], r, frq[SIZE];

int main(void) {
  r = 0;
  REP(i, 1, SIZE) {
    frq[i] = 0;
  }

  cin >> N;
  REP(i, 1, N) {
    cin >> a[i];
    r = max(r, a[i]);
    frq[a[i]]++;
  }

  if(r % 2 == 0) {
    REP(i, r / 2 + 1, r) if((frq[i] -= 2) < 0) goto IMPOSSIBLE;
    if(--frq[r / 2] < 0) goto IMPOSSIBLE;
    REP(i, 1, r / 2) if(frq[i] > 0) goto IMPOSSIBLE;
    goto POSSIBLE;
  } else {
    REP(i, r / 2 + 1, r) if((frq[i] -= 2) < 0) goto IMPOSSIBLE;
    REP(i, 1, r / 2 + 1) if(frq[i] > 0) goto IMPOSSIBLE;
    goto POSSIBLE;
  }

POSSIBLE:
  cout << "Possible" << endl;
  return 0;

IMPOSSIBLE:
  cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
vi graph[5];
bool vis[5];
i64 coun=1;
bool flag;
void check(i64 i)
{
  if(flag)
  return;
  // cout<<i<<" ";
vis[i]=true;
for(auto j:graph[i])
{
  if(vis[j])
  continue;

  check(j);

}
flag=true;

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

    // ifstream fin(".in");
    // ofstream fout(".in");


forn(i,3)
{
  i64 from,to;
  cin>>from>>to;
  graph[from].pb(to);
  graph[to].pb(from);
}
bool is=true;
for1(i,4)
{flag=false;
  memset(vis,false,sizeof(vis));
  is=true;
check(i);
// cout<<"\n";
for1(j,4)
{
  if(vis[j]==false)
  is=false;
}
if(is)
{
  cout<<"YES";
  break;
}
}
if(!is)
cout<<"NO";

    return 0;
  }


Measured memory_bytes: 256
n = int(input())
ans  = [0 for i in range(10**5)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1

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

Measured memory_bytes: 73264
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	vector<int> v;
	int cnt=0;
	for(int test=1;test<=64;test++)
	{
		int low=0,high=9;
		if(test==1)
		{
			low=1;
		}
		while(low<high)
		{
			cnt++;
			//cout<<low<<" "<<high<<"\n";
			int mid=low+((high-low)/2);
			vector<int> vv=v;
			vv.pb(mid);
			while(vv.size()!=11)
			{
				vv.pb(9);
			}
			ll num=0;
			for(int i=0;i<vv.size();i++)
			{
				//cout<<vv[i]<<" ";
				num=(num*10ll)+vv[i];
			}
			//cout<<"\n";
			char ch;
			cout<<'?'<<' '<<num<<endl;
			cin>>ch;
			//cout<<ch<<"\n";
			if(ch=='Y')
			{
				high=mid;
			}
			else
			{
				low=mid+1;
			}
		}
		if(low==0)
		{
			cnt++;
			vector<int> vv=v;
			vv.pb(0);
			while(vv.size()!=11)
			{
				vv.pb(0);
			}
			ll num=0;
			for(int i=0;i<vv.size();i++)
			{
				num=(num*10ll)+vv[i];
			}
			char ch;
			cout<<'?'<<' '<<num<<endl;
			cin>>ch;
			if(ch=='Y')
			{
				break;
			}
			else
			{
				v.pb(low);
			}
		}
		else
		{
			v.pb(low);
		}
	}
	vector<int> v1;
	v1.pb(1);
	while(1)
	{
		if(v1.size()>10)
		{
			break;
		}
		cnt++;
		vector<int> vv=v1;
		ll num=0;
		for(int i=0;i<vv.size();i++)
		{
			num=(num*10ll)+vv[i];
		}
		char ch;
		cout<<'?'<<' '<<num<<endl;
		cin>>ch;
		if(ch=='Y')
		{
			v1.pb(0);
		}
		else
		{
			v1.pop_back();
			break;
		}
	}
	if(v1.size()>10)
	{
		v1.clear();
		v1.pb(9);
		while(1)
		{
			ll num=0;
			for(int i=0;i<v1.size();i++)
			{
				num=num*10;
				num+=v1[i];
			}
			char ch;
			cout<<'?'<<' '<<num<<endl;
			cin>>ch;
			if(ch=='Y')
			{
				break;
			}
			else
			{
				v1.pb(9);
			}
		}
		while(v.size()!=v1.size())
		{
			v.pb(0);
		}
		ll ans=0;
		for(int i=0;i<v.size();i++)
		{
			ans=(ans*10)+v[i];
		}
		cout<<'!'<<' '<<ans<<endl;
		return 0;	
	}
	int len=v1.size();
	while(v.size()!=len)
	{
		v.pb(0);
	}
	ll ans=0;
	for(int i=0;i<v.size();i++)
	{
		ans=(ans*10)+v[i];
	}
	cout<<'!'<<' '<<ans<<endl;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  bool n1=false;
  bool n2=false;
  bool n3=false;
  bool n4=false;
  for(int i=0;i<4;i++){
    cin>>a;
    if(a==1)n1=true;
    else if(a==9)n2=true;
    else if(a==7)n3=true;
    else if(a==4)n4=true;
  }
  if(n1==true&&n2==true&&n3==true&&n4==true)
    cout<<"YES";
  else cout << "NO";
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define rep(i,n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	ll N,K;
	cin >> N >> K;
	ll M=N;
	ll A=K;
	ll i=1;
	while(M>=A){
		A*=K;
		i++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll p=1000000000+7;
  ll n,k;
  cin>>n>>k;
  if(n>8||k>8){cout<<":("<<endl;}
  else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
import itertools

n = int(input())
pn = tuple(map(int, input().split()))
qn = tuple(map(int, input().split()))

n_list = list(range(1, n+1))
counter = 1

for i in itertools.permutations(n_list, n):
  if pn == i:
    a = counter
  if qn == i:
    b = counter
  counter += 1
  
print(abs(a-b))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    int a[m];
    for(int i = 0; i < m; ++i) cin >> a[i];
    sort(a, a + m);
    
    int s[m];
    for(int i = 0; i < m; ++i) {
        if(i) s[i] = a[i] - a[i - 1];
        else s[i] = 0;
    }
    sort(s, s + m);

    int ans = 0;
    for(int i = 0; i <= m - n; ++i) {
        ans += s[i];
    }

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



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    string S[110];
    rep(i, N) cin >> S[i];
    sort(S, S + N);
    string T;
    rep(i, N) T += S[i];
    cout << T << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b){
	return b != 0 ? gcd(b, a%b) : a;
}

int lcm(int a, int b){
	return a*b / gcd(a, b);
}

#define N_MAX 200000
#define MOD 1000000007

int N;
bool func(int width, int pos, char *S, char *T)
{
	int left = 1, right = width;

	for (int i = N - 1; i >= 0; i--){
		if ('L' == T[i]){
			right = min(width, right + 1);
		}
		else if ('R' == T[i]){
			left = max(1, left - 1);
		}

		if ('L' == S[i]){
			left++;
		}
		else if ('R' == S[i]){
			right--;
		}
		if (left > right){
			return false;
		}
	}

	if (left <= pos && pos <= right){
		return true;
	}
	return false;
}

void change(char *S)
{
	for (int i = 0; i < N; i++){
		if ('L' == S[i]){
			S[i] = 'U';
		}
		else if ('R' == S[i]){
			S[i] = 'D';
		}
		else if ('U' == S[i]){
			S[i] = 'L';
		}
		else if ('D' == S[i]){
			S[i] = 'R';
		}
	}

	return;
}

void solv()
{
	char S[N_MAX]; scanf("%s", S);
	int len = strlen(S);
	int cnt = 0; lli ret = 0;
	for (int i = 0; i < len; i++){
		if ('A' == S[i]){
			cnt++;
		}
		else if ('B' == S[i]){
			if ('C' == S[i + 1]){
				ret += (lli)cnt;
				i++;
			}
			else{
				cnt = 0;
			}
		}
		else if ('C' == S[i]){
			cnt = 0;
		}
	}

	printf("%lld", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	string t=s;
	reverse(all(t));
	if(s!=t){
		cout<<"No"<<endl;
		return 0;
	}
	int a=(n-1)/2;
	int b=(n+3)/2-1;
	string k,l;
	rep(i,0,a){
		k.push_back(s[i]);
	}
	rep(i,b,n){
		l.push_back(s[i]);
	}
//	cout<<k<<endl<<l<<endl;
	if(k==l)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3600
def comb(n, r):
    if r<0 or r>n:
        return 0
    r=min(r, n-r)
    return g1[n]*g2[r]*g2[n-r]%MOD

MOD=10**9+7
MAXN=4000+10
g1=[1, 1]
g2=[1, 1]
inverse=[0, 1]

for i in range(2, MAXN+1):
    g1.append((g1[-1]*i)%MOD)
    inverse.append(-inverse[MOD%i]*(MOD//i)%MOD)
    g2.append((g2[-1]*inverse[-1])%MOD)

def f(n, k):
    if n<k:
        return 0
    if n==0 and k==0:
        return 1
    if k<1:
        return 0
    return f2(n-k, k)

def f2(n, k):
    return comb(n+k-1, k-1)

N, K=map(int, input().split())
for i in range(1, K+1):
    b=f(K, i)
    r=f(N-K, i-1)+2*f(N-K, i)+f(N-K, i+1)
    print((b*r)%MOD)

Measured memory_bytes: 43760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  print(max({a+b,a+a-1ll,b+b-1ll}));
  return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"math/bits"
	"os"
	// "strconv"
	// "strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	var n int
	fmt.Scanf("%d", &n)
	max := uint32(1)
	for i := 0; i < n; i++ {
		max = max * 2
	}

	for i := uint32(0); i < max; i++ {
		con.Printf("%d:", i)
		begin := bits.TrailingZeros32(i)
		end := bits.LeadingZeros32(i)
		for j := begin; j < 32-end; j++ {
			//fmt.Printf("%d & 1<<%d (%d)\n",i, j, (i & (1 << uint32(j))))
			if 0 < (i & (1 << uint32(j))) {
				con.Printf(" %d", j)
			}
		}
		con.Println("")
	}

}



Measured memory_bytes: 6136
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r;

        while((r = x % y) != 0){
            x = y;
            y = r;
        }

        System.out.println(y);
    }
}


Measured memory_bytes: 26412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;

const int mod = 1000003;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<mint> prod(mod), prodinv(mod);
    prod[0]=1;
    prodinv[mod-1]=-1;
    rep2(i,1,mod)prod[i]=prod[i-1]*i;
    //rep2(i,1,mod)prodinv[mod-i-1]=mint(mod-i)*prodinv[mod-i];
    rep2(i,0,mod)prodinv[i]=prod[i].inv();
    ll q;cin>>q;
    rep(i,q){
        ll x,d,n;cin>>x>>d>>n;
        mint mx=mint(x),md=mint(d);
        if(d==0){cout<<mx.pow(n).x<<endl;continue;}
        mint l = mx/md;
        mint r = (mx+md*(n-1))/md;
        if(n>=mod||r.x<l.x){cout<<0<<endl;continue;}
        cout<<(prod[r.x]*prodinv[l.x-1]*md.pow(n)).x<<endl;

    }
    return 0;
}

Measured memory_bytes: 16512
#include<stdio.h>
#include<string.h>
using namespace std;

int f_min(int a, int b){
	return a > b ? b : a;
}

int f_max(int a, int b){
	return a < b ? b : a;
}

int main(){
	int A, B, C, X, Y, ans;
	scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
	
	int op1 = X*A + Y*B;
	int op2 = 2*C*f_max(X, Y);
	int op3;
	if(X>Y){
		op3 = 2*C*Y + ((X-Y)*A);
	} else op3 = 2*C*X + ((Y-X)*B);


	ans = f_min(f_min(op1, op2), op3);
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int H, W; cin >> H >> W;
    char s[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s[i][j];
        }
    }
    bool can = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '.') continue;

            bool f = false;
            if (i != 0)   f |= s[i-1][j] == '#';
            if (i != H-1) f |= s[i+1][j] == '#';
            if (j != 0)   f |= s[i][j-1] == '#';
            if (j != W-1) f |= s[i][j+1] == '#';

            can &= f;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

bool can_divide(const vector<i64>& v, i64 k, i64 val) {
    for (i64 l : v) {
        if (l > val)
            k -= (l/val);
        if (k < 0) return false;
    }
    return true;
}

int main(int argc, char **argv) {
    i64 n, k;
    cin >>n >> k;
    vector<i64> v(n, 0);

    i64 v_sum{0};
    for(i64 i=0; i<n; ++i) {
        cin >> v[i];
        v_sum += v[i];
    }

    sort(v.begin(), v.end(), greater<i64>());

    i64 left{0}, right{1000000001};
    while (right - left > 1) {
        //cout << left << " "<< right << endl;
        i64 mid = (left+right) / 2;
        if (can_divide(v, k, mid)) right = mid;
        else left = mid;
    }

    cout << right << endl;
    return 0;
}


Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin>>n)
    {
        string a;
        cin>>a;
        if(n&1)
        {
            cout<<"No"<<endl;
        }
        else
        {
            string t1="";
            string t2="";
            for(int i=n/2;i<n;i++)
            {
                t1=t1+a[i];
            }
            for(int i=0;i<n/2;i++)
            {
                t2=t2+a[i];
            }
            if(t1==t2)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string convert_str(int n){
   string str;
   stringstream ss;
   ss << n;
   ss >> str;
   return str;
}

string convert_nb(int n, int negBase){

   if (n == 0)
      return "0";
   string converted = "";
   while (n != 0){

      int remainder = n % negBase;
      n /= negBase;

      if (remainder < 0) {
         remainder += (-negBase);
         n += 1;
      }

      converted = convert_str(remainder) + converted;
   }
   return converted;
}
int main() {
   ll n;
   cin>>n;
   int negBase = -2;
   cout << convert_nb(n, negBase)<<endl;
   return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc112/tasks/abc112_d
require 'prime'
N, M = gets.split.map(&:to_i)
m = M
ary = []

# https://qiita.com/seinosuke/items/fde2e0471dcf937e5a09
class Integer
  def my_divisor_list3
    return [1] if self == 1
    first, *rest = Prime.prime_division(self).map do |p, k|
      (0..k).map{|i| p**i}
    end
    first.product(*rest).map do |a|
      a.inject(&:*)
    end.sort
  end
end

p M.my_divisor_list3.select { |i| i <= M/N }.max

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll mod = 1e9+7;

int main() {
	ll t,d,s;
	cin>>d>>t>>s;
	if(s*t >= d)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, a;
	cin >> x >> a;
	
	if (x < a) cout << 0 << endl;
	else cout << 10 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using ll = long long;

int main() {
    int N; std::cin >> N;
    std::vector <std::pair<int, int>> W(N);

    for (int i=0; i < N; i++) {
        int A, B;
        std::cin >> A >> B;
        W[i] = std::make_pair(B, A);
    }
    std::sort(W.begin(), W.end());

    ll cumTime = 0;
    for (auto e : W) {
        cumTime += e.second;
        if (cumTime > e.first) {
            std::cout << "No\n";
            return 0;
        }
    }
    std::cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   int x; cin >> x;
   if(x<1200){
           cout << "ABC" << endl;
   }
   else if(x<2800){
          cout << "ARC" << endl;
   }
   else{
         cout << "AGC" << endl;
   }
}

Measured memory_bytes: 256
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 079C」Cat Snuke and a Voyage 26-08-2017
 *
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace {

const int MAXN = 200000;
bool vis[MAXN + 1];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n, m, u, v;
    for (std::cin >> n >> m; m--;) {
        std::cin >> u >> v;
        if (u == 1) {
            if (vis[v]) std::cout << "POSSIBLE", exit(0);
            vis[v] = true;
        } else if (v == n) {
            if (vis[u]) std::cout << "POSSIBLE", exit(0);
            vis[u] = true;
        }
    }
    std::cout << "IMPOSSIBLE";
}
}

int main() {
    solve();
    return 0;
}

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

int main(){

    int t, i, j, b, h=0;
    cin >> t ;
    int a[t];

    for(i=1; i<=t; i++){
        cin >> a[i] ;
    }
    for(j=1; j<=t; j++){
        if(a[j]!=j){
           h++;
        }
    }
    if(h<=2){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string sta;
    cin >> sta;

    if(sta[0] == sta[1] && sta[1] == sta[2]){
        cout << "No";
    }
    else{
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
v = gets.split.map(&:to_i)

v1, v2 = Hash.new(0), Hash.new(0)
 
v.each_slice(2) do |a, b|
    v1[a] += 1
    v2[b] += 1
end
 
a1, a2 = v1.sort_by(&:last).reverse.take(2)
b1, b2 = v2.sort_by(&:last).reverse.take(2)

if a1[0] == b1[0] then
    puts n - [a1[1] + (b2 ? b2[1] : 0), (a2 ? a2[1] : 0) + b1[1]].max
else
    puts n - a1[1] - b1[1]
end

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

int main(){
  int A, B;
  cin >> A >> B;
  
  string ans;
  
  if(A == 1 && B == 1){
    ans = "Draw";
  }
  else if(A == 1){
    ans = "Alice";
  }
  else if(B == 1){
    ans = "Bob";
  }
  else if(A == B){
    ans = "Draw";
  }
  else if(A > B){
    ans = "Alice";
  }
  else if(A < B){
    ans = "Bob";
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    let lines = input.split(/\n/);
    const [n, d] = lines.shift().split(/\s/);
    const points = lines.slice(0, n).map(line => line.split(/\s/).map(v => +v));

    const d2 = d*d;
    let count = 0;
    for (const point of points) {
        if(d2 >= point[0] * point[0] + point[1] * point[1]){
            count++;
        }
    }
    console.log(count);
})()


Measured memory_bytes: 98116
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; cin >> N;
string s;
long ans=0;
map<string, int> ana;
for(int i=0; i<N; i++){
  cin >> s; sort(s.begin(), s.end());
  ans+=ana[s]; ana[s]++;
}
cout << ans << "\n";
}


Measured memory_bytes: 11264
#include<stdio.h>
int n,m,x,min=1000000007;
int book[105][105],learn[105];
void make(int i,int fall,int money){
	if(fall==m){
		if(money<min) min=money;
		return ;
	}
	if(i==n+1) return ;
	make(i+1,fall,money);
	int f[105];
	for(int j=1;j<=m;j++) f[j]=learn[j];
	for(int j=1;j<=m;j++){
		if(learn[j]>=x) continue; 
		learn[j]+=book[i][j];
		if(learn[j]>=x) fall++;
	}
	money+=book[i][m+1];
	make(i+1,fall,money);
	for(int j=1;j<=m;j++) learn[j]=f[j];
}
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&book[i][m+1]);
		for(int j=1;j<=m;j++) scanf("%d",&book[i][j]);
	}
	make(1,0,0);
	printf("%d",min!=1000000007?min:-1);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	vector<pair<int, int>> v(n);
	for(int i = 0; i < n; ++i) cin>>v[i].second>>v[i].first;
	sort(v.begin(), v.end());
	bool ok = true;
	ll curr = 0;
	for(auto x : v){
		curr += x.second;
		ok &= (curr <= x.first);
	}
	cout<<(ok?"Yes":"No");
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
   ll N;
   cin>>N;
   vector<ll>A(N);
   ll ans=1;
   ll q=1;
   rep(i,N){
       cin>>A[i];
       ans*=3;
       if(A[i]%2==1){
           q*=1;
       }
       else{
           q*=2;
       }
   }
   cout<<ans-q<<endl;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
   string S;
   cin >> S;
   int sum_b = 0, sum_r = 0;
   for(char x : S){
       if(x == '0') sum_r++;
       if(x == '1') sum_b++;
   }
   cout << min(sum_r, sum_b) * 2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int dp[n] = {0};
	dp[0] = 0;
	for(int i = 1; i < n; ++i) {
		dp[i] = INT_MAX;
		for(int j = i - 1, it = 0; it < k && j >= 0; --j, ++it) {
			dp[i] = min(
				dp[i],
				dp[j] + abs(a[i] - a[j]));
		}
	}
	cout<<dp[n - 1];
}

Measured memory_bytes: 4388
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
map<int, int>mp;
int s[105],ans;
signed main() {	
	int n;
	cin >> n;
	loop(i, 2, n) {
		if (!prime(i))continue;
		int a = n, cnt = 0;
		while (a) {
			cnt += a / i;
			a /= i;
		}
		mp[cnt]++;
	}
	for (int i = 100; i >= 2; i--) {
		s[i] = mp[i] + s[i + 1];
	}
	ans += s[74];
	ans += s[24] * (s[2] - 1);
	ans += s[14] * (s[4] - 1);
	ans += (s[4] * (s[4] - 1)) / 2 * (s[2] - 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
const int M = 1000005;
int a[M] = {0};
using namespace std;
int main(){
	int time=0,n,x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a[x]++;
		if(a[x]>time) time = a[x];
		a[x-1]++;
		if(a[x-1]>time) time = a[x-1];
		a[x+1]++;
		if(a[x+1]>time) time = a[x+1];
	}
	cout<<time;
} 

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int a, b;
  cin >> a >> b;
  int s = ceil(a * 1.0 / 0.08);
  int t = ceil(b * 1.0 / 0.1);
  int x = (s * 0.1);
  int y = (t * 0.08);
  if (x == b)
  {
    cout << s << endl;
  }
  else if (y == a)
  {
    cout << t << endl;
  }
  else
  {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] input2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int H = input1[0];
            int W = input1[1];
            int h = input2[0];
            int w = input2[1];
            Console.WriteLine((H - h) * (W - w));
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a = list(map(int,input().split()))
x = [0]*n
s = sum(a)
sA = 0
for i in range(1,n,2):
    sA += a[i]
x[0] = s - 2*(sA)
print(x[0],end = " ")
for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]
    print(x[i+1],end = " ")


Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    float d,t,s;
    cin>>d>>t>>s;
    float k;
    k=d/s;
    if(k<=t)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}
 

Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            ArrayList<Integer> list=new ArrayList<>();
            int n=Integer.parseInt(br.readLine());
            String str=br.readLine();
            String[] ss=str.split(" ");
            for(int i=0;i<ss.length;i++){
                list.add(Integer.parseInt(ss[i]));
            }
            Collections.sort(list);
            int meals=0;
            for(int i=1;i<list.size();i+=2){
                meals+=Math.min(list.get(i),list.get(i-1));
            }
            System.out.println(meals);
        }catch(Exception e){

        }

    }

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vll water(31, 0), sugar(3001, 0);
    REP(i, 31){
        REP(j, 31){
            if(a * i + b * j > 30) continue;
            water[a * i + b * j] = 1;
        }
    }
    REP(i, f + 1){
        REP(j, f + 1){
            if(c * i + d * j > 3000) continue;
            sugar[c * i + d * j] = 1;
        }
    }
    ll resw = 1, ress = 0;
    FOR(i, 1, 30){
        FOR(j, 1, 3000){
            if(!water[i] || !sugar[j]) continue;
            ll w = 100 * i, s = j;
            if(w + s > f || s > e * i) continue;
            if(s * (resw + ress) > ress * (w + s)){
                resw = w;
                ress = s;
            }
        }
    }
    if(resw == 1){
        cout << a * 100 << " " << 0 << endl;
        return 0;
    }
    cout << resw + ress << " " << ress << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int a,b;
  cin >> a >>b;
  int ans=-1000000;
  ans=max({a+b,a-b,a*b});
  cout << ans << endl;
}

Measured memory_bytes: 3508
from fractions import gcd


def main():
    n, k = [int(x) for x in raw_input().split()]
    a = [int(x) for x in raw_input().split()]
    if k > max(a):
        return False
    g = a[0]
    for ai in a[1:]:
        g = gcd(g, ai)
    return k % g == 0


if __name__ == '__main__':
    print("POSSIBLE" if main() else "IMPOSSIBLE")


Measured memory_bytes: 13116
#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

int main(){
  ll n;
  cin >> n;
  ll t[n+1], x[n+1], y[n+1], sa;
  rep(i, n){
    cin >> t[i] >> x[i] >> y[i];
  }
  if (t[0] < x[0]+y[0]) {
    puts("No")
    exit(0);
  }

  FOR(i, 1, n){
    sa = abs( (x[i]+y[i]) - (x[i-1]+y[i-1]) );
    if (t[i]-t[i-1] < sa ) {
      puts("No")
      exit(0);
    }
    if ( (t[i]-t[i-1])%2 == 1  && sa%2 == 0 ) {
      puts("No")
      exit(0);
    }
    if ( (t[i]-t[i-1])%2 == 0  && sa%2 == 1 ) {
      puts("No")
      exit(0);
    }
  }
  puts("Yes")
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    int ans = 0;
    ans += a[2] - a[1];
    a[0] += ans;
    if ((a[2] - a[0]) % 2 == 0){
        ans += (a[2] - a[0]) / 2;
    }else{
        ans += (a[2] - a[0]) / 2 + 2;
    }
    cout << ans << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	//int limit=200001;
	
	long long  n;
	cin>>n;
	long long  a[n];
	for(long long  i=0;i<n;i++){
		cin>>a[i];
	}
	long long  freq[n]={0};
	for(long long  i=0;i<n;i++){
		if(i+1+a[i]<=n-1){
			freq[i+1+a[i]]++;
		}
	}
	long long  count=0;
	for(long long  i=0;i<n;i++){
		if(i+1-a[i]>0){
			count+=freq[i+1-a[i]];
			}
		}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 6756
#include<iostream>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	if((A==5)&&(B==5)&&(C==7))
	{
		cout<<"YES"<<"\n";
	}
	else if((A==5)&&(C==5)&&(B==7))
	{
		cout<<"YES"<<"\n";
	}
	else if((A==7)&&(B==5)&&(C==5))
	{
		cout<<"YES"<<"\n";
	}
	else 
	{
		cout<<"NO"<<"\n";
	}
	return 0;
}

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

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

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256