akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    vi a(5);
    cin>>a;
    for(ll i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1<<nl;
        }
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  string ans="No";
  cin >> S >> T;
  string a,b;
  int s=S.size();
  int i,j,n,q;
  for(i=0;i<s;i++){
    a="";
    for(j=i;j<s;j++){
      a+=S.at(j);}
    for(n=0;n<i;n++){
      a+=S.at(n);}
    if(a==T){ans="Yes";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef pair<int, int> P;

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

int d[1003][1003];

int main()
{
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    string s[1003];
    for(int i = 0; i < h; i++) cin >> s[i];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) d[i][j] = -1;
    }
    d[ch][cw] = 0;
    queue<P> que[2];
    que[0].push(P(ch, cw));
    for(int i = 0; i < h * w; i++){
        while(que[i % 2].size()){
            P p = que[i % 2].front();
            que[i % 2].pop();
            int x = p.first, y = p.second;
            if(d[x][y] < i) continue;
            for(int j = 0; j < 4; j++){
                int u = x + dx[j], v = y + dy[j];
                if(u >= 0 && u < h && v >= 0 && v < w && s[u][v] == '.' && (d[u][v] == -1 || d[u][v] > i)){
                    d[u][v] = i;
                    que[i % 2].push(P(u, v));
                }
            }
            for(int j = -2; j <= 2; j++){
                for(int k = -2; k <= 2; k++){
                    int u = x + j, v = y + k;
                    if(u >= 0 && u < h && v >= 0 && v < w && s[u][v] == '.' && d[u][v] == -1){
                        d[u][v] = i + 1;
                        que[(i + 1) % 2].push(P(u, v));
                    }
                }
            }
        }
    }
    cout << d[dh][dw] << endl;
}


Measured memory_bytes: 9408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	if(x >= 30){
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3656
import math
from numba import jit

k = int(input())

@jit
def ans():
    sum = 0
    for l in range(1,k+1):
        for m in range(1,k+1):
            for n in range(1,k+1):
                sum += math.gcd(math.gcd(l,m),n)
    return(sum)
print(ans())

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

void print(int a, int b){
	cout << endl;
	for(int i = 0;i < a;i++)cout << " ";
	for(int i = a;i < b;i++)cout << "^";
}

int main(){
	int p, q;
	while(cin >> p >> q){
		map<int, int> m;
		int cnt = 0;
		bool f = false;
		while(1){
			int a = p/q;
			int b = p%q;
			p = b * 10;
			if(f)cout << a;
			f = true;
			if(!b)break;
			
			if(!m[b])m[b] = ++cnt;
			else {print(m[b]-1, cnt);break;}
		}
		cout << endl;
	}
	return 0;
}

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

int v[25],c[25];

int main()
{
	int n,total=0;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>v[i];
	for (int i=1;i<=n;i++)  cin>>c[i];
	for (int i=1;i<=n;i++)
	{
		if (v[i]-c[i]>0)  total+=v[i]-c[i];  
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def intersection(I1, I2):
    left = max(I1[0], I2[0])
    right = min(I1[1], I2[1])
    return [left, right]


n = int(input())
A = list(map(int, input().split()))

if A[0] != 0:
    if n == 0 and A[0]==1:
        print(1)
    else:
        print(-1)
    sys.exit()

P = []

P.append([1,1])

for i in range(n):
    left = P[i][0]-A[i+1]
    right = 2*P[i][1]-A[i+1]
    P.append([left, right])

#print("Forward check")
#print(P)

if 0 < P[n][0] or P[n][1] < 0:
    print(-1)
    sys.exit()

P[n] = [0,0]
for i in reversed(range(n)):
    left = A[i+1]+P[i+1][0]
    left = -(-left//2)
    right = A[i+1]+P[i+1][1]
    P[i] = intersection(P[i], [left, right])
#print("Backward check")
#print(P)

ans = 0
for i in range(n+1):
    ans += P[i][1] + A[i]

print(ans)

Measured memory_bytes: 723532
// abc174_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int K;
    cin >> K;
    vector<int> v(1e6);

    ll d = 0;
    int ans = -1;
    REP(i, 2e6){
        d = (d * 10 + 7) % K;
        if (d == 0){
            ans = i+1;
            break;
        }
        if (v[d] == 1){
            break;
        }
        v[d] = 1;
    }
    print(ans);


    return 0;
}


Measured memory_bytes: 7152
#include <stdio.h>

int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  if(A<B){
    A^=B;
    B^=A;
    A^=B;
  }
  if(A==B) printf("%d\n",2*A);
  else printf("%d\n",2*A-1);
  return 0;
}

Measured memory_bytes: 128
S = input()
T = input()
ls = len(S)
lt = len(T)

S = S[::-1]
T = T[::-1]

ans = 'UNRESTORABLE'

if ls < lt:
    print(ans)
    exit()

i = 0
while i < ls - lt + 1:
    tmp = ''
    for j in range(lt):
        if S[i + j] == T[j] or S[i + j] == '?':
            tmp += S[i + j]
        else:
            break
    if len(tmp) == lt:
        ans = S.replace(tmp, T, 1)
        ans = ans.replace('?', 'a')
        print(ans[::-1])
        exit()
    i += 1

print(ans)


Measured memory_bytes: 62048
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define M 100010


int main(){
	IOS;
	tihs;
	
	
	ll k;cin>>k;
	ll ans=0;
	rep(i,1,k+1)rep(j,1,k+1)rep(l,1,k+1){
		ll x=__gcd(i,__gcd(j,l));
		ans+=x;
	}
	cout<<ans;
	return 0;
}

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

int main(){
    string lookingfor;
    string ring;
    int ans = 0;
    
    int n;
    cin >> lookingfor;
    cin >> n;

    for (int i = 0; i < n; i++){
	cin >> ring;
	ring += ring;
	if (ring.find(lookingfor, 0) != string::npos) ans++;
    }
    
    cout << ans << endl;
}

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

using namespace std;

bool solve(const vector<string>& w)
{
	const int n = w.size();

	for (int i = 0; i < n - 1; i++)
	{
		if (w.at(i).back() != w.at(i + 1).front())
		{
			return false;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (w.at(i) == w.at(j))
			{
				return false;
			}
		}
	}
	return true;
}

vector<string> input()
{
	int n;	cin >> n;
	vector<string> w(n);
	for (int i = 0; i < n; i++)
	{
		cin >> w.at(i);
	}
	return w;
}

int main()
{
	const vector<string> w = input();
	if (solve(w))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}


Measured memory_bytes: 256
import math


# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, x = invr()

a = inlist()
a = sorted(a)
c = 0
for i in a:
    if i <= x:
        c += 1
        x -= i
    else:
        x = 0

if x > 0 and c > 0:
    c -= 1
print(c)


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
monst = 0
C = A[N]
R = B[N-1] - C
R = max(R,0)
monst += B[N-1] - R
if N > 1:
    for i in range(N-1,0,-1):
        C = A[i]
        Q = R - C
        Q = max(Q,0)
        monst += R - Q
        P = max(0,C-R+Q)
        R = B[i-1] - P
        R = max(R,0)
        monst += B[i-1] - R
    monst += min(A[0],R)
print(monst)

Measured memory_bytes: 19284
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int x = lower_bound(all(a), l) - a.begin();
		int y = upper_bound(all(a), r) - a.begin();
		cout << y - x << endl;
	}
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    ll n,m;
    cin >> n >> m;

    ll cnt;

    //単純にSの数だけやってみる
    /**
    for(int i=0; i<n; i++){
        if(m < 2) break;
        m -= 2;
        cnt++;
    }

    //4つ以上ならまだ作れる
    if(m >= 4){
        while(m >= 4){
            m -= 4;
            cnt++;
        }
    }

     **/
    if(2*n <= m){
        // n個分つくることができるとき(あまりができる)..のこりmのあまった分
        cnt = n;
        m -= 2*n;

        if(m >= 4){
            //4つ以上の分でつくる
            cnt += m/4;
        }
    }else{
        //あまりができない(n個にたりない)
        cnt += m/2;
    }


    cout << cnt << endl;


}

Measured memory_bytes: 256
//c.c C-Skip
#include<stdio.h>
#include<stdlib.h>
typedef long long lld;

lld gcd(lld a,lld b){
    if(a==b){
        return a;
    }else if(a>b){
        return gcd(a-b,b);
    }else{
        return gcd(a,b-a);
    }
}

int cmp(const void *a,const void *b){
    if(*(lld*)a<*(lld*)b){
        return -1;
    }else{
        return 1;
    }
    return 0;
}

lld iabs(lld a){
    if(a>0){
        return a;
    }
    return -a;
}


int main(void){
    lld n,x;
    scanf("%lld %lld",&n,&x);
    lld ix[n+1];
    for(int i=0;i<n;++i){
        scanf("%lld",&ix[i]);
    }
    ix[n] = x;

    if(n==1){
        printf("%lld\n",iabs(ix[0]-ix[1]));
        return 0;
    }
    qsort(ix,n+1,sizeof(lld),cmp);

    lld iy[n];
    for(int i=0;i<n;++i){
        iy[i] = ix[i+1] - ix[i];
    }

    lld gg = gcd(iy[0],iy[1]);

    for(int i=2;i<n;++i){
        gg = gcd(gg,iy[i]);
    }
    printf("%lld\n",gg);
    return 0;
}

Measured memory_bytes: 1788
// ------------------------------------
// Date:2018/ 2/24
// Problem:AGC 002 KnotPuzzle c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

#define MOD 1000000007

int main()
{
  int N,L,sum;
  cin >> N >> L;
  vector<int> a(N);
  REP(i,N) cin >> a[i];
  
  // a[i]+a[i+1]>=Lの時にPossible
  REP(i,N-1) {
    if (a[i]+a[i+1]>=L) {
      cout << "Possible" << endl;
      FOR(j,1,i+1) cout << j << endl;
      RFOR(j,i+1,N) cout << j << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
  return 0;
}



Measured memory_bytes: 1152
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    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^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int N;
int D[100000];
int cnt[100000] ={};

signed main(){
    cin >> N;
    rep(i, N) cin >> D[i];
    if(D[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1; i<N; i++){
        if(D[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    sort(D, D+N);

    cnt[0] = 1;
    mint<MOD> ans = 1;
    for(int i=1; i<N; i++){
        ans *= cnt[D[i]-1];
        cnt[D[i]]++;
    }
    cout << ans << endl;
}

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


int main(){
  int x,y;
  cin>>x>>y;
  char cl[x][y];
  int t[x][y];
  for(int i=0;i<x;i++){
    for(int o=0;o<y;o++){
      cin>>cl[i][o];
      if(cl[i][o]=='c'){t[i][o]=0;}
      else{t[i][o]=-1;}
    }
  }

    for(int i=0;i<x;i++){
      for(int o=0;o<y;o++){
	if(t[i][o]==0){
	  for(int m=1;o+m<y;m++){
	    if(t[i][o+m]==0){o+=m-1; break;}
	    t[i][o+m]=m;
	  }
	}
      }
    }


    for(int i=0;i<x;i++){
      for(int o=0;o<y;o++){
	cout<<t[i][o];
	if(o!=y-1){cout<<" ";}
      }
      cout<<endl;
    }
  
  return 0;
}



Measured memory_bytes: 3124
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetlli tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;
 
/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
    lli res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        //y must be even now
        y=y>>1; //y=y/2
        x=(x*x)%p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n;
 cin>>n;
 lli a[n];
 forz(i,n)cin>>a[i];
 lli dp[n][n]={0};
 for(int l=n-1;l>=0;l--)
 {
   for(int r=l;r<n;r++)
   {
     if(l==r)dp[l][r]=0;
     else
     {
       dp[l][r]=1e18+5;
       lli s=0;
       for(int i=l;i<=r;i++)s+=a[i];
       for(int i=l;i<=r-1;i++)
       {
         dp[l][r]=min(dp[l][r],dp[l][i]+s+dp[i+1][r]);
       }
     }
   }
 }
 cout<<dp[0][n-1];
 return 0;
}


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

int main(void){
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0; i < n; ++i){
		cin >> s[i];
	}
	long long ans = 0LL;
	int a = 0, b = 0, ab = 0;
	for(int i = 0; i < n; ++i){
		if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A'){
			ab++;
		}else if(s[i][0] == 'B'){
			b++;
		}else if(s[i][s[i].size()-1] == 'A'){
			a++;
		}
		for(int j = 0; j < s[i].size()-1; ++j){
			if(s[i][j]=='A' && s[i][j+1] == 'B'){
				ans++;
			}
		}
	}
	if(ab>=1){
		ans += ab-1;
		if(a>=1){
			ans++;
			a--;
		}
		if(b>=1){
			ans++;
			b--;
		}
	}
	ans += min(a,b);
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

void ask(string s) {
    cout << "? " << s << endl;
}

bool get() {
    char c;
    cin >> c;
    return c == 'Y';
}

void append(string& s) {
    for (int i = 0; i < 9; i++) {
        s += '9';
    }
}

string ans = "";
int digit;

void checkdigit() {
    string s = "1";
    for (int i = 0; i < 10; i++) {
        ask(s);
        if (!get()) {
            digit = i;
            return;
        }
        s += '0';
    }
}

void checkdigit2() {
    string s = "";
    for (int i = 0; i < 10; i++) {
        s += '9';
    }
    for (int i = 0; i < 10; i++) {
        ask(s);
        if (!get()) {
            digit = 10 - i;
            return;
        }
        s.pop_back();
    }
}

int main() {
    checkdigit();
    if (digit == 0) {
        checkdigit2();
        ans = "1";
        for (int i = 0; i < digit; i++) {
            ans += '0';
        }
        cout << "! " << ans << endl;
        return 0;
    }
    for (int i = 0; i < digit; i++) {
        if (i == 0) {
            string t(ans);
            t += '1';
            append(t);
            ask(t);
            if (get()) {
                ans += '1';
                continue;
            }
            int l = 1, r = 9;
            while (l < r - 1) {
                int m = (l + r) / 2;
                t = string(ans);
                t += '0' + m;
                append(t);
                ask(t);
                if (get()) {
                    r = m;
                } else {
                    l = m;
                }
            }
            ans += '0' + r;
        } else {
            string t(ans);
            t += '0';
            append(t);
            ask(t);
            if (get()) {
                ans += '0';
                continue;
            }
            int l = 0, r = 9;
            while (l < r - 1) {
                int m = (l + r) / 2;
                t = string(ans);
                t += '0' + m;
                append(t);
                ask(t);
                if (get()) {
                    r = m;
                } else {
                    l = m;
                }
            }
            ans += '0' + r;
        }
    }
    cout << "! " << ans << endl;
}


Measured memory_bytes: 648
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

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

int a,b;

int main(){
    cin >> a >> b;
    rep(i,10001){
        if(i*8/100 == a && i*1/10 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
from scipy.sparse.csgraph import floyd_warshall as fw
import numpy as np
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
edge = [[np.inf for i in range(N+1)] for i in range(N+1)]
for i in range(M):
    A,B,C = map(int,input().split())
    edge[A][B] = C
    edge[B][A] = C
cost = fw(edge)
cd = {}
for r_ in r:
    cd[r_] = {}
for r_ in r:
    for r__ in r:
        cd[r_][r__] = cost[r_][r__]
import itertools
ans = np.inf
for rp in itertools.permutations(r):
    c = 0
    for i in range(R-1):
        c += cd[rp[i]][rp[i+1]]
    if c < ans:
        ans = c
print(int(ans))

Measured memory_bytes: 15568
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,K;
  string s,t,ans="";
  cin>>s>>t;
  N=s.size();
  K=t.size();
  mat dp(N+1,vec(K+1,0));
  rep(i,N)rep(j,K){
    if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
  }
  while(dp[N][K]){
    if(s[N-1]==t[K-1]){
      ans+=s[--N];
      K--;
    }else if(dp[N-1][K]==dp[N][K]){
      N--;
    }else{
      K--;
    }
  }
  reverse(all(ans));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 70784
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn input_int_tuple() -> (i32, i32) {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
  (vec[0], vec[1])
}

fn main() {
  let (n, x) = input_int_tuple();
  let mut ms: Vec<i32> = Vec::new();
  for i in 0..n {
    ms.push(input());
  }
  let size = ms.len();
  let mut min: i32 = 100000;
  let mut sum: i32 = 0;
  for m in ms {
    if m < min {
      min = m;
    }
    sum += m;
  }
  //println!("{}", sum);
  //println!("{}", min);
  println!("{}", (x - sum) / min + size as i32);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"unsafe"<<endl;
    else cout <<"safe"<<endl;
    return;
}
int main(){
    ll S,W;
    cin>>S>>W;
    YN(S<=W);
    return 0;
}

Measured memory_bytes: 3636
import math
l1 , l2 ,hour, minute  = map(int,input().split())

minuteAngel = (float(minute)*360)/60
hourAngel = (float(hour)%12)*30 + (float(minute)*30)/60
angel = abs(hourAngel - minuteAngel)

tmp = l1**2 + l2**2 - 2 * l1 * l2 * math.cos(math.radians(angel))

print(math.sqrt(tmp))

Measured memory_bytes: 9380
h,w,k = map(int,input().split())
mat = []
for i in range(h):
	mat.append(list(input()))
cnt = 0
for row in range((1 << h) - 1):
	for col in range((1 << w) - 1):
		black = 0
		for i in range(h):
			for j in range(w):
				if ((row >> i) & 1 == 0) and ((col >> j) & 1 ==0):
					if mat[i][j] == "#":
						black+=1 
		if black == k:
			cnt+=1
print(cnt)


Measured memory_bytes: 9024
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll num;
        cin >> num;
        /* 
        x = (a * b)
        x + y = num
         */
        ll cnt = 0;
        for(auto i=1; i<num; i++){
            factor_arr.clear();
            ll mul = num - i, prd = 1;
            myfactor(mul);
            for(auto j:factor_arr) prd *= (j.second + 1);
            cnt += prd;
        }
        cout<<cnt;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	int n;
	string s;
	vector<ll> t(10, 30000);
	vector<ll> e(10, -1);
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (t[s[i] - '0'] == 30000)
			t[s[i] - '0'] = i;
		e[s[i] - '0'] = i;
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (t[i] < e[j]) {
				int sa = 0;
				vector<bool> d(10, false);
				for (int k = t[i] + 1; k < e[j]; k++) {
					int x = s[k]-'0';
					if (d[x] == false){
						sa++;
						d[x]=true;
						if (sa == 10) break;
					}
				}
				ans += sa;
			}
		}
	}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

// DAG - directed acyclic graph

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax]; // the number of edges going to 'b'
int dist[nax];
bool visited[nax];

void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);
}

Measured memory_bytes: 9728
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        long result = 0;
        long whiteCount = 0;
        for (int i = 0; i < s.length(); ++i) {
            char ch = s.charAt(i);
            if (ch == 'W') {
                result += i - whiteCount;
                whiteCount++;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 27796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define assign(x,val) memset(x,val,sizeof(x))
void solve(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());sort(b.begin(),b.end());
    int x,y;
    if(n%2==1){
        x=a[n/2];
        y=b[n/2];
    }
    else{
        x=a[n/2-1]+a[n/2];
        y=b[n/2-1]+b[n/2];
    }
    cout<<y-x+1;
}
int main() {
    crap;
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}

Measured memory_bytes: 4784
loop do
  n, x = gets.split.map(&:to_i)
  if n == 0 && x == 0
    break
  end
  ans = 0
  for i in 1 .. n
    for j in i + 1 .. n
      for k in j + 1 .. n
        if i + j + k == x
          ans += 1
        end
      end
    end
  end
  puts ans
end



Measured memory_bytes: 6864
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(a//b)
    else:
        break



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

using namespace std;
using ll = long long;

constexpr int MAX_N = 105;
constexpr int MAX_WEIGHT = 100100;

int n, max_weight;
int weight[MAX_N], val[MAX_N];

ll dp[MAX_N][MAX_WEIGHT];

int main() {
    scanf(" %d %d", &n, &max_weight);
    for (int i = 1; i <= n; ++i) {
        scanf(" %d %d", &weight[i], &val[i]);
    }

    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= max_weight; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j - weight[i] >= 0 && dp[i - 1][j - weight[i]] != -1)  {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[i]] + val[i]);
            }
        }
    }

    ll ans = 0LL;
    for (int j = 0; j <= max_weight; ++j) {
        if (dp[n][j] != -1) {
            ans = max(ans, dp[n][j]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 82304
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    ll brojac=0;
    for(int i=0;i<n;i++)
    {
        if(i<k)
            brojac+=x;
        else
            brojac+=y;
    }
    cout<<brojac<<endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
*A, = map(int, input().split())
flg = 0
count = 0
index = 0
ans = 0
while 1:
    a = A[index]
    if a%2!=0:
        count = count + 1
    else:
        A[index] = a//2
        ans = ans + 1
    if count==len(A):
        break
    if index==len(A)-1:
        index = 0
        count = 0
        continue
    index = index + 1
print(ans)


Measured memory_bytes: 4148
import java.util.Scanner;

public class Main {

    public Main() {
    }

    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();
    }

    private void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();

        int t = a + b;

        if (t >= 24) {
            System.out.println(t - 24);
        } else {
            System.out.println(t);
        }
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
/*Calculate GCD, LCM =============================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}
long long LCM(long long a, long long b) {
    return a*b/GCD(a,b);
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    /**
     * X = Ak * (p + 0.5)
     * X = Ak/2 * (2p+1)
     * -> LCM(answer, Ak/2)
     */
    int n,m; cin >> n >> m;
    vi a(n); rep(i,n) cin >> a[i];
    rep(i,n) a[i] = a[i]/2;

    ll lcm = a[0];
    for(auto Ak : a) lcm = lcm*Ak/GCD(lcm, Ak);
    
    for(auto Ak : a) {
        if(lcm/Ak % 2 == 0) {
            cout << 0 << '\n';
            return 0;
        }
    }
    
    cout << (m/lcm + 1)/2 << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h, n;
  cin >> w >> h >> n;
  int x[100], y[100], a[100];
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
  int minx = 0, miny = 0, maxx = w, maxy = h;
  for(int i = 0; i < n; i++){
    if(a[i] == 1) minx = max(minx, x[i]);
    else if(a[i] == 2) maxx = min(maxx, x[i]);
    else if(a[i] == 3) miny = max(miny, y[i]);
    else maxy = min(maxy, y[i]);
  }
  int dx = max(0, maxx - minx);
  int dy = max(0, maxy - miny);
  cout << dx * dy << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long x,y;
    cin>>x>>y;
    
    map<long,long> m;
    m.insert(make_pair(1,0));
    m.insert(make_pair(3,0));
    m.insert(make_pair(5,0));
    m.insert(make_pair(7,0));
    m.insert(make_pair(8,0));
    m.insert(make_pair(10,0));
    m.insert(make_pair(12,0));
    
    m.insert(make_pair(4,1));
    m.insert(make_pair(6,1));
    m.insert(make_pair(9,1));
    m.insert(make_pair(11,1));
    
    m.insert(make_pair(2,2));
    
    if(m.at(x)==m.at(y)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main(){
    int k, x; cin >> k >> x;
    for(int i=x-k+1; i<=x+k-1; i++) {
        cout << i << " ";
    }
    cout << endl;
    
    return 0;
}

// EOF



Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int n,a,b;
  
  scanf("%d %d %d", &n, &a, &b);

  if(n==1) printf("Hello World");
  else if(n==2) printf("%d", a+b);
  return 0;
}

  

Measured memory_bytes: 1728
n, t = gets.chomp.split.map(&:to_i)
c_ts = []
(0..(n - 1)).each do |i|
  c_ts[i] = gets.chomp.split.map(&:to_i)
end
ans = c_ts.select { |c_t| c_t.last <= t }.map(&:first).min
ans.nil? ? puts('TLE') : puts(ans)

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){

    int S, W;
    cin >> S >> W;

    if(W >= S){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }

    return 0;
}

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

int main(void){


  int i,j;
  int n;
  int ans=0;
  int k;

  scanf("%d",&n);
  int h[n];

  scanf("%d",&k);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  for(i=0;i<n;i++){
    if(h[i]>=k)
    ans++;
  }

  printf("%d",ans);



return 0;

}


Measured memory_bytes: 512
using System;
using System.Linq;
public class Test
{
    public static void Main()
    {
        Console.ReadLine();
        var input = Console.ReadLine().Split(' ').Select((v, i) => new { value = int.Parse(v), index = i }).GroupBy(v => v.index % 2, v => v.value).Select(arr => arr.GroupBy(v => v).Select(grp => new { Count = grp.Count(), Element = grp.First() })).ToArray();
        var OddMajor = input.First().OrderByDescending(v => v.Count).Take(2).ToArray();
        var EvenMajor = input.Last().OrderByDescending(v => v.Count).Take(2).ToArray();
        if (OddMajor[0].Element != EvenMajor[0].Element)
        {
            Console.WriteLine(input.Sum(v => v.Sum(w => w.Count)) - OddMajor[0].Count - EvenMajor[0].Count);
        }
        else
        {
            int Odder, Evener;
            if (OddMajor.Length == 1)
                Odder = EvenMajor[0].Count;
            else
                Odder = OddMajor[1].Count + EvenMajor[0].Count;
            if (EvenMajor.Length == 1)
                Evener = OddMajor[0].Count;
            else
                Evener = OddMajor[0].Count + EvenMajor[1].Count;
            Console.WriteLine(input.Sum(v => v.Sum(w => w.Count)) - Math.Max(Evener, Odder));
        }
    }
}

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

int main() {
  int a, b, c, d;
    cin >> a >> b;
    c = (a + b) / 2;
    d = (a + b) % 2;
  if (d == 0 ){
    cout <<  c  << endl;
  }
  else {
    cout <<  c + 1  << endl;
}
}

Measured memory_bytes: 256