akhauriyash/Code-Regression huggingface dataset:
#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 rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define nl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+ 5 ;
            const ll mod = 1e9+7;
            const ll inf = 1e18;
            ll   n  , m  , k,u,v , xors , sum , fact[N] , inv_fact[N] ,ans ;
            char a[10][10];
            set <ll> row ,col;
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod; ;
        if(n&1)
            pt *= a  , pt %= mod;
        return pt;
    }

    int main()
    {
         IOS;
         int ts =1;
       ///  cin >> ts ;
         while(ts--)
         {
            cin >> n >> m >> k;
            rep(i,0,n) rep(j,0,m) cin >> a[i][j];
            for(int i =0 ; i <= ( (1ll << (n)) -1); i++)
            {
                for(int j =0 ; j <= ( (1ll << (m)) -1); j++  )
                {
                    int cnt =0 ;
                    for(int r = 0 ; r < n; r++)
                    {
                        if( (pow_mod_m(2,r) & i) == 0){
                        for(int c =0 ; c < m; c++)
                        {
                            if( (pow_mod_m(2,c) & j) == 0)
                            {
                                cnt += (a[r][c] == '#');
                            }
                        }
                        }
                    }
                        if(cnt == k)
                        {
                            bitset <5> w(i) ,x(j);
                    ///        cout << " current considered for \n";
                     ///       cout << w << nl << x << nl;
                            ans++;
                        }
                }
            }
            cout << ans << endl;
         }
    }


Measured memory_bytes: 3632
my $N = <STDIN>;
my @A = split(/ /, <STDIN>);
my $nn = 0;
foreach my $i (@A) {
        $nn += &check_2n(0,$i);
}
print $nn;
sub check_2n($){
        my ($num, $n) = @_;
        if ($n%2 == 0) {
                $num++;
                &check_2n($num,$n/2);
        } else {
                return $num;
        }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    string result;
    cin >> result;

    int tenin = a+b;
    int tuuka = 0;
    int kaigai =1;
    rep(i,n){
        if(result[i] =='a'){
            if(tuuka < tenin){
                cout << "Yes" << endl;
                tuuka ++;
            }
            else cout << "No" << endl;
        }
        else if(result[i] == 'b'){
            if(tuuka < tenin && kaigai <= b) {
            cout << "Yes" <<endl;
            tuuka ++; kaigai++;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;

    }

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll x[100010], y[100010];
int main(){
    ll n, m;
    cin >> n >> m;
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    ll p = 0, q = 0;
    rep(i, n){
        p += i * x[i] - (n - i - 1) * x[i];
        p %= MOD;
    }
    rep(i, m){
        q += i * y[i] - (m - i - 1) * y[i];
        q %= MOD;
    }

    cout << (p * q) % MOD << endl;

    return 0;
}


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N), A(M), B(M);
    vector<ll> vec(N,0);
    for (ll i=0; i<N; i++) cin >> H[i];
    for (ll i=0; i<M; i++) {
        cin >> A[i] >> B[i];
        if (H[A[i]-1] <= H[B[i]-1]) vec[A[i]-1]++;
        if (H[A[i]-1] >= H[B[i]-1]) vec[B[i]-1]++;
    }

    ll ans = 0;
    for (ll i=0; i<N; i++) {
        if (vec[i]==0) ans++;
    }

    cout << ans << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int d = a*100 + b*10 +c;
  if(d%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

int n;
vector<pair<pair<string,int>,int>> table;

int main() {
  cin >> n;
  table.resize(n);
  
  for (int i=0; i<n; i++){
    cin >> table[i].first.first >> table[i] .first.second;
    table[i].first.second *= -1;
    table[i].second = i+1;
  }
  sort(table.begin(),table.end());
  
  for (int i=0; i<n; i++){
    cout << table[i].second << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int n, A[20];

int solve(int, int);

int main()
{
  int i, q, res, m[200];

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

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &m[i]);
  }

  for(i = 0; i < q; i++){
    res = solve(0, m[i]);

    if(res == 0) printf("yes\n");
    else if(res == 1) printf("no\n");
  }

    return 0;
}

int solve(int i, int m)
{
  int res;

  if(m == 0) return 0;
  if(i >= n) return 1;
  if(solve(i+1, m) == 0 || solve(i+1, m-A[i]) == 0) return 0;
}

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

ll A, B, T;
void solve() {
  ll res = 0;
  for (int i = 1; i * A <= T; i++) {
    res += B;
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> A >> B >> T;
  solve();
  return 0;
}


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

#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)

int N, M, s, g;
struct Edge {
    int to;
    double d, c;
    Edge(int to, double d, double c) : to(to), d(d), c(c) {}
};
struct Data {
    double res;
    int n;
    int pre;
    int v;
    bool operator<(const Data &rhs) const { return res < rhs.res; };
    bool operator>(const Data &rhs) const { return res > rhs.res; };
};
vector<Edge> G[33];
double dp[33][33][33];  // jから速度kでiに来た時の最短時間
void init() {
    REP(i, N + 1) REP(j, N + 1) REP(k, 31) { dp[i][j][k] = 1e9; }
    REP(i, N) G[i].clear();
    dp[s][s][0] = 0;
}

using arr4 = array<int, 4>;
bool solve() {
    cin >> N >> M;
    if (N == 0) return false;
    cin >> s >> g;
    s--, g--;
    init();
    REP(i, M) {
        int u, v;
        double d, c;
        cin >> u >> v >> d >> c;
        u--, v--;
        G[u].push_back({v, d, c});
        G[v].push_back({u, d, c});
    }
    priority_queue<Data, vector<Data>, greater<Data>> que;
    que.push({0, s, s, 0});
    while (!que.empty()) {
        Data dat = que.top();
        que.pop();
        double res = dat.res;
        int n = dat.n;
        int pre = dat.pre;
        int v = dat.v;
        for (auto e : G[n]) {
            if (e.to == pre) continue;
            REP(i, 3) {
                int nv = v - 1 + i;
                if (nv <= 0 || nv > e.c) continue;
                if (dp[e.to][n][nv] > dp[n][pre][v] + (double)e.d / nv) {
                    dp[e.to][n][nv] = dp[n][pre][v] + (double)e.d / nv;
                    que.push({dp[e.to][n][nv], e.to, n, nv});
                }
            }
        }
    }
    double ans = 1e9;
    REP(i, N) { ans = min(ans, dp[g][i][1]); }
    if (ans >= 1e9)
        cout << "unreachable" << endl;
    else
        cout << fixed << setprecision(10) << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 4024
x, y = gets.chop.split.map(&:to_i)

groups = [[1,3,5,7,8,10,12], [4,6,9,11], [2]]

def same_group(x, y, groups)
  groups.each do |group|
    return 'Yes' if group.include?(x) && group.include?(y)
  end
  return 'No'
end

puts same_group(x, y, groups)

Measured memory_bytes: 1788
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M),c(M);
  rep(i,M){
    cin >> s[i] >> c[i];
  }
  vector<int> num(N+1,-1);
  bool hantei = false;
  rep(i,M){
    if(num[s[i]]==-1){
      num[s[i]]=c[i];
    }
    else if(num[s[i]]==c[i])num[s[i]]=c[i];
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if(N==1){
    if(num[1]>=0)cout << num[1] << endl;
    else cout << 0 << endl;
    return 0;
  }

  if(num[1]==-1)num[1]=1;
  for(int i = 2;i <= N;i++){
    if(num[i]==-1)num[i]=0;
  }

  if(num[1]==0){
    cout << -1 << endl;
  }else{
    for(int i = 1;i <= N;i++)cout << num[i];
    cout << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pp pair<int,int>
#define MZ 1000000007
#define Pi acos(-1)
#define pq priority_queue

using namespace std;

long long ans=0,num[66];
long long c[55][55];

int main()
{
    long long n,a,b,c,d,temp;
    long long minn,maxx;
    bool f=0;
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    n--;
    if(a>b)
    {
        temp=a;
        a=b;
        b=temp;
    }
    minn=maxx=a;
    for(int i=n;i;i--)
    {
        if(b<=maxx+i*d && b>=minn+i*c)
        {
            f=1;
            break;
        }
        else
        {
            minn-=d;
            maxx-=c;
        }
    }
    if(f)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT long long int
#define oo 987654321
using namespace std;
INT n, m, b[30], a[30][30], c, ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>c;
    for(int i = 0 ; i < m ; i++ ) cin>>b[i];
    for(int i = 0 ; i < n ; i++ ) for(int j = 0 ; j < m ; j++ ) cin>>a[i][j];
    for(int i = 0 ; i < n ; i++ )
    {
        INT s = c;
        for(int j = 0 ; j < m ; j++ )
            s += b[j]*a[i][j];
        if( s > 0 ) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

int ans_gu_choki_per(char te, int c, int d, int e ) {
  if(te = "r") return e;
  else if(te = "s") return c;
  else if(te = "p") return d;
  else return 0;
//  return abs(a-b)*abs(a-b);
}
int ans_gu_choki_per_2(char te, int c, int d, int e ) {
  if(te = "r") return c;
  else if(te = "s") return d;
  else if(te = "p") return e;
  else return 0;
//  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%s", &s);
  printf("%c\n", s[0]+1);
  
return 0;
}


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

int main(){
    long long N,ai;
    cin >> N;
    long long a[N];
    long long sum, total, ans, tmp;

    total=0;
    for(long long i=0; i<N; i++){
        cin >> a[i];
        total+=a[i];
    }

    sum=0;

    for(long long i=0; i<N-1; i++){
        sum+=a[i];
        tmp= abs(total-2*sum);
        if(i==0){
            ans=tmp;
        }else{
            ans= min(ans,tmp);
        }
        //cout << "i sum total total-sum tmp ans " << i << " " << sum << " " << total << " " << total-sum << " " << tmp << " " << ans << endl; 
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int n, t;
	string s;
	vector<string> vec;
	cin >> n >> t;
	while(n--)
		cin >> s, vec.push_back(s);
	sort(vec.begin(), vec.end());
	for(auto elem: vec)
		cout << elem;
	puts("");
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int dp[3003][3003];

int main(){
   string s,t;
   cin>>s>>t;
   rep(i,s.size())rep(j,t.size()){
       if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
       else{
           dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
       }
   }
   
   int len=dp[s.size()][t.size()];
  
   int i=s.size(),j=t.size();
    string ans;
    while(len>0){
        if(s[i-1]==t[j-1]){
            ans=s[i-1]+ans;
            
            i--;
            j--;
            len--;
        }
        else if(dp[i][j]==dp[i-1][j])i--;
        else j--;
        
    }
   
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const double mod = 1e9 + 7;
const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;


int main() {
    int N, s, sum = 0;
    vector<int> S;
    cin >> N;
    REP(i, N) {
        cin >> s;
        sum += s;
        S.push_back(s);
    }

    sort(S.begin(), S.end());
    if (sum % 10 == 0) {
        REP(i, N) {
            if (i == N - 1) {
                sum = 0;
                break;
            }
            if (S.at(i) % 10 != 0) {
                sum -= S.at(i);
                break;
            }
        }

    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    if N == 2:
        print(abs(A[0] - A[1]))
        return

    A.sort()

    q = collections.deque(A)

    ans = 0
    i = 0
    c = [q.popleft(), q.pop()]
    ans += abs(c[0] - c[1])
    while q:
        if len(q) >= 2:
            a = q.popleft()
            b = q.pop()
            al = abs(a - c[0])
            ar = abs(a - c[1])
            bl = abs(b - c[0])
            br = abs(b - c[1])
            ma = max([al, ar, bl, br])
            ans += ma
            if ma == al:
                c[0] = a
                q.append(b)
            elif ma == ar:
                c[1] = a
                q.append(b)
            elif ma == bl:
                c[0] = b
                q.appendleft(a)
            else:
                c[1] = b
                q.appendleft(a)
        else:
            a = q.pop()
            ans += max(abs(c[0] - a), abs(c[1] - a))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13968
use proconio::input;
use std::cmp::{max, min};

const MAX_L: u32 = 100_000;
const BASE_SIZE: usize = 1 << 9;

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        vl: [(usize, u32); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < vw[0].1 { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1;
                let v = if i < w { 0 } else { dp[p][(i - w) as usize] + vw[c].0 };
                max(dp[p][i as usize], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: u32,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l as usize]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long Q = 10100;
const long long mod = 1e9 + 7;
const long long block = sqrt(N);

using namespace std;

int n;
int k;
int a[N];

void solve()
{
        cin >> n >> k;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        for(int i = 1; i < n; i++){
                int g = min(a[i], k);
                a[i] -= g;
                k -= g;
        }
        a[n] -= k;
        int cnt = 0;
        for(int i = 1; i <= n; i++){
                cnt += (a[i] == 0);
        }
        cout << cnt << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("substr3.in");
        //fout("substr3.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
    int X;
    cin >> X;
    int N = X/100;
    if(X>= 100*N && X<= 105*N) cout << 1 << endl;
    else    cout << 0 << endl;

    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[101], y[101], h[101];

int a[100001], b[2001][2001], sum[100001];

int G[1001][1001];
vector<int> ans[1001];

signed main() {
	int N;
	cin >> N;
	//考える時間が惜しいのでO(N)でできるかどうか判別
	bool flag = false;
	int nodenum = 0;
	for (int i = 0; i < 10000; i++) {
		if (N == i * (i - 1) / 2) {
			flag = true;
			nodenum = i;
			break;
		}
	}
	if (!flag) {
		cout << "No\n";
		return 0;
	}
	//cout << nodenum << "\n";
	//nodenum個の完全グラフを構築
	for (int i = 1; i <= nodenum; i++) {
		for (int j = 1; j <= nodenum; j++) {
			if (i == j) continue;
			G[i][j] = G[j][i] = 1;
		}
	}
	int cnt = 1;
	for (int i = 1; i <= nodenum; i++) {
		for (int j = 1; j <= nodenum; j++) {
			if (i == j) continue;
			if (G[i][j] == 1) {
				ans[i].push_back(cnt);
				ans[j].push_back(cnt);
				G[i][j] = G[j][i] = 0;
				cnt++;
			}
		}
	}
	vector<vector<int>> kotae;
	for (int i = 1; i <= nodenum; i++) {
			if (ans[i].size() != 0) {
				kotae.push_back(ans[i]);
			}
	}
	cout << "Yes\n";
	cout << kotae.size() << "\n";
	for (vector<int> v : kotae) {
		cout << v.size() << " ";
		for (int i = 0; i < v.size(); i++) {
			cout << v[i];
			if (i != v.size() - 1) cout << " ";
			else cout << "\n";
		}

	}


	return 0;
}

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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.size() > k)
    {
        s = s.substr(0, k);
        s += "...";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3632
_ = int(input())
coords = tuple(int(x) for x in input().split())

start = min(coords)
end = max(coords)

min = float("inf")
for x in range(start, end + 1):
    sum = 0
    for coord in coords:
        temp = x - coord
        sum += temp * temp
    if sum < min:
        min = sum
  
print(min)

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

using namespace std;

int dp[505050];

int main(){
        int n;
        cin>>n;
        string s;
        cin>>s;
        s="0"+s+"0";
        for(int i=1;i<(int)s.size()-1;i++){
                dp[i+1]=max(dp[i+1], dp[i]);
                if(s[i-1]=='1'&&s[i]=='0'&&s[i+1]=='1'){
                        int prev=i-1, next=i+1;
                        while(s[prev]!='0'){
                                dp[i+1]=max(dp[i+1], dp[prev-1]+(i-prev));
                                prev--;
                        }
                        while(s[next]!='0'){
                                dp[next]=max(dp[next], dp[i-2]+(next-i));
                                next++;
                        }
                }
        }
        cout<<dp[(int)s.size()-1]<<endl;
        return 0;
}


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

int main() {
	int n; cin >> n;
	string s[100000];
	rep(i,n) cin >> s[i];
	map<string, int> table;
	rep(i,n) {
		table[s[i]] += 1;
	}
	cout << "AC x " << table["AC"] << endl;
	cout << "WA x " << table["WA"] << endl;
	cout << "TLE x " << table["TLE"] << endl;
	cout << "RE x " << table["RE"] << endl;
}

Measured memory_bytes: 6740
h, w = map(int,input().split())
s = [list(input()) for i in range(h)]

L = [[0] * w for i in range(h)]
R = [[0] * w for i in range(h)]
D = [[0] * w for i in range(h)]
U = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] == '.':
                L[i][j] = 1
            if s[i][- (j + 1)] =='.':
                R[i][- (j + 1)] = 1

        if j != 0:
            if s[i][j] == '.':
                L[i][j] = L[i][j - 1] + 1
            if s[i][- (j + 1)] == '.':
                R[i][- (j + 1)] = R[i][- (j + 1) + 1] + 1

        if i == 0:
            if s[i][j] == '.':
                U[i][j] = 1
            if s[- (i + 1)][j] == '.':
                D[- (i + 1)][j] = 1
        if i != 0:
            if s[i][j] == '.':
                U[i][j] = U[i - 1][j] + 1
            if s[- (i + 1)][j] == '.':
                D[- (i + 1)][j] = D[- (i + 1) + 1][j] + 1
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':continue
        temp = R[i][j] + L[i][j] + D[i][j] + U[i][j] -3
        if ans < temp:ans = temp
        #print(temp)
print(ans)

Measured memory_bytes: 311560
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	string s, t;
	int n;
	cin >> n;
	cin >> s >> t;
	forn(i,n){
		cout << s[i] << t[i];
	}
	return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    let days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    let s: String = s.into_iter().collect();
    let pos = days.iter().position(|&x| x == &s).unwrap();
    puts!("{}\n", 7 - pos);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    if 0 in a:
        print(0)
        exit()
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
          print(-1)
          exit()
    print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Measured memory_bytes: 21804
#include <iostream>
#include <cstdio>
using namespace std;
int h,w,n,ans;
int main()
{
    scanf("%d%d%d",&h,&w,&n);
    if (h < w)
        swap(h,w);
    ans = n / h;
    if (n % h)
        ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGNUM(x) printf("%d\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORNUM(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPNUM(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    char class[20];
    int am, pm;
    int i;

    for (i = 0; i < 9; ++i){
        scanf("%s %d %d", class, &am, &pm);

        printf("%s %d %d\n", class, am + pm, (am * 200) + (pm * 300));
    }

    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int bs (int [], int, int);

int main(void)
{
  int i,j,n,a[100000],dp[100000];

  scanf("%d",&n);
  for(i=0;i<=n-1;i++)
    {
      scanf("%d",&a[i]);
    }
  dp[0]=-1;
  dp[1]=a[0];
  j=1;
  for(i=1;i<=n-1;i++)
    {
      if(dp[j]<a[i])
	{
	  dp[j+1]=a[i];
	  j++;
	}
      else
	{
	  dp[bs(dp,j+1,a[i])]=a[i];
	}
    }
  printf("%d\n",j);
  return 0;
}

int bs (int D[], int n, int c) 
{
    int j,k,l;
    j=0;
    k=n-1;
    while(1)
    {
        if(j<=k)
        {
            l=(j+k)/2;
            if(D[l] > c)
            {
                k=l-1;
            }
            else if(D[l] < c)
            {
                j=l+1;
            }
            else
            {
                return l;
            }
        }
        else
        {
	  return k+1;
        }
    }
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n){
        cin >> v[i];
        v[i]--;
    }
    vector<bool> u(n, false);
    int p = 0, cnt = 0;
    while(!u[p]){
        if(p == 1){
            cout << cnt << endl;
            return 0;
        }
        u[p] = true;
        p = v[p];
        cnt++;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    if n == 1{
        fmt.Println("Hello World")
    } else {
        var a,b int
        fmt.Scan(&a,&b)
        fmt.Println(a+b)
    }
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool solve(vector<pair<int, int>>& ab, vector<pair<int, int>>& ba) {
  vector<int> cnt(4, 0);
  REP(i, 3) {
    int a, b;
    tie(a, b) = ab[i];
    ++cnt[a];
    ++cnt[b];
  }
  int one_cnt = std::count_if(cnt.begin(), cnt.end(), [](int x) { return x == 1; });
  int two_cnt = std::count_if(cnt.begin(), cnt.end(), [](int x) { return x == 2; });
  if (one_cnt == 2 && two_cnt == 2)
    return true;
  return false;
}

int main() {
  vector<pair<int, int>> ab, ba;

  REP(i, 3) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ab.emplace_back(a, b);
    ba.emplace_back(b, a);
  }
  if (solve(ab, ba))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
from collections import deque

S=input()
Q=int(input())
r_flag=False
ans=deque((S))
for i in range(Q):
  Qu=input().split()
  if Qu[0]=="1":
    r_flag=not r_flag
  else:
    if Qu[1]=="1":
      if r_flag==True:
        ans.append(Qu[2])
      else:
        ans.appendleft(Qu[2])
    else:
      if r_flag==True:
        ans.appendleft(Qu[2])
      else:
        ans.append(Qu[2])
ans=list(ans)
print("".join(ans) if r_flag==False else "".join(ans[::-1]))


Measured memory_bytes: 14056
#include<bits/stdc++.h>
const int N=1e5+10;
using namespace std;
typedef long long ll;
const ll inf=(1LL<<60)-1;
ll sum;
priority_queue<int> q;
int x,y,z,a[N],b[N],n,c[N],h[N];
ll f[N],g[N];
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
inline bool cmp(int x,int y){
	return a[x]-b[x]<a[y]-b[y];
}
int main(){
	x=read();y=read();z=read();n=x+y+z;
	for(int i=1;i<=n;i++){
		h[i]=i;a[i]=read();b[i]=read();c[i]=read();
		sum+=c[i];a[i]-=c[i];b[i]-=c[i];
	}
	sort(h+1,h+n+1,cmp);ll cur=0,ans=-inf;
	for(int i=1;i<=y;i++)q.push(-b[h[i]]),cur+=b[h[i]];
	f[y]=cur;
	for(int i=y+1;i<=n;i++){
		cur+=b[h[i]];q.push(-b[h[i]]);
		cur+=q.top();q.pop();f[i]=cur;
	}
	while(!q.empty())q.pop();cur=0;
	for(int i=n;i>=n-x+1;i--)q.push(-a[h[i]]),cur+=a[h[i]],g[n-x+1]=cur;
	for(int i=n-x;i;i--){
		cur+=a[h[i]];q.push(-a[h[i]]);
		cur+=q.top();q.pop();g[i]=cur;
	}
	for(int i=y;i<=n-x;i++)ans=max(ans,f[i]+g[i+1]);ans+=sum;
	printf("%lld\n",ans);
}

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

int main() {
    long long N,M;
    cin >> N >> M;
    long long sum=1;
    if(abs(N-M)>1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        sum=(sum*(N-i))%(1000000007);
    }for(int j=0;j<M;j++){
        sum=(sum*(M-j))%(1000000007);
    }
    if(N==M) sum=(2*sum)%(1000000007);

    cout << sum << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  
  int a = 0;
  for (int i = 0; i < K + 1; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (0 <= S - i - j && K >= S - i - j) a++;
    }
  }
  
  cout << a << endl;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	int ret=x/500 * 1000;
	x%=500;
	ret+=x/5*5;
	cout<<ret;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527

int main(){
    ll X, Y, ans;
    cin >> X >> Y;
   
    if(Y%2==1){
        cout << "No" << endl;
        return 0;
    }
    else if(X*4<Y){
        cout << "No" << endl;
        return 0;
    }
    else{
        REP(i, X+1){
            ans=i*4+abs(X-i)*2;
            if(ans==Y){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func rev(s string) string {
	b := []byte(s)
	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
		b[i], b[j] = b[j], b[i]
	}
	return string(b)
}

func main() {
	defer stdout.Flush()

	s := readString()
	rs := rev(s)

outer:
	for len(rs) > 0 {
		for _, p := range []string{rev("dream"), rev("dreamer"), rev("erase"), rev("eraser")} {
			if strings.HasPrefix(rs, p) {
				rs = rs[len(p):]
				continue outer
			}
		}
		println("NO")
		return
	}
	println("YES")
}


Measured memory_bytes: 1792
A, B = map(int,input().split())
S = input()
flag = 1
for i in range(A+B+1):
    if i == A:
        if S[i] != '-':
            flag = 0
    else:
        if not S[i] in '0123456789':
            flag = 0
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

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

    int n;
    cin>>n;
    if(n==1)cout<<"Hello World"<<endl;
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N, M;

signed main() {
  cin >> N >> M;
  vector<ll> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i] /= 2;
  }

  ll L = 1;  // 最小公倍数
  rep(i, N) { L = L * a[i] / __gcd(L, a[i]); }

  rep(i, N) {
    if (L / a[i] % 2 == 0) {
      std::cout << 0 << endl;
      return 0;
    }
  }

  std::cout << (M + L) / L / 2 << endl;

  return 0;
}

Measured memory_bytes: 1024
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int n,i;
		cin>>n;
		int ac=0,re=0,tle=0,wa=0;
		// vector<string>v(n);
		repf(i,0,n)
		{
			string s;
			cin>>s;
			if(s=="AC") ac++;
			else if(s=="WA") wa++;
			else if(s=="TLE") tle++;
			else re++;
		}
		cout<<"AC x "<<ac<<"\n";
		cout<<"WA x "<<wa<<"\n";
		cout<<"TLE x "<<tle<<"\n";
		cout<<"RE x "<<re<<"\n";
    }
    return 0;
} 


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f,ans=0,k,g;
	cin>>a>>b>>c>>d>>e>>f;
	k=min(min(a,b),min(c,d));
	g=min(e,f);
	ans=a+b+c+d+e+f-k-g;
	cout<<ans<<endl;
}


Measured memory_bytes: 3080
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

int n, p[mxn], pp[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i], pp[p[i]] = i;
    }

    int mx = 0;
    for (int i = 1; i <= n; i++) {
        int strt = i;
        while (pp[i+1]>pp[i]) i++;
        mx = max(mx, i-strt+1);
    }
    cout << n-mx << '\n';
}

Measured memory_bytes: 1792
#include<stdio.h>

void ea(long*, long*);

int main(void) {
        long a,b,a_o,b_o,r;
        long gcd, lcm;
        while(scanf("%ld %ld", &a_o,&b_o)>0) {

                a=a_o;
                b=b_o;
                while(a!=b) {
                        if(a>b) ea(&a, &b);
                        else    ea(&b, &a);
                        // ea(&a, &b);
                }
                gcd=b;
                lcm=a_o*b_o/gcd;

                printf("%ld %ld\n", gcd, lcm);
        }

        return 0;
}

void ea(long *big, long *small) {
        long a,b,r;
        a=*big;
        b=*small;
        r=a-b;
        if(r>=b) {
                *big=r;
                *small=b;
        } else {
                *big=b;
                *small=r;
        }

        return ;
}

Measured memory_bytes: 596
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int dx = x2 - x1;
        int dy = y2 - y1;
        System.out.print(x2 - dy);
        System.out.print(" ");
        System.out.print(y2 + dx);
        System.out.print(" ");
        System.out.print(x1 - dy);
        System.out.print(" ");
        System.out.println(y1 + dx);
    }
}

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

typedef struct node{
  struct node *p,*r,*l;
  int key;
}Node;

Node *insert(Node *p,int key){
  Node *x,*y,*n;
  x=p;
  y=NULL;
  while(x!=NULL){
    y=x;
    if(x->key<=key)x=x->r;
    else x=x->l;
  }
  
  n=new Node;
  n->p=y;
  n->r=NULL;
  n->l=NULL;
  n->key=key;

  if (p==NULL)return n;
  if (y->key<=key) y->r=n;
  else y->l=n;
  return p;
}

void printA(Node *p){
  if (p==NULL) return;
  printA(p->l);
  cout << " " << p->key;
  printA(p->r);
}

void printB(Node *p){
  if (p==NULL) return;
  cout << " " << p->key;
  printB(p->l);
  printB(p->r);
}

void print(Node *p){
  printA(p);
  cout << endl;
  printB(p);
  cout << endl;
}

int main(){
  int n,k;
  Node *root=NULL;
  char cmd[16];

  cin >> n;
  for (int i=0;i<n;i++){
    cin >> cmd;
    if (cmd[0]=='i'){
      cin >> k;
      root=insert(root,k);
    }else if (cmd[0]=='p'){
      print(root);
    }//else if (cmd[0]==''){
    //}
  }
  
  return 0;
}

Measured memory_bytes: 26484