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

using namespace std;

int main() {
    int a[6];
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
    sort(a,a+5);
    cout<< ( (abs(a[0]-a[4])<=a[5]) ? "Yay!" : ":(");
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    REPS(i, 10000) {
        if (int(i * 0.08) == A && int(i * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pr;

int main(){
    string s;
    cin>>s;
    ll ans=0;
    ll n=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            ans+=(i-n);
            n++;
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << (nob - 1)
    b = (n + 1) ^ a
    a = n + a if a % 2 == 0 else a
    b = n + b if b % 2 == 0 else b
    print(n, a)
    print(b, 2 * n)


Measured memory_bytes: 5780
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> L(N + 1);
  
  L.at(0) = 2;
  L.at(1) = 1;
  
  for (int i = 2; i < N+1; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }

  printf("%ld", L.at(N));
}


Measured memory_bytes: 3768
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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


using namespace std;


int main() {
	
	char a;
	cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, k;
    cin >> n >> k;

    int k2 = k * 2;

    vector<vector<int>> a(k + 1, vector<int>(k2 + 1));
    int p[2] = {};
    for (int i = 0; i < n; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;

        x %= k2;
        if (x >= k) {
            x -= k;
            y += k;
        }
        a[x + 1][y % k2 + 1] += c == 'B' ? 1 : -1;
        p[c == 'B' ? 0 : 1]++;
    }

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k2; j++) {
            a[i][j] += a[i][j - 1];
        }
    }
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k2; j++) {
            a[i][j] += a[i - 1][j];
        }
    }

    int r = 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k2; j++) {
            int t;
            if (j < k) {
                t = a[k][j + k] - a[k][j] - a[i][j + k] + 2 * a[i][j];
                t += a[i][k2] - a[i][j + k];
            } else {
                t = a[k][k2] - a[k][j] - a[i][k2] + a[i][j];
                t += a[i][j] + a[k][j - k] - 2 * a[i][j - k];
            }
            r = max(r, t + p[1]);
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int P, Q, R;

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);

  cin >> P >> Q >> R;

  cout << min(P+Q, min(R+Q, R+P)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{	
	int ans;
	int n;
	int omosa=5;
	while(cin>>n,n!=0){
		ans=0;
		omosa=5;
		while(1){
			if(n/omosa==0)break;
			ans+=n/omosa;
			omosa*=5;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < s.size(); i++) {
        ans += s[i] != s[i - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

vector<ll> getDivisor(ll x) {
    vector<ll> res;
    for(ll i=1; i*i<=x; ++i) {
        if (x%i == 0) {
            res.push_back(i);
            if (x/i != i) res.push_back(x/i);
        }
    }
    return res;
}

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

    int n; cin >> n;
    ll k; cin >> k;
    ll sum = 0;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; sum += a[i]; }

    auto div = getDivisor(sum);
    sort(div.begin(), div.end());

    ll ans = 1;
    for(auto x: div) {
        vector<ll> r(n);
        rep(i, n) r[i] = a[i]%x;
        sort(r.begin(), r.end());
        vector<ll> cum(n+2, 0);
        rep(i, n) cum[i+1] = r[i] + cum[i];
        cum[n+1] = cum[n];
        bool ok = false;
        rep(i, n+1) if (max(cum[i], -(cum[n]-cum[i]) + x*(n-i)) <= k) { ok = true; break; }
        if (ok) chmax(ans, x);
    }
    cout << ans << endl;
    
    return 0;
}


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

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

ll X, Y;

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

    ll num = X;
    ll ans = 0;
    while (num <= Y){
        ans++;
        num *= 2;
    }
    
    cout << ans << endl;
}

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



signed main(){
    int l,t;
    cin >> l;
    int a[l][5],u[4];
    cin >> t;
    a[0][0]=t;
    a[0][1]=( t==0 ? 2 : t%2);
    a[0][2]=(t+1)%2;
    a[0][3]=( t==0 ? 2 : t%2);
    a[0][4]=t;
    for(int i=1;i<l;i++){
        cin >> t;
        a[i][0]=a[i-1][0]+t;
        u[0]=min(a[i-1][0],a[i-1][1]);u[1]=min(u[0],a[i-1][2]);u[2]=min(u[1],a[i-1][3]);u[3]=min(u[2],a[i-1][4]);
        a[i][1]=u[0]+( t==0 ? 2 : t%2);a[i][2]=u[1]+((t+1)%2);a[i][3]=u[2]+( t==0 ? 2 : t%2);a[i][4]=u[3]+t;
    }
    int ans=a[l-1][0];
    
    for(int i=1;i<5;i++)if(ans>a[l-1][i])ans=a[l-1][i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 8064
class Process_Queue:
    class Process:
        def __init__(self, name, r_time, link = None):
            self.name = name
            self.r_time = r_time
            self.link = link

    def __init__(self, q):
        self.size = 0
        self.e_time = 0
        self.q = q
        self.front = None
        self.rear  = None

    def enqueue(self, name, r_time):
        if self.size == 0:
            self.front = self.rear = Process_Queue.Process(name, r_time)
        elif self.size == 100000:
            raise Exception("queue overflow")
        else:
            new_process = Process_Queue.Process(name, r_time)
            self.rear.link = new_process
            self.rear = new_process
        self.size += 1

    def dequeue(self):
        if self.size == 0:
            raise Exception("queue underflow")
        elif self.front.r_time > self.q:
            self.enqueue(self.front.name, self.front.r_time - self.q)
            self.front = self.front.link
            self.e_time += self.q
        elif self.front.r_time <= self.q:
            p_name = self.front.name
            self.e_time += self.front.r_time
            print(p_name, self.e_time)
            self.front = self.front.link
        self.size -= 1
        if self.size == 0:
            self.rear = None
                
    def isEmpty(self):
        return self.size == 0
    
    def isFull(self):
        return self.size == 100000


n, q = map(int, input().split())

p_queue = Process_Queue(q)

for i in range(n):
    p = input().split()
    p_queue.enqueue(p[0], int(p[1]))

while not p_queue.isEmpty():
    p_queue.dequeue()

Measured memory_bytes: 18752
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll pow(ll x, ll y) {
    ll ret = 1;
    while(y-- > 1) ret *= x;
    return ret;
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    ll r = x / y;
    return gcd(y, x-y*r);
}

int run(istream& in, ostream& out) {
    ll N, K ;
    in >> N >> K;
    ll ans = 0;
    while(N > 0) {
        N /= K;
        ans++;
    }
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char s[10];
  int c=0,cmax=0,i;
  scanf("%s",s);
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
		++c;
    if(s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C')
    	c=0;
    if(s[i]=='\0')
      break;
    if(c>cmax)
      cmax=c;
  }
  
  printf("%d",cmax);
  
  return 0;
}

Measured memory_bytes: 128
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
int dp[101000];
vector<ll> a;
ll n, k;
int recurse(ll kk) {
	if(dp[kk] != -1) return dp[kk];
 	if(kk < a[0]) return 0	;
 	int ans = 0;
 	for(auto it: a) {
 		if(kk - it < 0) ans = (ans | 0);
 		else 
 		{
 		   ans = ans | (!recurse(kk-it));
 		}
 	}
 	return dp[kk] = ans;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> k; 
  a.resize(n);
  memset(dp, -1 , sizeof(dp));
  for(ll i = 0; i < n; i++)cin >> a[i];
  sort(a.begin(), a.end());
  if(recurse(k)) cout << "First";
  else {
  	cout << "Second" ;
  }
  return 0;
} //good night.

Measured memory_bytes: 5376
def main(num):
	
	c1 = abs(num[0]-num[1])
	c2 = abs(num[2]-num[1])
	c3 = abs(num[0]-num[2])
	
	cost = min(c1+c2, c1+c3, c2+c3)
	
	return cost



num = input().split(" ")
num = [int(c) for c in num]
print(main(num))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];
    int hmax = 0;
    int ans = 0;
    rep(i,n){
        if(hmax <= h[i]){
            ans++;
            hmax = h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	long long tmp=x,ans=1;
	while(tmp*2<=y)
	{
		tmp*=2;ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <array>
#include <tuple>
#include <utility>
#include <cctype>
#include <typeinfo>
using namespace std;

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define ii(n)    ff(i, n)
#define kk(n)    ff(k, n)
#define mm(n)    ff(m, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define iii(a, b) fff(i, a, b)
#define kkk(a, b) fff(k, a, b)
#define mmm(a, b) fff(m, a, b)
#define xx first
#define yy second
#define bb begin()
#define ee end()
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }

using LL = long long;
using pii = pair<int, int>;


const LL INF = 9223372036854775807LL;
//const int INF = 2147483647;
   




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << '\n';
    

    int N, A, B;
    cin >> N >> A >> B;
    vector<int> Xs(N);
    ii (N)
        cin >> Xs[i];

    LL rr = 0;
    iii (1, N) {
        LL dist = Xs[i] - Xs[i-1];
        rr += min(dist * A, LL(B));
    }

    cout << rr << '\n';


    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#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
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,0,sz(s))
    {
      int j=i;
      while(j<sz(s) && s[j]==s[i]) j++;
      j--; i=j;
      ans++;
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
map<int,int> memf,mems;
const int M=1e9+7;
int f(int n){
	if(n<=1)return 1;
	if(memf.find(n)==memf.end()){
		int k=n/2;
		if(k+k==n){
			memf[n]=(f(k)+f(k-1))%M;
		}else{
			memf[n]=f(k);
		}
	}
	return memf[n];
} 
int s(int n){
	if(n<=1)return n+1;
	if(mems.find(n)==mems.end()){
		int k=n/2;
		if(k+k==n){
			mems[n]=(3*s(k-1)+f(k))%M;
		}else{
			mems[n]=(3*s(k-1)+2*f(k))%M;;
		}		
	}
	return mems[n];
}

int32_t main(){
	int n;
	cin>>n;
	cout<<s(n)<<'\n';
	return 0;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		int N, a, d, M, K;
		int x, y, z;
		Scanner sc = new Scanner(System.in);
		List<Integer> ID = new ArrayList<Integer>();
		List<Integer> val = new ArrayList<Integer>();

		N = sc.nextInt();
		a = sc.nextInt();
		d = sc.nextInt();
		M = sc.nextInt();
		for (int i = 0; i < M; ++i) {
			x = sc.nextInt();
			y = sc.nextInt() - 1;
			z = sc.nextInt() - 1;
			int tmpy;
			int tmpz;
			if (x == 0) {
				if (ID.contains(y)) {
					tmpy = val.get(ID.indexOf(y));
					val.remove(ID.indexOf(y));
					ID.remove(ID.indexOf(y));
				} else {
					tmpy = a + y * d;
				}
				if (ID.contains(z)) {
					tmpz = val.get(ID.indexOf(z));
					val.remove(ID.indexOf(z));
					ID.remove(ID.indexOf(z));
				} else {
					tmpz = a + z * d;
				}
				ID.add(z);
				val.add(tmpy);
				ID.add(y);
				val.add(tmpz);
			} else if (x == 1) {
				if (ID.contains(z)) {
					tmpz = val.get(ID.indexOf(z));
				} else {
					tmpz = a + z * d;
				}

				if (ID.contains(y)) {
					tmpy = val.get(ID.indexOf(y));
					val.remove(ID.indexOf(y));
					ID.remove(ID.indexOf(y));
				}
				ID.add(y);
				val.add(tmpz);
			}
		}
		K = sc.nextInt() - 1;
		sc.close();
		int tmp;
		if (ID.contains(K)) {
			tmp = val.get(ID.indexOf(K));
		} else {
			tmp = a + K * d;
		}
		System.out.println(tmp);
	}
}



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

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) (v.size())
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;

const LL MOD = 1000000000 + 7;

/* nを素因数分解する(O(n^(1/2)))
 * primeFactorDecomposition(12) : {2:2, 3:1} 
 */
map<int, int> primeFactorDecomposition(int n) {
    map<int, int> m;
    while (n > 1) {
        bool findFactor = false;
        for(int i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                m[i]++;
                n /= i;
                findFactor = true;
                break;
            }
        }
        if (!findFactor) {
            m[n]++;
            break;
        }
    }
    return m;
}

int main(int argc, char *argv[]) {
    
    int N;
    cin >> N;
    map<int, int> m;
    for(int n = N; n >= 1; --n) {
        FOE(p, primeFactorDecomposition(n)) {
            m[p.first] += p.second;
        }
    }
    
    LL ans = 1;
    FOE(p, m) {
        ans *= (p.second + 1);
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

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

int main()
{
	int N, M;

	cin >> N >> M;

	int X[M];

	for (int i = 0; i < M; i++)
	{
		cin >> X[i];
	}

	sort(X, X + M);

	int distance[M - 1];

	for (int i = 0; i < M - 1; i++)
	{
		distance[i] = X[i + 1] - X[i];
	}

	sort(distance, distance + M - 1);

	int ans = 0;

	for (int i = 0; i < M - 1 - (N - 1); i++)
	{
		ans += distance[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define per(x,a,b) for(int x=a;x>=b;x--)
using namespace std;

int a[maxn],n;
vector<int> v;
set<int> st;
queue<int> q;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	if(n%4==0||n%7==0)
		return puts("Yes"),0;
	for(int i=1;i*4<=n;i++)
		if((n-i*4)%7==0)
			return puts("Yes"),0;
	puts("No");
	return 0;
}

Measured memory_bytes: 256
a=(0...3).flat_map{gets.split.map(&:to_i)}
gets
b=ARGF.map(&:to_i)

a.map!{|x| b.include?(x) }


r = (0...3).any?{|x| a[x*3+0] &&  a[x*3+1] &&  a[x*3+2] } || (0...3).any?{|x| a[x+0] &&  a[x+3] &&  a[x+6] } || (a[0] &&  a[4] &&  a[8]) || (a[2] &&  a[4] && a[6])

print (r ? 'Yes' : "No")

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    if (a == b && a != c) ans = true;
    if (a == c && a != b) ans = true;
    if (b == c && b != a) ans = true;

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}



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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

char S[N],T[N];

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    scanf("%s%s",S+1,T+1);
    int n=strlen(S+1);
    int m=strlen(T+1);
    int ans=1e9;
    for(int i=1;i<=n-m+1;i++){
        int r=0;
        for(int j=1;j<=m;j++){
            if(S[i+j-1]!=T[j]) r++;
        }
        ans=min(ans,r);
    }
    cout<<ans<<endl;
    return 0;
}

//Created Time  :2020/8/29 20:00:20


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll l; cin >> l;
  l--;
  vector<vector<P>> g(20);
  int now = 1;
  int cnt = 0;
  for(int i=0;i<18;++i) {
    g[i].push_back({i+1, 0});
    g[i].push_back({i+1, now});
    cnt += 2;
    now <<= 1;
  }
  int tmp = now;
  g[0].push_back({19, 0});
  cnt++;
  now = 1;
  for(int i=0;i<19;++i) {
    if(l & (1<<i)) {
      g[i].push_back({19, now});
      cnt++;
      now = now + (1<<i);
    }
  }
  if(l & (1<<19)) {
    g[18].push_back({19, now});
    g[18].push_back({19, tmp + now});
    cnt += 2;
  }
  cout << 20 << " " << cnt << endl;
  for(int i=0;i<20;++i) {
    for(int j=0;j<(int)(g[i].size());++j) {
      cout << i+1 << " " << g[i][j].first+1 << " " << g[i][j].second << endl;
    }
  }
}


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
  	int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl; 
}

Measured memory_bytes: 256
from sys import stdin
a,b = map(int,stdin.readline().rstrip().split())
#0からnまでの排他的論理和の和
def xor(n):
    point = ((n+1)//2)%2
    if n%2 == 0:
        if point == 0:
            return 0^n
        else:
            return 1^n
    else:
        if point == 0:
            return 0
        else:
            return 1
print(xor(a-1)^xor(b))

Measured memory_bytes: 3064
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(array.Aggregate(0, (acc,suc)=> acc += Div2s(suc)));
    }
    static int Div2s(int n)
    {
        int count = 0;
        while(n % 2 == 0)
        {
            n /= 2;
            count++;
        }
        return count;
    }
}

Measured memory_bytes: 14176
from itertools import accumulate, islice
from bisect import bisect_left

n = int(input())
xs = [int(x) for x in input().split()]

ys = list(accumulate(xs))
zs, total = ys[:-1], ys[-1]

res = max(xs) - min(xs)
for i, z in islice(enumerate(zs), 1, n-1):
    j = bisect_left(zs, z//2)
    splits = ((zs[j+k], z - zs[j+k]) for k in (-1, 0, 1) if 0 <= j+k <= i)
    a, b = min(splits, key=lambda s:abs(s[0]-s[1]))

    j = bisect_left(zs, (total - z)//2 + z)
    splits = ((zs[j+k] - z, total - zs[j+k]) for k in (-1, 0, 1) if i <= j+k <= n-2)
    c, d = min(splits, key=lambda s:abs(s[0]-s[1]))

    minn, _, _, maxx = sorted((a,b,c,d))
    if maxx - minn < res:
        res = maxx - minn

print(res)

Measured memory_bytes: 24308
import java.util.*;
import java.io.*;

public class Main {
	// https://atcoder.jp/contests/abc163/tasks/abc163_a
	
	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("CirclePond"));

		int r = Integer.parseInt(in.readLine());  
		System.out.println(2 * r * Math.PI);

	}

}


Measured memory_bytes: 33152
#include <stdio.h>
#include <stdlib.h>
int main() {
	char score[100];
	int N,i,j=0;
	scanf("%d",&N);
	scanf("%s",score);
	for(i=0;i<N-2;i++){
		if(score[i]=='A'&&score[i+1]=='B'&&score[i+2]=='C'){
			j++;
			i=i+2;
		}
	}
	printf("%d",j);
	return 0;
} 

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    ans = max(ans, i * i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = list(input())
ops = ['+', '-']
fin = False
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = a+op1+b+op2+c+op3+d
            res = eval(s)
            if res == 7:
                print(s+'=7')
                fin = True
                break
        if fin == True:
            break
    if fin == True:
        break

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int ave = 0;
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
			ave += a[i];
		}
		for(int i=0;i<n;i++) {
			a[i] *= n;
		}
		int nearestIdx = n-1;
		int minAbSub = Math.abs(a[n-1]-ave);
		for(int i=n-2;i>=0;i--) {
			int nowAbSub = Math.abs(a[i]-ave);
			if(nowAbSub<=minAbSub) {
				minAbSub = nowAbSub;
				nearestIdx = i;
			}
		}
		System.out.println(nearestIdx);
		in.close();
	}

}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  int r=0;
  int t=0;
  cin >> s;
  for(auto x:s){
    if(x=='A'||x=='T'||x=='G'||x=='C'){
      t++;
    }
    else{
      if(t==0)continue;
      else if(t>r)r=t;
      t=0;
    }
  }
  cout<<(r>t?r:t)<<endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
pw = []
d = 2
while d*d <= m:
  e = 0
  while m % d == 0:
    e += 1
    m //= d
  if e > 0: pw.append(e)
  d += 1
if m > 1: pw.append(1)
ans = 1
for e in pw:
  comb = 1
  for i in range(e):
    comb = comb * (n+i) // (1+i)
  ans = ans * comb % 1000000007
print(ans)

Measured memory_bytes: 3064
Sa = input()
Sb = input()
Sc = input()
data = [Sa, Sb, Sc]
target = 0
while True:
    if(data[target] == ""):
        if target == 0:
            print("A")
        if target == 1:
            print("B")
        if target == 2:
            print("C")
        break
    if data[target][0] == "a":
        data[target] = data[target][1:]
        target = 0
    elif data[target][0] == "b":
        data[target] = data[target][1:]
        target = 1
    elif data[target][0] == "c":
        data[target] = data[target][1:]
        target = 2

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

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    while(1){
        int data[10]={};
        int n;
        cin>>n;
        if(n==0)break;
        rep(i,n){
            int a;
            cin>>a;
            if(a<10)data[0]++;
            else if(a<20)data[1]++;
            else if(a<30)data[2]++;
            else if(a<40)data[3]++;
            else if(a<50)data[4]++;
            else if(a<60)data[5]++;
            else data[6]++;
        }
        rep(i,7)cout<<data[i]<<endl;
    }
    return 0;
}

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

int main()
{
int n , t;
cin>>n>>t;
int ans = INT_MAX , c , v;
for(int i = 0; i < n; i++)
{
cin>>c>>v;
if(v<= t)
{
ans = min(ans , c);
}
}
if(ans==INT_MAX)
cout<<"TLE"<<endl;
else
cout<<ans<<endl;
}

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

int main() {
    char s[3];
    cin >> s;

    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define DIGIT 4
int main(void)
{
	int i, j, n;
	int s;
	char* numCodeCenter;
	char  numCode[DIGIT*2 +1]={0};
	
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &s);
		printf("Case %d:\n", i+1);
		for(j=0; j<10; j++)
		{
			// printf("%0*d ", DIGIT*2, s*s);
			sprintf(numCode, "%0*d", DIGIT*2, s*s);
			numCodeCenter        = &numCode[DIGIT/2];
			numCodeCenter[DIGIT] = '\0';
			s = atoi(numCodeCenter);
			printf("%d\n", s);
		}
	}
	return 0;
}

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

int main() {
   int n;
   cin >> n;
    bool a = false;
    int seki;
    
   for(int i = 1; i < 10; i++){
   for(int j = 1; j < 10; j++){
    seki = i * j;
    if(seki == n){
    a = true;
    }
   }
       }
    
    if(a) {
    cout << "Yes";
    }
    else {
    cout << "No";
    }
}

Measured memory_bytes: 256
def examA():
    Q, H, S, D = LI()
    N = I()
    economical2 = min(Q*8, H*4, S*2, D)
    economical1 = min(Q*4, H*2, S)
    ans = (N//2)*economical2 + (N%2)*economical1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()

Measured memory_bytes: 38384
#include <stdio.h>
int main(void) {
    int n,i,tmp,tmp2;
    int flag = 0;
    scanf("%d", &n);
    for(i=1;i<10;i++){
        tmp = n%i;
        tmp2 = n/i;
        if(tmp==0 && tmp2<10){
            flag=1;
            break;
        }
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int x[107], y[107], h[107];
int X, Y, H;
 
int main() {
	scanf("%d", &n);
	int dd;
	for(int i = 1; i <= n; i++) {
		scanf("%d %d %d", &x[i], &y[i], &h[i]);
		if(h[i]) dd = i;
	}
	for(int i = 0; i <= 100; i++) {
		for(int j = 0; j <= 100; j++) {
			X = i, Y = j;
			H = h[dd] + abs(x[dd] - X) + abs(y[dd] - Y);
			for(int k = 1; k <= n; k++) {
				int t1 = abs(x[k] - X), t2 = abs(y[k] - Y);
				if(h[k] != max(H - t1 - t2, 0)) break;
				if(k == n) {
					printf("%d %d %d\n", X, Y, H);
					return 0;
				}
			}
		}
	}
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    long long K;
    cin >> K;
    K--;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != '1') {
            if (K <= i) {
                cout << S[K] << endl;
            } else {
                cout << S[i] << endl;
            }
            return 0;
        }
    }
    cout << '1' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    vector<char>v;
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='B' && v.size()>0)
        {
            v.pop_back();
        }
        else if(s[i]!='B')
        {
            v.push_back(s[i]);
        }

    }
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i];
    }
    v.clear();
return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
 
N, M = MAP()

time = 100*(N-M) + 1900*M
fail_probability = 1 - (1/2)**M

ans = time * 1/(1-fail_probability)

print(int(ans))

Measured memory_bytes: 5200
amount, num = map(int, input().split())

hate_num_list = list(map(str, input().split()))

while(True):

    check = 0

    for digit in str(amount):

        if digit in hate_num_list:
            check += 1

    if check == 0:
        print(amount)
        break

    else:
        amount += 1

Measured memory_bytes: 2940
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    --N;
    vector<ll> C(N), S(N), F(N);
    for (int i = 0; i < N; i++) cin >> C[i] >> S[i] >> F[i];
    for (int i = 0; i < N; i++) {
      ll res = 0;
      for (int j = i; j < N; j++) {
        ll start = (max(S[j], res) + F[j] - 1) / F[j] * F[j];
        res = start + C[j];
      }
      cout << res << endl;
    }
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = len(bin(k))-2
if k == 0:
    l = 0
memo = [0 for i in range(l)]

for ai in a:
    for j in range(l):
        if ai & (1<<j):
            memo[j] += 1

x = 0
f = 0

for j in reversed(range(l)):
    if f or k & (1<<j):
        if memo[j] < n - memo[j]:
            x += 2 ** j
        else:
            f = 1
ans = 0

for ai in a:
    ans += ai ^ x

print(ans)

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


signed main(){
    string S;cin>>S;
    int K;cin>>K;
    int N=S.size();
    set<string> dict;
    for(int i=1;i<=K;i++){
        for(int j=0;j<N-i+1;j++){
            string T="";
            for(int p=0;p<i;p++)T+=S[j+p];
            dict.insert(T);
        }
    }
    vector<string> ans;
    for(auto T:dict){
        ans.push_back(T);
    }
    sort(ans.begin(),ans.end());    
    cout<<ans[K-1]<<endl;
}

Measured memory_bytes: 1920
from itertools import combinations
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")
for i in range(1, n+1):
  for i1 in combinations(ca, i):
    nums = [0]*(m+1)
    for i2 in i1:
      for i3 in range(m+1): nums[i3] += i2[i3]
    if min(nums[1:]) >= x:
      if nums[0] < ans: ans = nums[0]
if ans == float("inf"): print(-1)
else: print(ans)

Measured memory_bytes: 9132
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, m, i, j;
    int[] c, dp;
    n = sc.nextInt(); m = sc.nextInt();
    dp = new int[n + 1]; c = new int[m];
    for(i = 0;i < m;i++)c[i] = sc.nextInt();
    for(i = 0;i < n + 1;i++)dp[i] = n * 2;
    dp[0] = 0;
    for(i = 0;i < n + 1;i++)if(dp[i] != n * 2)
      for(j = 0;j < m;j++)if(i + c[j] <= n && dp[i] + 1 < dp[i + c[j]])
        dp[i + c[j]] = dp[i] + 1;
    out.println(dp[n]);


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 27192
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <assert.h>
#include <random>
#include <bitset>
#include <string>
#include <cstring>
#include <memory.h>

using ll = long long;

const int inf = 1e9;
const ll infll = 1e18;

using namespace std;


struct Solution {
	Solution() {
		ll n;
		cin >> n;
		ll five = 0;
		if (n & 1) {
			cout << 0;
			return;
		}
		for (ll x = 2 * 5; x <= 2e18; x *= 5) {
			five += n / x;
		}
		cout << five << endl;
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (; t; t--) {
		Solution s;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    set<string> st;
    int n;
    cin >> n;
    rep(i, n) {
        string com, s;
        cin >> com >> s;
        if (com == "insert") {
            st.insert(s);
        } else {
            cout << (st.count(s) ? "yes" : "no") << endl;
        }
    }
}



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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, char *argv[])
{
  ll n;
  scanf("%lld", &n);

  printf("%lld\n", (n - 1) * n / (ll)2);

  return 0;
}


Measured memory_bytes: 128
a, b = map(int, input().split())
s = input()
ans = "Yes"
for i, s_i in enumerate(s):
    if i == a:
        if s_i == "-":
            pass
        else:
            ans = "No"
            break
    else:
        if s_i != "-":
            pass
        else:
            ans = "No"
            break
print(ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

string f(string s) {
  string t = string(s.size(), '.');
  char u = 'a';
  REP(i, s.size()) {
    if (s[i] != '.') {
      char p = s[i];
      REP(j, t.size()) {
        if (s[j] == p) {
          t[j] = u;
          s[j] = '.';
        }
      }
      REP(j, s.size()) if (s[j] == p) s[j] = '.';
      u++;
    }
  }
  return t;
}

int main2() {
  string s1, s2;
  cin >> s1 >> s2;
  // cout << s1 << " " << f(s1) << endl;
  // cout << s2 << " " << f(s2) << endl;

  if (f(s1) == f(s2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1544
#include<stdio.h>

int binarySearch(int T,int S[],int n){
    int left,right,mid;
    
    left=0;
    right=n;
    while(left<right){
        mid=(left+right)/2;
        if(T==S[mid]){
            return 1;
        }else if(T<S[mid]){
            right=mid;
        }else{
            left=mid+1;
        }
    }
    
    return 0;
}

int main(void){
    int n,q,S[100000],T[50000];
    int i,j,count=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&T[i]);
    }
    
    for(i=0;i<q;i++){
        if(binarySearch(T[i],S,n)==1){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2312