akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, K; cin >> N >> K;
  ll sum = 0;
  // a = b * q + r

  // b = 0 ... NG
  // b = 1; r = 0
  // b = 2; r = 0, 1
  // ...

  // r >= K より, b >= K + 1
  // b = B; r = K, ..., B - 1
  //        a = B * q + r

  REP(b, K + 1, N + 1) {
    // r = K, ..., B - 1
    // q = 0, ..., N / b (各q に対して B - K 個の r が存在)
    // #a = #q * (B - K) + max(0, (N % B) - K + 1)
    // 但し、K = 0 の場合、b に対して q = 0, r = 0 のケースを取り除く
    sum += N / b * (b - K) + max(0, (N % b) - K + 1);
    if (K == 0) sum--;
  }
  cout << sum << "\n";
}


Measured memory_bytes: 256
k = int(input())
if k == 1:
	print(1)
	print(1)
else:
	n = (k+3) // 4 * 2
	ans = [[0 for _ in range(n)] for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if i % 2 == 0:
				ans[i][j] = (i+j) % n + 1
			else:
				if (i+j) % n + n+1 > k:
					ans[i][j] = (i+j) % n + 1
				else:
					ans[i][j] = (i+j) % n + n+1
	print(n)
	for i in range(n):
		print(*ans[i])

Measured memory_bytes: 12384
def solve():
    a, b = list(map(int, input().split(" ")))
    if 0 < a <= b:
        print("Positive")
    elif a <= b < 0:
        if (b-a)%2==1:
            print("Positive")
        else:
            print("Negative")
    elif a < 0 < b:
        print("Zero")
    return
 
solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n, m;
    cin >> n >> m;
    ll a[n], b[n];
    for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll c[m], d[m];
    for (ll i = 0; i < m; i++) cin >> c[i] >> d[i];
    for (ll i = 0;i<n;i++){
        ll ans = INF;
        ll res;
        for (ll j = 0; j < m; j++) {
            if (chmin(ans, abs(a[i] - c[j]) + abs(b[i] - d[j]))) res = j + 1;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
long long N,M,Q;
cin>>N>>M>>Q;

unsigned int pat[N][N]={};


rep(i,M){
int l,r;
cin>>l>>r;
l--,r--;
pat[l][r]++;
}

for(int i=0;i<N-1;i++){
    for(int k=i+1;k<N;k++){
        pat[i][k]+=pat[i][k-1];
    }
}

for(int i=N-1;i>0;i--){
    for(int k=i-1;k>=0;k--){
        pat[k][i]+=pat[k+1][i];
    }
}

rep(i,Q){
    int p,q;
    cin>>p>>q;
    p--,q--;
    cout<<pat[p][q]<<endl;
}
 return 0;
}
/*
2 3 1
1 1
1 2
2 2
1 2

3


10 3 2
1 5
2 8
7 10
1 7
3 10

1
1


10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10

7
9
10
6
8
9
6
7
8
10
*/

Measured memory_bytes: 1920
#include <stdio.h>

long long gcd(long long x,long long y){
  long long r;
  if(x>y){
    long long t = y;
    y = x;
    x = t;
  }
  while((r = y % x) != 0){
    y = x;
    x = r;
  }
  return x;
}

int main(){
  long long T[100],ans=1,sp;
  int i,j,N;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lld",&T[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(T[j]>T[j-1]){
      sp=T[j];
      T[j]=T[j-1];
      T[j-1]=sp;
      }
    }
  }
  ans = T[0];
  for(i=1;i<N;i++){
    if(ans%T[i]==0){
      continue;
    }
      else{
      ans = ans/gcd(ans,T[i])*T[i];
      }
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128
n,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

cnt = 0

for i in range(n):
    if i == n-1 and a[i] < x:
        break    
    if a[i] <= x:
        cnt += 1
        x -= a[i]

        

print(cnt)

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll n;
const ll mod= 1e5;

int main() {
    cin >> n;
	if(n==0)
		cout << 1 << "\n";
	else if(n==1)
		cout << 2 << "\n";		
	else if(n==2)
		cout << 1 << "\n";
	else
		cout << 0 << "\n";
	return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int AC=0,WA=0,TLE=0,RE=0;
  cin>>N;
  string A;
  for(int i=0;i<N;i++){
    cin>>A;
    if(A=="AC"){AC++;}
    if(A=="WA"){WA++;}
    if(A=="TLE"){TLE++;}
    if(A=="RE"){RE++;}
  }
  cout <<"AC x "<<AC<<endl<<"WA x "<<WA<<endl<<"TLE x "<<TLE<<endl<<"RE x "<<RE<<endl;
  
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  
  rep(i,N){
    cin >> A.at(i);
  }
  rep(i,N){
    cin >> B.at(i);
  }
  rep(i,N-1){
    cin >> C.at(i);
  }
  
  int sum=0;
  rep(i,N){
    sum+=B.at(A.at(i)-1);
  }
  rep(i,N-1){
    if(A.at(i)+1 == A.at(i+1)) sum += C.at(A.at(i)-1);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io::Read;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();
    let z: usize = iter.next().unwrap().parse().unwrap();

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  vll cnt(26, 0);
  for (char c : s) cnt[c - 'a']++;

  ll kif = n * (n - 1) / 2 + 1;
  rep(i, 26) kif -= cnt[i] * (cnt[i] - 1) / 2;
  cout << kif << endl;

  return 0;
}


Measured memory_bytes: 3748
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int x,y,z;cin >> x >> y >> z;
    int w=y+z;
    x-=z;
    cout << x/w << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int left = -1000000;
    int right = 1000000;

    int k,x; cin >> k >> x;

    int min = x - (k - 1);
    int max = x + (k - 1);

    for(int i = min; i<max ;i++)
    {
        cout << i << " ";
    }

    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
 
struct block {
    int w, s, v;
};
 
bool cmp(const block &x, const block &y) {
    return x.w + x.s > y.w + y.s;
}
 
const int N = 2e4+10;
int memo[N];
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<block> arr(n);
    for(int i = 0; i < n; ++i) {
        cin >> arr[i].w >> arr[i].s >> arr[i].v;
    }
    sort(arr.begin(), arr.end(), cmp);
    int res = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= arr[i].s; ++j) {
            memo[j] = max(memo[j], arr[i].v + memo[j+arr[i].w]);
            res = max(res, memo[j]);
        }
    }
    cout << res << '\n';
}
 
 
 
 
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int v[N];
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    int a,b;
    cin >> a >> b;
    if(a == 1 && b == 1)
        cout << "Draw\n";
    else if(a == 1)
        cout << "Alice\n";
    else if(b == 1)
        cout << "Bob\n";
    else{
        if(a == b)
            cout << "Draw\n";
        else if(a > b)
            cout << "Alice\n";
        else
            cout << "Bob\n";
    }
    return 0;   
}

Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Threading;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            string[] input2 = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            int count=0;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input2[i]);
            }

            for (int j = 0; j < n; j++)
            {
                if ((j + 1) % 2 == 1)
                {
                    if (a[j] % 2 == 1)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 17852
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    cout << n-k+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int[] A=new int[N];
        int i;
        int answer=0;
        for(i=0;i<N;i++){
            A[i]=scan.nextInt();
            for(int j=0;j<i;j++){
                if(answer<Math.abs(A[i]-A[j])){
                    answer=Math.abs(A[i]-A[j]);
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
import collections
n, m = map(int, input().split())
par = [i for i in range(n)]
# print(par)
s = list()
"""
# union find(parには0も入れているので、par[1]=1になる)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
"""


def find(x):

    while par[x] != x:
        tmp = par[x]
        par[x] = par[par[x]]
        x = par[x]

    return x


def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    else:
        par[x] = y


# 各要素をunionする
for j in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)

# 1～nの親を探してsに入れていき、一番多い親を答えにする
for k in range(n):
    s.append(find(k))
# print(s)
c = collections.Counter(s)
print(max(c.values()))


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC161
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int N, M;
    
  cin >> N >> M;
  
  vector<int> A(N);
  
  int sum=0;
  
  REP(i, N){
    cin >> A[i];
    sum += A[i];
  }
  
  sort(ALL(A), greater<>());
  
  bool flag=true;
  
  REP(i,M){
    if(A[i]*4*M<sum){flag=false; break;}
  }
  
  puts(flag?"Yes":"No");
  
  
  
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D

if __name__ == '__main__':
    S = int(raw_input())
    h = S / 3600
    m = (S % 3600) / 60
    s = S % 60
    print "%d:%d:%d" % (h, m, s)


Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n";

void Main()
{
	ll X, A,B;
	ll result=0;
	string S;
	cin>>X>>A>>B;
	result=(X-A)%B;
	
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
 
  int n;
  long long ans=0;
  scanf("%d",&n);
  
  int a[n],i;
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
   for(i=0;i<n-1;i++){
     if(a[i]>a[i+1]){
       ans+=a[i]-a[i+1];
       a[i+1]+=a[i]-a[i+1];
     }
   }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2480
#include <iostream>
#include <string>
using namespace std;
string str,tmp;
int solve(string judge){
      int t = judge.length();
      for(int i=0;i<t;i++){
            if(str[0]!=judge[i])continue;
            for(int j=i+1;j<t;j++){
                  if(str[1]!=judge[j])continue;
                  for(int k=2;;k++){
                        if(k==str.length())return 1;
                        if(i+(j-i)*k>=t||str[k]!=judge[i+(j-i)*k])break;
                  }
            }
      }
      return 0;
}
int main(){
      int x,ctn = 0;
      cin>>x>>str;
      for (int i = 0;i < x ; i++){
            cin >> tmp;
            ctn += solve(tmp);
      }
      cout<<ctn<<endl;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>
int main(void)
{
 int i;
 char S[7][4] = { "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" , "SUN" };


 char Sa[4];
 scanf("%s",Sa);
 if (strcmp(Sa,"SUN")==0) 
  {
  printf("7\n");
  return 0;
  }

 for(i=0;i<7;i++)
  if(strcmp(Sa,S[i])==0) printf("%d\n",(7-i-1)%7);

 return 0;
}



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


void solve(long long N, long long X, std::vector<long long> m){
    long long sum = 0;
    long long mi = 1e9;
    for (int i = 0; i < N; i++) {
        sum += m[i];
        mi = min(mi, m[i]);
    }
    int counter = 0;
    X -= sum;
    while (X >= 0) {
        X -= mi;
        counter += 1;
    }
    cout << N + counter - 1 << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> m(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&m[i]);
    }
    solve(N, X, std::move(m));
    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

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

bool check(vector<P> p){
    int n = p.size();
    sort(ALL(p));
    // REP(i,n) cout << p[i].first << " " << p[i].second << endl;
    int s = 0, j = 0;
    multiset<int> st;
    REP(i,n){
        while (j < n && p[j].first <= s){
            st.insert(-p[j].second);
            j++;
        }
        if (st.empty()) return false;
        int x = -*st.begin();
        s += x;
        st.erase(st.find(-x));
    }
    return true;
}

int main(void){
    int n;
    cin >> n;
    VI d(n), mi(n);
    int sum = 0;
    REP(i,n){
        string s;
        cin >> s;
        int x = 0, m = 0;
        for (char c : s){
            if (c == '(') x++;
            else x--;
            chmin(m, x);
        }
        d[i] = x;
        mi[i] = m;
        sum += x;
    }
    if (sum != 0){
        cout << "No" << endl;
        return 0;
    }
    vector<P> up, down;
    REP(i,n){
        if (d[i] >= 0){
            up.push_back(P(-mi[i], d[i]));
        }else{
            down.push_back(P(d[i] - mi[i], -d[i]));
        }
    }
    if (check(up) && check(down)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 49944
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp
 
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()
 
using namespace std;
 
template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<int>());
    return;
}
 
template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<int>());
    return;
}
 
int main(){
    vector<char> c;

    int n;
    cin >> n;

    if(n == 0){
        cout << '0' << endl;
        return 0;
    }

    while(n){
        if(n % -2 == 0){
            c.push_back('0');
            n /= -2;
        }
        else{
            c.push_back('1');
            if(n == 1) break;
            n /= -2;
            if(n >= 0) n += 1;
        }
    }

    for(int i = c.size() - 1; i >= 0; i--) cout << c[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;

typedef long long LL ;
const int N = 200010 , mod = 1000000007;
int a[N];


signed main()
{
    int n , k ;
    scanf("%lld%lld",&n,&k);
    for(int i = 0 ; i < n ; i ++) scanf("%lld",&a[i]);

    sort(a,a + n);

    LL res = 1 ;
    int l = 0 , r = n - 1 ;
    int sign = 1 ;
    if(k % 2 )
    {
        res =  a[r]; 
        r -- ;
        k -- ;

        if(res < 0) sign = -1;
    }
    while(k)
    {
        LL x = (LL)a[l] * a[l + 1] , y = (LL)a[r] * a[r - 1];
        if(x * sign > y * sign)
        {
            res = x % mod * res % mod; 
            l += 2;                                
        }
        else 
        {
            res = y % mod * res % mod; 
            r -= 2; 
        }
        k -= 2; 
    }
    printf("%lld",(res%mod+mod)%mod);
    return 0;
}

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

using namespace std;

void dfs(vector<bool> &visited, vector<unordered_set<int> > &G, vector<long long int> &ans, vector<long long int> &temp, int nodo, long long int previous){
    ans[nodo] += (temp[nodo] + previous);
    visited[nodo] = true;
    for(auto c:G[nodo]){
        if(!visited[c])
            dfs(visited, G, ans, temp, c, temp[nodo] + previous);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    int n,q;
    cin >> n >> q;

    vector<bool> visited(n+1, false);
    vector<long long int> ans(n+1, 0);
    vector<long long int> temp(n+1, 0);
    vector<unordered_set<int> > G(n+1);

    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
    }

    for(int i=0; i<q; i++){
        int p, x;
        cin >> p >> x;
        temp[p] += x;
    }

    dfs(visited, G, ans, temp, 1, 0);

    for(int i=1; i<=n; i++){
        cout << ans[i] << " ";
    }cout << "\n";

    return 0;
}


Measured memory_bytes: 55552
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long currentA = 1;
        long[] vals = new long[N];
        for (int i = 0; i < N; i++) {
            vals[i] = sc.nextLong();
        }
        Arrays.sort(vals);
        if (vals[0] == 0) {
            System.out.println(0);
        } else {
            for (int i = 0; i < N; i++) {
                if (currentA > 1000000000000000000L / vals[i]) {
                    currentA = -1;
                    break;
                }
                currentA *= vals[i];
            }
            System.out.println(currentA);
        }

    }
}


Measured memory_bytes: 60984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstring>
using namespace std;
int a[100005];
int main()
{
	memset(a,0,sizeof(a));
	int n;
	int maxn=0,minn=100005;
	cin>>n;
	while(n--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		maxn=max(maxn,r);
		minn=min(minn,l);
		for(int i=l;i<=r;i++)
		{
			a[i]++;
		}
	}
int cnt=0;
for(int i=minn;i<=maxn;i++)
{
	if(a[i]>0)
	{
		cnt++;
	}
}
cout<<cnt<<endl;
}

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

const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
vector<int> g[N];
vector<int> dis[N];
char s[N];
int h, w, k;
int x[3], y[3];

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

struct Node{
    int x, y;
};

int main()
{
    scanf("%d%d%d%d%d%d%d", &h, &w, &k, &x[1], &y[1], &x[2], &y[2]);
    for(int i = 1; i <= h; i++) {
        dis[i].push_back(INF);
        g[i].push_back(1);
        scanf("%s", s + 1);
        for(int j = 1; j <= w; j++) {
            g[i].push_back(s[j] == '@' ? 1 : 0);
            dis[i].push_back(INF);
        }
    }

    queue<Node> q;
    q.push((Node){x[1], y[1]});
    dis[x[1]][y[1]] = 0;
    
    while(!q.empty()) {
        Node t = q.front(); q.pop();

        for(int i = 0; i < 4; i++) {
            int nx = t.x;
            int ny = t.y;
            int ndis = dis[t.x][t.y] + 1;

            for(int j = 1; j <= k; j++) {
                nx += dx[i];
                ny += dy[i];
                if(nx >= 1 && nx <= h && ny >= 1 && ny <= w && g[nx][ny] == 0 && dis[nx][ny] >= ndis) {
                    if(dis[nx][ny] == ndis) continue;
                    else dis[nx][ny] = ndis, q.push((Node){nx, ny});
                }
                else break;
            }
        }
    }
    printf("%d\n", dis[x[2]][y[2]] == INF ? -1 : dis[x[2]][y[2]]);

}

Measured memory_bytes: 59816
#include<iostream>
using namespace std;
int main(){

while(1){
	int n,x,a=0;
	
	cin>>n>>x;

	if(n==0&&x==0){
		break;
	}

	for(int i=1;i<=n-2;i++){
	for(int k=2;k<=n-1;k++){
	for(int j=3;j<=n;j++){
		if(i<k&&k<j){
		if(i+k+j==x){
			a=a+1;
		}
		}
	
	}
	}
	}
	cout<<a<<endl;
}
	return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

vll pl;

bool is_prime(const unsigned n) {
  for (ll i : pl) {
    if (i * i > n)
      break;
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
std::map<ll, ll> prime_factorization(ll n) {
  std::map<ll, ll> prime_factors;
  for (ll i : pl) {
    if (i * i > n)
      break;

    while (n % i == 0) {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

  for (int i = 2; i < 1e6 + 10; i++) {
    if (is_prime(i)) {
      pl.push_back(i);
    }
  }

  set<ll> primes;
  bool is_pairwise = true;

  rep(i, n) {
    auto pf = prime_factorization(a[i]);
    for (auto& p : pf) {
      auto it = primes.lower_bound(p.first);
      if (it != primes.end() && *it == p.first) {
        is_pairwise = false;
      } else {
        primes.insert(p.first);
      }
    }
  }

  ll all_gcd = a[0];
  rep(i, n) {
    all_gcd = gcd(all_gcd, a[i]);
  }

  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (all_gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 15072
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 62);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }

int check(vec &x,vec &y,int i,int j,int k,int l,int K){
    int maxx=-INF,maxy=-INF,minx=INF,miny=INF;
    maxx=max({x[i],x[j],x[k],x[l]});
    maxy=max({y[i],y[j],y[k],y[l]});
    minx=min({x[i],x[j],x[k],x[l]});
    miny=min({y[i],y[j],y[k],y[l]});
    int cnt=0;
    rep(g,x.size()){
        if(range(x[g],minx,maxx+1)&&range(y[g],miny,maxy+1)) cnt++;
    }
    if(cnt>=K){
        return (maxx-minx)*(maxy-miny);
    }
    else{
        return INF+1;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,K;
    cin>>n>>K;
    vec x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    int ans=INF;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                rep(l,n){
                    int cnt=check(x,y,i,j,k,l,K);
                    chmin(ans,cnt);
                }
            }
        }
    }
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=t.in();for(var i=new Array(e),o=0;o<e;o++)i[o]=t.in();for(var s=0,u=0;u<e;u++)r[u]-i[u]>0&&(s+=r[u]-i[u]);console.log(s)}}]);

Measured memory_bytes: 22964
#include <stdio.h> 
#include <ctype.h> 
#include <stdlib.h>
int main() {
int a[101][101], b[101], c[101];
int i, j;
int n, m;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
}
for (j = 0; j < m; j++) scanf("%d", &b[j]);
for (i = 0; i < n; i++) { c[i] = 0;
for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
}
for (i = 0; i < n; i++) {
printf("%d\n", c[i]);
}
return 0;
}


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

using namespace std;

int main() {
	long long int N, D, X;
	cin >> N >> D >> X;
	vector<long long int>Pprev( N ), Pnext( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> Pprev[i];
	}
	for( size_t j = 1; j < D; j++ ) {
		long long int now = X;
		vector<long long int>nextprime( N );
		long long int maxnow = now;
		vector<long long int>dp( now + 1 );
		dp[now] = now;
		for( size_t i = 0; i < N; i++ ) {
			cin >> Pnext[i];
			for( long long int k = now; k >= Pprev[i]; k-- ) {
				dp[k - Pprev[i]] = max( dp[k - Pprev[i]], dp[k] - Pprev[i] + Pnext[i] );
				maxnow = max( dp[k - Pprev[i]], maxnow );
			}
		}
		X = maxnow;
		Pprev = Pnext;
	}
	cout << X << endl;
}

Measured memory_bytes: 3156
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

aa = inputs[0][0]
ll = inputs[-2][0]
kk = inputs[-1][0]

# body
if $debugFlag
  p aa
  p ll
  p kk
end

if ll - aa > kk
  puts ":("
else
  puts "Yay!"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e5+5;
int const inf = 1e18;


void solve(){
    int i,j,l;
    int a,b;
    cin>>a>>b;
    if(a < b){
        while(b--) cout<<a;
        cout<<endl;
    }
    else{
        while(a--) cout<<b;
        cout<<endl;
    }
}   

int32_t main(){
    IOS;
    int t;
    t = 1;
    // pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

const int MaxN = 1e5;
int n, m, ind[MaxN + 5];
int all, last[MaxN + 5], other[2 * MaxN + 5], pre[2 * MaxN + 5];
bool vis[MaxN + 5], tot;
vector<int>ans;

void Build(int x, int y) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}

void Dfs1(int x, int fa){
	vis[x] = 1;
	int ed = last[x], dr;
	while(ed != -1) {
		dr = other[ed];
		if(!vis[dr]) {
			Dfs1(dr, x);
			break;
		}
		ed = pre[ed];
	}
	ans.push_back(x);
}

void Dfs2(int x, int fa){
	vis[x] = 1;
	ans.push_back(x);
	int ed = last[x], dr;
	while(ed != -1) {
		dr = other[ed];
		if(!vis[dr]) {
			Dfs2(dr, x);
			break;
		}
		ed = pre[ed];
	}
}

int main()
{
	all = -1; memset(last, -1, sizeof(last));
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		Build(u, v);
		Build(v, u);
	}
	memset(vis, 0, sizeof(vis));
	Dfs1(1, 0);
	Dfs2(1, 0);
	printf("%d\n", ans.size() - 1);
	for(int i = 0; i < ans.size(); i++) {
		if(i > 0 && ans[i] == ans[i - 1]) continue;
		else printf("%d ", ans[i]);
	}
	printf("\n");
}

Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;++i)
#define per(i,r,l) for (int i=r;i>=l;--i)
#define rep0(i,r) for (int i=0;i<r;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=2e6+6;
int tags[N],tagt[N],bit[N],a[N],b[N];
ll C[102][102],f[N]; bool del[N];
void solve(int t,int len){
    rep(i,1,len) f[i]+=t*C[len][i];
}
int main(){
    int n,k,s,t; cin>>n>>k>>s>>t;
    rep(i,0,n){
        C[i][0]=1;
        rep(j,1,i) C[i][j]=C[i-1][j]+C[i-1][j-1];
    }
    rep(i,1,n) cin>>a[i];
    rep(j,0,17) if (s>>j&1) tags[j]=1;
    rep(j,0,17) if (!(t>>j&1)) tagt[j]=1;
    int c=0;
    rep(j,0,17){
        if (tags[j]&&tagt[j]){
            cout<<0<<endl;
            return 0;
        }
        if (!tags[j]&&!tagt[j]) bit[++c]=j;
        if (tags[j])
            rep(i,1,n)
                if (!(a[i]>>j&1)) del[i]=true;
        if (tagt[j])
            rep(i,1,n)
                if (a[i]>>j&1) del[i]=true;
    }
    int _n=0;
    rep(i,1,n) if (!del[i]) a[++_n]=a[i];
    n=_n;
    rep(s,0,(1<<c)-1){
        int t=1; rep(i,1,c) if (s>>i-1&1) t=-t;
        rep(i,1,n){
            b[i]=0;
            rep(j,1,c)
                if ((s>>j-1&1)&&(a[i]>>bit[j]&1))
                    b[i]|=1<<j-1;
        }
        sort(b+1,b+1+n);
        int len=0;
        rep(i,1,n){
            if (i!=1&&b[i]!=b[i-1]) solve(t,len),len=0;
            ++len;
        }
        solve(t,len);
    }
    ll ans=0;
    rep(i,1,k) ans+=f[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int cst1=0,cst2=0;
    int mi=min(x,y);
    cst1+=mi*2*c;
    cst1+=(x-mi)*a+(y-mi)*b;
    cst2=x*a+y*b;
    int ma=max(x,y);
    int cst3=ma*2*c;
    int ans=min(cst1,cst2);
    ans=min(cst3,ans);
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i,a,b) for(int i = a; i < b ; i++)
using namespace std;

long long ans =0;

void solve (vector<int> a,int n,vector<vector<int> > v,vector<int> p)
{
	if(n < 0)
	{
		for(int i = 0 ; i < v.size() ; i ++)
		{
			int coun = 0;
			for(int j = 0 ; j < v[i].size(); j++)
			{
				//coun = 0;
				if(a[v[i][j] - 1])
				{
					coun++;
				}
			}
			if(coun % 2 != p[i] % 2)
			{
				return ;
			}
		}
		ans++;
		return ;
	}
	solve(a,n - 1,v,p);
	a[n] = 1;
	solve(a,n - 1,v,p);
}

int main()
{
	int n,m;
	cin>>n>>m;
	//vector<vector<int> > v(m,vector<int>(n,0));
	vector<vector<int> > v(m);
	for(int i = 0 ; i < m ; i++)
	{
		int k;cin>>k;
		v[i] = vector<int>(k);
		for(int j = 0 ; j < k ;j++)
		{
			//int temp;
			//v[i][temp- 1] = 1;
			cin>>v[i][j];
		}
	}
	vector<int> p(m);
	for(int i = 0 ; i < m ; i++)
	{
		cin>>p[i];
	}
	vector<int> a(n);
	solve(a,n - 1,v,p);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> p(n);
    
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    string answer="NO";
    int ok=0;
    
    for(int i=0;i<n;i++){
        
        for(int j=0;j<n;j++){
            vector<int> hoge=p;
            hoge.at(i)=p.at(j);
            hoge.at(j)=p.at(i);
            ok=0;
            for(int k=0;k<n-1;k++){
                if(hoge.at(k)>hoge.at(k+1))ok=1;
            }
            if(ok==0)answer="YES";
        }
        
    }
    cout<<answer;
}

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

int main() {
	int N, C, K, T[100005], min = 0, ans = 0;
	cin >> N >> C >> K;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	sort(T, T + N);
	for (int i = 0; i < N; i++) {
		if (i - min +1 > C || T[i] - T[min] > K) {//人数オーバーor時間
			ans++;
			min = i;
		}
	}
	//if (min != N) ans++;
	cout << ans+1 << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

int prime[3500];
int find_prime();
int prime_search(int, int, int, int);

int main(void)
{
    int n = find_prime();

    int a;
    scanf("%d", &a);
    int end = int(sqrt(a * 1.0)) + 1;

    printf("%d:", a);
    for(int i = 0; prime[i] < end; i++){
        if(a % prime[i] == 0){
            do{
                printf(" %d", prime[i]);
                a = a / prime[i];
            }while(a % prime[i] == 0);
        }
        if(a == 1) break;
    }
    if(a > 1){ printf(" %d", a); }
    printf("\n");

    return 0;
}

int find_prime()
{
    int n, lim;
    prime[0] = 2, prime[1] = 3, prime[2] = 5, prime[3] = 7;
    n = lim = prime_search(4, 2, 32, 0);
    n = lim = prime_search(n, 32, 180, lim);
    return prime_search(n, 180, 31700, lim);
}

int prime_search(int n, int from, int to, int lim)
{
    int i, j;
    for(i = from; i < to; i++){
        if(i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0) continue;
        for(j = 0; j < lim; j++){
            if(i % prime[j] == 0) break;
        }
        if(j == lim){ prime[n] = i; n++; }
    }
    return n;
}

Measured memory_bytes: 1204
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

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

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        return n + (n*n) + (n*n*n);
    }

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


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


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  string s;
  cin >> s;
  int sum = 0;
  for (char c : s) {
    sum += (c - '0');
    sum %= 9;
  }
  cout << (sum == 0 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3752
n,k = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(k)]
imos = [0] * (2 * n + 1)
imos[0] = 1
imos[1] = -1
ans = [1]
  # print(imos)
for i in range(n):
    for x,y in lis:
        imos[i+x] += ans[-1]
        imos[i+y+1] -= ans[-1]
    ans.append((ans[-1]+imos[i+1])%998244353)
  #print(imos)
print(ans[-2])

Measured memory_bytes: 84640
class Poker
  def initialize
    @card_list = ["1","2","3","4","5","6","7",
              "8","9","10","11","12","13"]
    @results = []
    input
    @results.each do |ans|
      puts ans
    end
  end

  def input
    while input = $stdin.gets
      @results << checker(create_hand(input))
    end
  end

  def create_hand(input)
    input.chomp.split(',')
  end

  def checker(hands)
    @card_list.each_with_index do |elem,index|
      case hands.count(elem)   
      when 2
        hands.delete(elem)
        return two_check(hands)
      when 3
        hands.delete(elem)
        return three_check(hands)
      when 4
        return "four card"
      else
      end
    end 
    return straight_check(hands)
  end

  def two_check(hands)
    hands.each do |elem|
      case hands.count(elem)
      when 2
        return "two pair"
      when 3
        return "full house"
      end
    end
    return "one pair"
  end

  def three_check(hands)
    hands.each do |elem|
      case hands.count(elem)
      when 2
        return "full house"
      else
        return "three card"
      end
    end
  end

  def straight_check(hands)
    count = 0
    (@card_list+["1"]).each do |elem|
      if hands.include?(elem)
        count += 1
        return "straight" if count == 5
      else
        count = 0
      end
    end
    return "null"
  end
end

p = Poker.new

Measured memory_bytes: 2424