akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int len;
char s[100001];
void dfs(int pos){
	if(pos == len){
		printf("No");
		return;
	}
	if(s[pos] == 'A'){
		if(s[pos + 1] == 'C'){
			printf("Yes");
			return;
		}
	}
	dfs(pos + 1);
}
int main(){
	scanf("%s",s);
	len = strlen(s);
	dfs(0);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

l=[b,c,d,e]
min=a
for x in l:
    if x<min:
        min=x
if n%min==0:
    ans=n//min+4
else:
    ans=n//min+5
print(ans)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int aoki, taka;
  aoki = C;
  taka = A;
  while(aoki > 0 && taka > 0){
    aoki = aoki - B;
    taka = taka - D;
  }
  if(taka > 0){
    cout << "Yes" << endl;
  }
  else if(aoki > 0 && taka < 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }    
}  

Measured memory_bytes: 3596
from collections import deque
d = deque()
time = 0
n,q = map(int,input().split())
for i in range(n):
	d.append(input().split())
while len(d):
	d[0][1]=int(d[0][1])
	if d[0][1]>q:
		d[0][1] -= q
		time += q
		d.rotate(-1)
	else:
		time += d[0][1]
		print(f'{d.popleft()[0]} {time}')







Measured memory_bytes: 17300
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int x, y;
    cin >> x >> y;

    bool ok = false;
    for (int i = 0; i <= x; i++) {
        if (2 * i + 4 * (x - i) == y) ok = true;
    }

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


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


l = []
while True:
    nx = list(readnums())
    if nx[0] == 0 and nx[1] == 0:
        break
    else:
        l.append(nx)

for v in l:
    n, x = v[0], v[1]
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            k = x - i - j
            if k != i and k != j and k > j and k <= n:
                ans += 1

    print(ans)



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

int main() {
  int N, point = 0, res = 0, prevres = INT_MAX;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) cin >> vec[i];
  while(true) {
    for(int i = 0; i < N; i++) {
      res += (vec[i] - point) * (vec[i] - point);
    }
    if(prevres < res) {
      res = prevres;
      break;
    }
    else {
      prevres = res;
      res = 0;
      point++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3516
n = int(input())
l = {}
ans = 0
for _ in range(n):
    a = int(input())
    if a in l:
        l[a] += 1
    else:
        l[a] = 1
for v in l.values():
    if v % 2 == 1:
        ans += 1
print(ans)

Measured memory_bytes: 19236
#include<iostream>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){
    if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }else if(a==4||a==6||a==9||a==11){
    if(b==4||b==6||b==9||b==11)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

s = input()
t = input()

s_dict = defaultdict(int)
for char in s:
    s_dict[char] += 1

t_dict = defaultdict(int)
for char in t:
    t_dict[char] += 1

if sorted(s_dict.values()) == sorted(t_dict.values()):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4144
/* ex9_2
   reo012 */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//リストにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
    return;
}

//リストからデータを削除する
void pop(node **first){
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return;
}

int main(void){
    char input_s[100001];
    int i, count=0;
    //最初のノードの指す先
    node *first = NULL;

    //入力
    scanf("%s", input_s);

    //入力された文字列の情報をリストに順に追加
    //ただし、i-1回目に追加されたキューブがi回目のキューブと異なるなら、i-1回目をリストから削除
    for(i=0; input_s[i]!='\0'; i++){
        if(first==NULL || input_s[i]==first->elem){ //最初のキューブ・一個前と同じキューブ
            push(&first, input_s[i]);   //リストに追加
        }else{  //一個前のキューブと異なるとき
            pop(&first);    //一個前のキューブ（リストの先頭にある）を削除
            count += 2;     //countを2増やす
        }
    }
    //答えのcountを出力
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 4956
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct UnionFind{
    vl par;
    vl rank;
    map<ll, ll> size;
    UnionFind(ll N) : par(N, 0), rank(N, 0){
        for(int i = 0; i < N; i++){
            par[i] = i; size[i] = 1;
        }
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]); // compression
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x); ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx, ry);
        if(rank[rx] == rank[ry]) ++rank[rx];
        par[ry] = rx;
//        if(rx != ry) size[rx] = size[rx] + size[ry];
//        else{
//            size[rx] = max(size[rx], size[ry]);
//        }
    }
    
    ll get_size(ll x){
        return size[root(x)];
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};


int main(){
    ll N, M; cin >> N >> M;
    auto uf = new UnionFind(N);
    vl ps(N, 0); REP(i, N){ ll p; cin >> p; ps[i] = p-1;};
    REP(i, M){
        ll x, y; cin >> x >> y;
        uf->unite(x-1, y-1);
    }
    map<ll, set<ll>> m1, m2;
    REP(i, N){
        ll root = uf->root(ps[i]);
        m1[root].insert(i);
    }
    
    ll ret = 0;
    for(auto it : m1){
        for(auto v : it.ss){
            if(it.ss.count(ps[v])) ret++;
        }
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 22912
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string S; cin >> S;
    int ans;
    if (S == "SUN") ans = 7;
    if (S == "MON") ans = 6;
    if (S == "TUE") ans = 5;
    if (S == "WED") ans = 4;
    if (S == "THU") ans = 3;
    if (S == "FRI") ans = 2;
    if (S == "SAT") ans = 1;
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>

using namespace std;

vector<int> prime,point[201],v1,v2;
int match[201],N,x,cnt;
bool check[10000001],rev[10000002],vis[201];

void sieve(){
	check[1]=true;for(int i=2;i<=10000000;++i){
		if(!check[i])prime.push_back(i);
		for(int j:prime){if(1ll*i*j>10000000)break;check[i*j]=true;if(i%j==0)break;}
	}
}

bool dfs(int x){
	for(int y:point[x])if(!vis[y]){vis[y]=true;if(match[y]<0||dfs(match[y])){match[y]=x;return true;}}
	return false;
}

int main(){
	sieve();
	scanf("%d",&N);for(int i=1;i<=N;++i)scanf("%d",&x),rev[x]^=true;
	for(int i=1;i<=10000001;++i)if(rev[i]!=rev[i-1])if(i&1)v1.push_back(i);else v2.push_back(i);
	for(int i=0;i<v1.size();++i)for(int j=0;j<v2.size();++j)if(!check[abs(v1[i]-v2[j])])point[i].push_back(j);
	memset(match,-1,sizeof(match));for(int i=0;i<v1.size();++i){memset(vis,false,sizeof(vis));if(dfs(i))++cnt;}
	printf("%d",cnt+(v1.size()-cnt>>1<<1)+(v2.size()-cnt>>1<<1)+((v1.size()-cnt)&1)*3);
}

Measured memory_bytes: 21996
#include<bits/stdc++.h>
using namespace std;
int main(){int n;cin>>n;vector<long>a(n);
     unsigned long long s=0,p=0;for(int i=0;i<n;i++){cin>>a.at(i);s+=a.at(i);}
     for(int i=0;i<n-1;i++)
     {s-=a.at(i);p+=(s%1000000007)*a.at(i);p%=1000000007;}
cout<<p<<endl;}

Measured memory_bytes: 4828
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;

#define v1 first
#define v2 second
#define pb push_back
#define mid ((l+r)>>1)
#define vec vector<int>
#define pr pair<int,int>
#define tp tuple<int,int,int>
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define mem(a,x) memset(a,x,sizeof a)
#define For(x) for(int y,i=head[x];(y=e[i].to);i=e[i].nxt)

inline bool rd(int &X)
{
    X=0;int w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    X=w?-X:X; return 1;
}

vector<pr> ok1,ok2;
int n,a[N],ans;
map<int,int> cnt,cnt2;

signed main()
{
    for(int i=rd(n);i<=n;i++) rd(a[i]);
    for(int i=1;i<=n;i+=2) cnt[a[i]]++;
    for(int i=2;i<=n;i+=2) cnt2[a[i]]++;
    for(int i=1;i<=n;i+=2)
        if(cnt[a[i]]) ok1.pb(pr(cnt[a[i]],a[i])),cnt[a[i]]=0;
    for(int i=2;i<=n;i+=2)
        if(cnt2[a[i]]) ok2.pb(pr(cnt2[a[i]],a[i])),cnt2[a[i]]=0;
    sort(all(ok1));sort(all(ok2));
    reverse(all(ok1));reverse(all(ok2));
    if(ok1[0].v2!=ok2[0].v2)
        return printf("%d\n",n-ok1[0].v1-ok2[0].v1),0;
    if(sz(ok1)>1)
        ans=max(ans,ok1[1].v1+ok2[0].v1);
    if(sz(ok2)>1)
        ans=max(ans,ok1[0].v1+ok2[1].v1);
    ans=max(ans,max(ok1[0].v1,ok2[0].v1));
    cout<<n-ans;

}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    int u[n-1], v[n-1];
    for(int i=0;i<n-1;i++) {
        cin>>u[i]>>v[i];
        if(u[i]>v[i]) {
            swap(u[i], v[i]);
        }
    }   
    int ans = 0;
    for(int i=0;i<n-1;i++) {
        ans+=u[i]*(n-v[i]+1);
        // ans+=(n-v[i]+1)*(v[i]-u[i]-1);
    }
    cout<<-ans+n*(n+1)*(n+2)/6;

    return 0;
}

Measured memory_bytes: 6756
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

int main() {
    int K; cin >> K;
    int X; cin >> X;

    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <vector>
// 1 - (+) , 0 - (-)
const int MaxN = 1e5;
typedef long long LL;
using namespace std;
int a[MaxN + 5] , sum;
int pos = 0 , n;
LL ans = 0;
bool ok = 0;
void Init(){
	ok = 0;
	sum = ans = 0;
	for(int i = 1;i <= n;i++) 
		scanf("%d" , &a[i]);
}
void Solve(){
	ok = 0;
	for(int i = 1;i <= n;i++){
		if(ok){
			sum += a[i];
			if(sum >= 0) ans += sum + 1 , sum = -1;
			ok = 0;
		}
		else if(ok == 0){
			sum += a[i];
			if(sum <= 0) ans += abs(sum) + 1 , sum = 1;
			ok = 1;
		}
	}
	LL tmp = 0;
	ok = 1 , sum = 0;
	for(int i = 1;i <= n;i++){
		if(ok){
			sum += a[i];
			if(sum >= 0) tmp += sum + 1 , sum = -1;
			ok = 0;
		}			
		else if(ok == 0){
			sum += a[i];
			if(sum <= 0) tmp += abs(sum) + 1 , sum = 1;
			ok = 1;
		}
	}
	printf("%lld\n" , min(tmp , ans));
}
int main()
{
	while(~scanf("%d" , &n)){
		Init();
		Solve();
	}
}

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

using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define PI 3.141592653589793
#define scanstr(s) cin>>ws; getline(cin,s);

void solve()
{
	int n;
	cin>>n;
	cout<< (n+1)/2<< nl;
	return ;
}

int32_t main()
{
	FastIO;
	solve();
	return 0;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            bool[] found = new bool[26]; // found[0] = a

            for (int i = 0; i < S.Length; i++)
            {
                found[S[i] - 'a'] = true;
            }

            for(int i = 0; i < 26; i++)
            {
                if(found[i] == false)
                {
                    char c = (char)('a' + i);
                    Console.WriteLine(c);
                    return;
                }
            }

            Console.WriteLine("None");

        }
    }
}

Measured memory_bytes: 11232
import sys
N = int(input())
if N == 0:
  print(0)
  sys.exit()
ans = ''
k = 1
while N != 0:
  if N%(2**k) == 0:
    ans = '0'+ans
  else:
    ans = '1'+ans
    N = N-((-2)**(k-1))
  k += 1
print(ans)

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

using namespace std;

#define fst first
#define snd second

#define mp make_pair
#define pb push_back

typedef pair<int,int> ii;
typedef long long ll;

int dp[MAX][3];
int u[MAX], v[MAX];
int n;

int solve(int i, int up) {
  if (i == n)
    return 0;

  if (dp[i][up] != -1)
    return dp[i][up];

  if (up)
    return dp[i][up] = max(solve(i + 1, 1) + v[i], solve(i, 0) + v[i]);
  else
    return dp[i][up] = solve(i + 1, 0) + u[i];
}

int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", v + i);
  for (int i = 0; i < n; ++i)
    scanf("%d", u + i);

  u[n-1] += 200;
  printf("%d\n", solve(0, 1) - 200);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long PER(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return (fac[n] * finv[n-k]) % MOD;
}

long long modpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = (ret * x) % MOD;  
        x = (x * x) % MOD;
        n >>= 1;  
    }
    return ret;
}

int main(){
    COMinit();
    int n,m;
    cin >> n >> m;
    ll ans = PER(m,n);
    ll res = 0;
    for(int k=1;k<=n;k++){
        ll p = (COM(n,k) * PER(m-k,n-k))%MOD;
        if(k%2==1) res = (res + p)%MOD;
        else res = (res - p + MOD)%MOD;
        //cout << p << endl;
    }
    res = (ans - res + MOD)%MOD;
    ans = (ans * res)%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27052
def main():
    mtx = [
400,
599,
8,
600,
799,
7,
800,
999,
6,
1000,
1199,
5,
1200,
1399,
4,
1400,
1599,
3,
1600,
1799,
2,
1800,
1999,
1
    ];
    X = int(input())
    for i in range(0, len(mtx), 3):
        lo = mtx[i]
        hi = mtx[i+1]
        ans = mtx[
i+2
        ]
        if lo <= X <= hi:
            print(ans)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 9148
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

struct Info{

	ll left,right;
};

ll N,M;
map<ll,ll> MAP,rev_MAP;
vector<ll> V;
Info info[SIZE];
ll table[3*SIZE];

int main(){

	scanf("%lld %lld",&N,&M);

	V.push_back(0);
	V.push_back(M);

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

		scanf("%lld %lld",&info[i].left,&info[i].right);

		V.push_back(info[i].left);
		V.push_back(info[i].right);
		V.push_back(info[i].right+1);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(ll i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
		rev_MAP[i] = V[i];
	}

	for(int i = 0; i <= V.size(); i++){

		table[i] = 0;
	}

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

		table[MAP[info[i].left]]++;
		table[MAP[info[i].right]+1]--;
	}

	ll maximum = table[0];

	for(int i = 1; i < V.size(); i++){

		table[i] += table[i-1];
		maximum = max(maximum,table[i]);
	}

	int L = -1,R = -1;

	for(int i = 0; i < V.size(); i++){

		if(table[i] == maximum){
			if(L == -1){

				L = i;
			}
			R = i;
		}
	}

	L = rev_MAP[L];
	R = rev_MAP[R];

	if(maximum%2 == 0){

		printf("%lld\n",M*(maximum-1)+(M-L));

	}else{

		printf("%lld\n",M*(maximum-1)+R);
	}

	return 0;
}



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

bool contains(string str, string pre){
    int s = str.length(), p = pre.length();
    if(s < p)   return false;

    for(int i = 0; i <= s - p; i++){
        int j;
        for(j = 0; j < p; j++){ 
            if(str[i+j] != pre[j])  break;
        }
        if(j == p)  return true;
    }

    return false;
}

typedef unsigned long long ull;
ull x = 1000000007;

int f(string s, string t){
    int k = min(s.length(), t.length()), slen = s.length();
    int ret = 0;
    ull a = 0, b = 0, tmp = 1;
    for(int i = 1; i <= k; i++){
        a = a + s[slen-i]*tmp;
        b = b*x + t[i-1];
        if(a == b)  ret = i;
        tmp *= x;
    }
    return ret;
}

int main(){
    int n;
    while(cin >> n, n){
        vector<string> v;
        for(int i = 0; i < n; i++){
            string s;   cin >> s;
            v.push_back(s);
        }
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(),v.end()),v.end());
        n = v.size();
        vector<string> x;
        for(int i = 0; i < n; i++){
            bool valid = true;
            for(int j = 0; j < n; j++){
                if(i == j)  continue;
                if(contains(v[j], v[i]))    valid = false;
            }
            if(valid)   x.push_back(v[i]);
        }
        int n = x.size();
        vector<vector<string>> dp(n, vector<string>(1<<n, ""));
        for(int i = 0; i < n; i++)  dp[i][1<<i] = x[i];
        for(int s = 1; s < 1<<n; s++){
            for(int i = 0; i < n; i++){
                if(((s>>i)&1) == 0)    continue;
                for(int j = 0; j < n; j++){
                    if((s>>j)&1)    continue;
                    string tmp = dp[i][s];
                    tmp += x[j].substr(f(dp[i][s], x[j]));
                    int nbit = s + (1<<j);
                    if(dp[j][nbit] == "" || tmp.length() < dp[j][nbit].length() || (tmp.length()==dp[j][nbit].length() && tmp < dp[j][nbit])){
                        dp[j][nbit] = tmp;
                    }
                }
            }
        }
        string ans = dp[0].back();
        for(int i = 1; i < n; i++){
            if(ans.length() > dp[i].back().length() || (ans.length()==dp[i].back().length() && ans > dp[i].back())){
                ans = dp[i].back();
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3412
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll 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+(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;
    }
};

mint Combination(ll n, ll r) {
    mint molecule = 1;
    mint denominator = 1;
    for (int i = 0; i < r; i++) {
        molecule *= n - i;
        denominator *= r - i;
    }
    return (molecule / denominator);
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= Combination(n, a);
    ans -= Combination(n, b);
    cout << ans.x << endl;

    return 0;
}


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

// Problem https://atcoder.jp/contests/abc079/tasks/abc079_c
int zeroNum='0';
string solver(string givenNumber){
    string result;
    result.clear();
    vector<int> ticketNum(4,0);
    for(int j=0;j<4;j++){
        ticketNum[j]=(int)(givenNumber[j]-zeroNum);
    }
 //   for(int j=0;j<4;j++){
   //     cout << ticketNum[j] << ',';
//    }
 //   cout << endl;
    for(int bitPattern=0;bitPattern < (1 << 3);bitPattern++)
    {   
        int nowNumber;
        nowNumber=ticketNum[0];
        for(int scale=0;scale < 3;scale++){
            int nowChange = ticketNum[scale+1];
            int minusFlug = bitPattern & (1 << scale);
            // cout << minusFlug << endl;
            if(minusFlug == 0){
                nowNumber=nowNumber-nowChange;
            }
            else{
                nowNumber = nowNumber+nowChange;
            }
        }
        if(nowNumber == 7){ // この時のビットの値で+-作り、関数を返す
            result.push_back(ticketNum[0]+zeroNum);
            for(int scale=0;scale < 3;scale++){
                int nowChange=ticketNum[scale+1];
                int minusFlug = bitPattern & (1<<scale);
                if(minusFlug == 0){
                    result.push_back('-');
                }
                else{
                     result.push_back('+');
                }
                result.push_back(nowChange+zeroNum);
            }
            result.append("=7\n");
            break;
        }
    } 
    return result;
}

int main(void){
    string answer;
    answer.clear();
    string ABCD;
    cin >> ABCD;
    answer = solver(ABCD);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int a, b, c, d, x;

int main()
{
	cin >> a >> b;

	if (a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;;){

			int h=sc.nextInt();

			int m=sc.nextInt();

			int s=sc.nextInt();

			if(h==-1&&m==-1&&s==-1) break;

			int ns = -s;

			while(ns<0){

				m+=1;

				ns+=60;

			}

			int nm = -m;

			while(nm<0){

				h+=1;

				nm += 60;

			}

			int nh=2-h;

			System.out.printf("%02d:%02d:%02d",nh,nm,ns);

			System.out.println();

			ns = ns*3;

			int nm2=0;

			while(ns>=60){

				nm2+=1;

				ns-=60;

			}

			nm = nm*3+nm2;

			int nh2=0;

			while(nm>=60){

				nh2+=1;

				nm-=60;

			}

			nh=nh*3+nh2;

			System.out.printf("%02d:%02d:%02d",nh,nm,ns);

			System.out.println();

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 11000
#include<iostream>

using namespace std;

long long n;

void func(long long cur, int use, int &counter) {
    if (cur > n) return;
    if (use == 0b111) counter++;

    func(cur * 10 + 7, use | 0b001, counter);

    func(cur * 10 + 5, use | 0b010, counter);

    func(cur * 10 + 3, use | 0b100, counter);
}


int main() {
    cin >> n;

    int ans = 0;
    func(0, 0, ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=100005;
int ch[N][2],n,l,cnt;
typedef long long ll;
ll L;
unsigned long long ans;
char s[N];
ll lowbit(ll x){ return x&(-x); }
void dfs(int u,int deep){
	for (int i=0;i<=1;i++)
		if (ch[u][i]) dfs(ch[u][i],deep+1);
		else ans=ans^lowbit(L-deep); 
}
int main(){
	scanf("%d%lld",&n,&L);
	for (int i=1;i<=n;i++){
		scanf("%s",s);
		l=strlen(s);
		int u=0,deep=0;
		while (deep<l){
			int c=s[deep]-'0';
			if (!ch[u][c]) ch[u][c]=++cnt;
			u=ch[u][c];
			deep++;
		} 
	}
	dfs(0,0);
	if (ans) puts("Alice");
	else puts("Bob"); 
}

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

int main() {
    int N,i,j,s=0;
    cin >> N;
    vector<int> d(N);

    for(i=0; i<N; i++)
        cin >> d.at(i);

    for(i=0; i<N-1; i++)
        for(j=i+1; j<N; j++) {
            if(i==j)
                continue;
            s += d.at(i)*d.at(j);
        }
    
    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
bool ldp[5001][5001],rdp[5001][5001];
int main(){
	int N,K;
	ll a[5001];
	vll sa;
	scan(N>>K);
	int ans=N;
	rep(i,N){
		scan(a[i]);
		if(a[i]>K) ans--;
		else sa.push_back(a[i]);
	}
	sort(ALL(sa));
	int M=sa.size();
	ldp[0][0]=1;
	rep(i,M){
		rep(k,K+1){
			ldp[i+1][k]|=ldp[i][k];
			if(k>=sa[i]) ldp[i+1][k]|=ldp[i][k-sa[i]];
		}
	}
	rdp[M][0]=1;
	brep1(i,M){
		rep(k,K+1){
			rdp[i-1][k]|=rdp[i][k];
			if(k>=sa[i-1]) rdp[i-1][k]|=rdp[i][k-sa[i-1]];
		}
	}
	rep(i,M){
		/*printf("i:%d sa[i]:%d\nldp: ",i,sa[i]);
		rep(k,K+1) printf("%d ",ldp[i][k]);
		printf("\nrdp: ");
		rep(k,K+1) printf("%d ",rdp[i+1][k]);
		kaigyo;*/
		int rkosu[5002]={};
		rep(j,5001){
			rkosu[j+1]=rkosu[j]+rdp[i+1][j];
		}
		int flag=1;
		rep(j,K){
			if(ldp[i][j]){
				if(K-j-sa[i]<0){
					if(rkosu[K-j]>0){
						flag=0;
						//printf("i:%d sa[i]:%d j:%d flag0\n",i,sa[i],j);
						break;
					}
				}
				else if(rkosu[K-j]!=rkosu[K-j-sa[i]]){
					flag=0;//hituyo
					//printf("i:%d sa[i]:%d j:%d flag00\n",i,sa[i],j);
					break;
				}
			}
		}
		if(flag==0) ans--;
		//printf("i:%d sa[i]:%d flag:%d\n",i,sa[i],flag);
	}
	/*rep(i,M){
		bitset<5001> dp[];
		dp.set(0);
		rep(j,M){
			if(j==i) continue;
			dp|=(dp<<sa[j]);
		}
		int flag=1;
		for(int k=K-sa[i];k<K;k++){
			if(dp[k]){
				flag=0;
				break;
			}
		}
		if(flag==0) ans--;
	}*/
	prin(ans);
	return 0;
}


Measured memory_bytes: 49280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int dc = c*2;
  int x, y;
  cin >> x >> y;
  int ans;
  if(dc <= a + b){
    int m = min(x, y);
    ans = m*dc;
    x -= m;
    y -= m;
    // cerr << x << " " << y << " " << a << " " << b << " " << dc << endl;
    if(y > 0){
      if(dc <= b){
        ans += dc*y;
      }else{
        ans += b*y;
      }
    }else{
      if(dc <= a){
        ans += dc*x;
      }else{
        ans += a*x;
      }
    }
  }else{
    ans = x*a + y*b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map<int,int> m1;
long long ans;
long long mx;
long long res;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        m1[x]++;
    }
    for(auto x:m1){
        if(x.second>=4){
            ans= max(ans,1LL*x.first*x.first);
            ans = max(ans,1LL*x.first*mx);
            mx = max(mx,(long long)x.first);
        }else if(x.second>=2){
            ans = max(ans,1LL*x.first*mx);
            mx = max(mx,(long long)x.first);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
while 1:
    m, f, r = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m + f < 30:
        print("F")

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

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    bool ok = abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

const int MAX = 1001;
typedef pair<int,int> QQ;
typedef pair<int,int> PP;
typedef pair<PP,QQ> P;
 
int main(){
    int n;
 
    while(cin >> n ,n){
	int id,uni,ac,pe;
	int tc[MAX+1];
	fill(tc,tc+MAX,0);
	vector<P> v;
 
	while(n--){
	    cin >> id >> uni >> ac >> pe;
	    v.push_back(P(PP(-ac,pe),QQ(id,uni)));
	} 
	sort(v.begin(),v.end());
 
	int cnt = 0;
	int size = v.size();
	for(int i = 0; i < size ; i++){
	    int u = v[i].second.second;
    
	    if(cnt < 10){
		if(tc[u] < 3){
		    cout << v[i].second.first << endl;
		    cnt++;
		}
	    }
	    else if(cnt < 20){
		if(tc[u] < 2){
		    cout << v[i].second.first << endl;
		    cnt++;
		}
	    }
	    else if(cnt < 26){
		if(tc[u] < 1){
		    cout << v[i].second.first << endl;
		    cnt++;
		}
	    }
	    tc[u]++;
	} 
    }
    return 0;
}

Measured memory_bytes: 3096
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include <map>
using namespace std;
long long int n,m,X;
map<long long int,char>co;
map<long long int,int>flag;
char s[1000050],t[1000050];
long long int gcd(long long int x,long long int y)
{
    if (y==0)
    {
        return x;
    }
    return gcd(y,x%y);
}
int main()
{
    scanf("%lld%lld",&n,&m);
    scanf("%s",s);
    scanf("%s",t);
    int ruler=0;
    long long int l=gcd(n,m);
    X=n*m/l;
    for (long long int i=0;i<n;i++)
    {
        flag[X/n*i+1]=1;
        co[X/n*i+1]=s[(int)i];
    }
    for (long long int i=0;i<m;i++)
    {
        if (flag[X/m*i+1]==1)
        {
            if (co[X/m*i+1]!=t[(int)i])
            {
                ruler=1;
                break;
            }
        }
    }
    if (ruler==1)
    {
        printf("-1");
    }
    else
    {
        printf("%lld",X);
    }
    return 0;
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll n,d;
    cin>>n>>d;
    ll x[n];
    ll y[n];
    rep(i,n){
        cin>>x[i]>>y[i];
        x[i]*=x[i];
        y[i]*=y[i];
    }

    ll dnizyou=d*d;
    ll count=0;

    rep(i,n){
        if(dnizyou>=x[i]+y[i]) count++;
        else continue;
    }

    cout<<count<<endl;


}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {
    int N, T;
    cin>>N>>T;
    
    int ans=0;
    int A;
    cin >> A;
    int prev=A;
    int next_close=A+T;
    rep(i,N-1){
        cin >> A;
        // 終わる前に押された
        if(A<next_close){
            next_close=A+T;
        }else{
            ans+=next_close-prev;
            prev=A;
            next_close = A+T;
        }
        dump(prev,next_close);
    }
    ans+=next_close-prev;
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
S = str(input())

x = 0

if S == "MON":
    x += 6
elif S == "TUE":
    x += 5
elif S == "WED":
    x += 4
elif S == "THU":
    x += 3
elif S == "FRI":
    x += 2
elif S == "SAT":
    x += 1
elif S == "SUN":
    x += 7

print(x)



Measured memory_bytes: 3064
N, M, X = map(int, input().split())
item = []
ans = []
for i in range(N):
  item.append(list(map(int, input().split())))
for i in range(2**N):
  bag = []
  money = 0
  for j in range(N):
    if ((i>>j) & 1):
      bag.append(item[j])
  if bag == []:
    continue
  total = [0] * M
  for k in bag:
    money += k[0]
    for l in range(1, M+1):
      total[l-1] += k[l]
  if min(total) >= X:
    ans.append(money)
if ans == []:
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 8980
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var y = int.Parse(spl[1]);
        
        for(int i=0; i<=n; i++) {
            for(int j=0; j <= n - i; j++) {
                var k = n - i - j;

                if(i * 10000 + j * 5000 + k * 1000 == y) {
                    return $"{i} {j} {k}";
                }
            }
        }

        return "-1 -1 -1";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
    int N,A,B,C,D;
    int E,F=0;
    cin >> N >> A >>B >> C >> D;
    while(N>A*E){
        E++;
    }
    while(N>C*F){
        F++;
    }
    if(B*E<D*F){
        cout << B*E << "\n";
    }else{
        cout << D*F << "\n";
    }
    return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<vector>
using namespace std;
int ze(int a) {
  return max(a, -a);
}
int noe(int a) {
  if (a == 0) return 1;
  if (a == 1) return 0;
}
int main () {
  int N, A, B;
  cin >> N >> A >> B;
  int bi[18];
  bi[0] = 1;
  for (int i = 1; i < 18; i ++) bi[i] = bi[i - 1] * 2;
  int bita[18];
  int bitb[18];
  vector<vector<int>>ans(bi[N],vector<int>(N, -1));
  int a = A;
  int b = B;
  int sa = 0;
  int sb = 0;
  for (int i = 0; i < N; i ++) {
    bita[i] = a % 2;
    bitb[i] = b % 2;
    a /= 2;
    b /= 2;
    sa += bita[i];
    sb += bitb[i];
  }
  if (!(ze(sa - sb) % 2)) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 0; i < N; i ++) {
    ans[0][i] = bita[i];
    ans[bi[N] - 1][i] = bitb[i];
  }
  for (int i = N; i >= 0; i --) {
    for (int k = 1; k <= bi[N - i]; k ++) {
    //前と後はビットがどれか違うはずだから、それを見つけて中間を作る
      for (int j = 0; j < N; j ++) {
        if (ans[k * bi[i] - 1][j] != ans[(k - 1) * bi[i]][j]) {
          for (int l = (k - 1) * bi[i] + 1; l < (2 * k - 1) * bi[i - 1]; l ++) {
            ans[l][j] = ans[(k - 1) * bi[i]][j];
          }
          for (int l = (2 * k - 1) * bi[i - 1]; l < k * bi[i] - 1; l ++) {
            ans[l][j] = ans[k * bi[i] - 1][j];
          }
          bool did = true;
          for (int l = N - 1; l >= 0;) {
            if (ans[(2 * k - 1) * bi[i - 1] - 1][l] == -1) {
              if (did) {
                ans[(2 * k - 1) * bi[i - 1] - 1][l] = noe(ans[(k - 1) * bi[i]][l]);
                did = false;
              }
              else ans[(2 * k - 1) * bi[i - 1] - 1][l] = ans[(k - 1) * bi[i]][l];
            }
            l --;
          }
          bool di = true;
          for (int l = N - 1; l >= 0; l --) {
            if (ans[(2 * k - 1) * bi[i - 1]][l] == -1) {
              ans[(2 * k - 1) * bi[i - 1]][l] = ans[(2 * k - 1) * bi[i - 1] - 1][l];
            }
          }
          j = N;
        }
      }
    }
  }
  cout << A;
  for (int i = 1; i < bi[N]; i ++) {
    int an = ans[i][N - 1];
    for (int j = N - 2; j >= 0; j --) {
      an *= 2;
      an += ans[i][j];
    }
    cout << ' ' << an;
  }
  cout << endl;
}
  
  
  



Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back
main(){
  int n,m;
  while(cin>>n>>m && n){
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(ALL(a));reverse(ALL(a));
    int ans=0;
    int cnt=1;
    rep(i,n){
      if (cnt == m){
	cnt=0;
      }
      else ans+=a[i];
      cnt++;
    }
    cout << ans << endl;
  }
  return false;
}

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

#define all(a) (a).begin(), (a).end()

int main(){
	int n;
	int c[20],v[20];
	cin>>n;
	for (int i = 0; i < n; ++i){
		cin>>v[i];
	}
	for (int i = 0; i < n; ++i){
		cin>>c[i];
	}

	int sum=0;
	for (int i = 0; i < n; ++i){
		if(v[i]>c[i])
			sum+=v[i]-c[i];
	}

	cout<<sum<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
int n,a[200001]={0},b[200001]={0},k,k1;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
b[n/2+1]=a[1];
k=k1=n/2+1;
for(int i=2;i<=n;i++){
	if(i%2==0){
		b[--k]=a[i];
	}
	else b[++k1]=a[i];
}
if(n%2==0)
for(int i=1;i<=n;i++)cout<<b[i]<<" ";
else for(int i=n;i>=1;i--)cout<<b[i]<<" ";
}




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

int main (){
        int N;
        cin >> N;
        long long count = 0;
        char *ptr = new char[N+1];
        for (int i = 0; i < N; i++) {
                cin >> ptr[i];
                if (ptr[i]== 'E') {
                        count++;
                }
        }

        int c =count;
        for (int i = 0; i < N; i++) {

                if (ptr[i]== 'E') {
                        c--;
                }
                if (i!=0 && ptr[i-1]== 'W') {
                        c++;
                }

                if ( count > c ) {
                        count = c;
                }
        }

        cout << count << endl;

        return 0;
}


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

signed main(void){
  int N; cin >> N;
  multiset<int> ms;
  for(int i = 0; i < N; i++){ 
    int a; cin >> a;
    //aより小さなものがなければ、そのまま入れる
    if( ms.empty() || *ms.begin() >= a ){ 
      ms.insert(a);
    }
    else{ // aより小さなものがある
      
      auto itr = ms.lower_bound(a);
      itr--;
      ms.erase(itr);
      ms.insert(a);
    }
  }
  
  cout << ms.size() << endl;
  
  return 0;
}
  

Measured memory_bytes: 4992
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int d = sc.nextInt();
			int s = 0;
			for(int i=0; i<600/d; i++){
				s+= Math.pow(d*i,2)*d;
			}
			System.out.println(s);
		}
	}

}

Measured memory_bytes: 17200
from string import ascii_lowercase

def resolve():
    n = int(input())
    l = [[0]]
    for i in range(1, n):
        ll = []
        for j in l:
            for k in range(max(j) + 2):
                ll.append(j + [k])
        l = ll
    for i in l:
        print("".join([ascii_lowercase[x] for x in i]))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 25932
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    string s;
    cin >> s;
    for (int i = 0 ; i < s.length(); i++) {
        int curPos = i + 1;
        if (curPos&1) {
            if (s[i] == 'L') {
                cout << "No\n";
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	
	int r1, r2;
	
	r1 = x>=a? x-a : a-x;
	r2 = x>=b? x-b : b-x;
	
	if(r1<r2){
		printf("A");
	}else {
		printf("B");
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 1620