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

int ok(vector<int> &A){

    if(A.at(3)+A.at(2)+A.at(1)+A.at(0) == 7) {
        cout << A.at(3) << "+" << A.at(2) << "+" << A.at(1) << "+" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)+A.at(2)-A.at(1)+A.at(0) == 7) {
        cout << A.at(3) << "+" << A.at(2) << "-" << A.at(1) << "+" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)-A.at(2)+A.at(1)+A.at(0) == 7) {
        cout << A.at(3) << "-" << A.at(2) << "+" << A.at(1) << "+" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)-A.at(2)-A.at(1)+A.at(0) == 7) {
        cout << A.at(3) << "-" << A.at(2) << "-" << A.at(1) << "+" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)+A.at(2)+A.at(1)-A.at(0) == 7) {
        cout << A.at(3) << "+" << A.at(2) << "+" << A.at(1) << "-" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)+A.at(2)-A.at(1)-A.at(0) == 7) {
        cout << A.at(3) << "+" << A.at(2) << "-" << A.at(1) << "-" << A.at(0)  << "=7" << endl;
        return 0;
    }

    if(A.at(3)-A.at(2)+A.at(1)-A.at(0) == 7) {
        cout << A.at(3) << "-" << A.at(2) << "+" << A.at(1) << "-" << A.at(0) << "=7" << endl;
        return 0;
    }

    if(A.at(3)-A.at(2)-A.at(1)-A.at(0) == 7) {
        cout << A.at(3) << "-" << A.at(2) << "-" << A.at(1) << "-" << A.at(0)  << "=7" << endl;
        return 0;
    }          
      
}


int main() {
    int ABCD=0;
    cin >> ABCD;

    vector<int> A(4,0);
    for(int i=0; i < 4; i++){
        A.at(i) = ABCD % 10;
        ABCD /= 10;
    }
    
    int result = ok(A);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  string n;
  cin>>n;
  rep(i,3){
    if(n[i]=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define int long long
#define inf 100000000000000000
#define f first
#define s second
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,m;
	cin >> n >> m;
	pair <pair<int,int>,int> v[m];
	for(int i=0;i<m;++i)
		cin >> v[i].f.f >> v[i].s >> v[i].f.s ;
	sort(v,v+m);
	int d[n+1];
	for(int i=1;i<=n;i++)
		d[i]=inf;
	d[1]=0;
	set <int> s;
	s.insert(1);
	s.insert(n);
	for(int i=0;i<m;++i){
		int l=v[i].f.f,r=v[i].s,c=v[i].f.s;
		auto itr=s.lower_bound(r);
		auto itl=s.lower_bound(l);
		int x=d[*itl]+c;
		if(x>=d[*itr])
			continue;
		auto t=--itr;
		while(d[*t]>=x){
			if(t==s.begin()){
				s.erase(t);
				break;
			}
			t--;
			s.erase(itr);
			itr=t;
		}
		s.insert(r);
		d[r]=x;
	}
	// for(int i=1;i<=n;i++)
	// 	cout << d[i] << " ";
	if(d[n]==inf)
		d[n]=-1;
	cout << d[n] << endl;
}

Measured memory_bytes: 7936
using System;

namespace A___9x9
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int A = int.Parse(S.Split()[0]);
            int B = int.Parse(S.Split()[1]);

            if (A >= 10 || B >= 10)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(A * B);
            }
        }
    }
}


Measured memory_bytes: 11092
from bisect import bisect

k = int(input())
A = list(range(10))

if k <= 9:
    print(A[k])
    exit()


def is_1_keta(i):
    return len(str(i)) == 1


kouho = list(map(str, range(1, 10)))
kouho2 = list(map(str, range(1, 10)))
while True:
    ll = []
    for i in kouho:
        su = list(filter(is_1_keta, [int(i[-1]) - 1, int(i[-1]), int(i[-1]) + 1]))
        l = [str(i) + str(x) for x in su]
        A.extend(l)
        ll.extend(l)
    kouho = ll
    kouho2.extend(ll)
    if len(kouho2) > k:
        break

print(sorted(list(map(int, kouho2)))[k - 1])


Measured memory_bytes: 29968
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val s = in.readLine()

    System.out.println(
      if(s.substring(0, n / 2) + s.substring(0, n / 2) == s) {
        "Yes"
      } else {
        "No"
      }
    )
  }
}


Measured memory_bytes: 25740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,T;
  cin >> N;
  T=0;
  vector<long long> L(N);
  for (int i=0;i<N;i++) {cin >> L[i];}
  sort(L.begin(),L.end());
  for (int i=0;i<N-1;i++) {T+=L[i];}
  if (T>L[N-1]) {cout << "Yes" << endl;} else {cout << "No" << endl;}
}


Measured memory_bytes: 256
#include<stdio.h>

int selection(int A[], int n){
    int i, mini, t, j, s = 0;
    for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j] < A[mini] ) mini = j;
    }
    t = A[i];
    A[i] = A[mini];
    A[mini] = t;
    if ( i != mini ) s++;
  }
  return s;
}

int main(){
  int A[100], n, i, j, t, s = 0, mini;

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

  for ( i = 0; i < n - 1; i++ ){
    printf("%d ", A[i]);
  }
  printf("%d", A[i]);
  printf("\n");
  printf("%d\n", s);

  return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>

int main(){

	int i,n,q,s[10000+1],t,c=0,k;

	scanf("%d",&n);

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

	scanf("%d",&q);

	for(i=0;i<q;i++){
		scanf("%d",&t);
		//seach
		s[n]=t;
		k=0;
		while(s[k]!=t){
			k++;
		}
		if(k!=n)
			c++;
		
	}
	printf("%d\n",c);

	return 0;
	
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int n;
int a[10010],b[10010];
int c[10010];
int deg[10010];
int ans[10010];
vector<int> g[10010];
int vs[10010];
int K=0;
void dfs(int v,int p){
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p)continue;
		dfs(u,v);
	}
	vs[K++]=v;
}
int main(){
	cin >> n;
	for(int i=0;i<n-1;i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		deg[a[i]]++;
		deg[b[i]]++;
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	for(int i=0;i<n;i++){
		cin >> c[i];
	}
	sort(c,c+n);
	K=0;
	dfs(0,-1);
	for(int i=0;i<n;i++){
		ans[vs[i]]=c[i];
	}
	int answer=0; 
	for(int i=0;i<n-1;i++){
		answer += c[i];
	}
	cout << answer << endl;
	for(int i=0;i<n;i++){
		cout << ans[i];
		if(i+1<n)cout << ' ';
		else cout << endl;
	}
	return 0;
}


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

namespace AtCoderBeginner
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            string answer;

            if (b - a == c - b)
                answer = "YES";
            else
                answer = "NO";
            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  for(int i = 0; i <= 100; i++) {
    int rest = N - i * 4;
    if(rest < 0) continue;
    if(rest % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import itertools

n,m = map(int,input().split())
graph = {i+1:set() for i in range(n)}

for i in range(m):
    a,b = map(int,input().split())
    graph[a] |= set([b])
    graph[b] |= set([a])

count = 0
node = [i+2 for i in range(n-1)]

for i in itertools.permutations(node):
    route = [1] + list(i)
    flag = True
    for j in range(n-1):
        if route[j+1] not in graph[route[j]]:
            flag = False
            break
    if flag == True:
        count += 1
print(count)

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

int main(void) {
    string S;cin>>S;
    char before;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i];
        if (i == 0) {
            if (s == '?') {
                if (i < S.size() - 1) {
                    char s_next = S[i + 1];
                    if (s_next == 'D') {
                        cout << 'P';
                        before = 'P';
                    } else {
                        cout << 'D';
                        before = 'D';
                    }
                } else {
                    cout << 'D';
                    before = 'D';
                }
            } else {
                before = s;
                cout << s;
            }
        } else {
            if (s == '?') {
                if (before == 'D') {
                    if (i < S.size() - 1) {
                        char s_next = S[i + 1];
                        if (s_next == 'D') {
                            before = 'P';
                            cout << 'P';
                        } else {
                            before = 'D';
                            cout << 'D';
                        }
                    } else {
                        before = 'D';
                        cout << 'D';
                    }
                } else {
                    before = 'D';
                    cout << 'D';
                }
            } else {
                before = s;
                cout << s;
            }
        }
    }
    cout << endl;
    return 0;
}

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

using namespace std;
const long long mod=1e9+7;

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

 vector<int>oks(N+1, true);
 for (int i = 0; i<M; i++) {
     int a;
     cin >> a;
     oks[a]=false;
 }

 vector<long> dp(N+1);
 dp[0] = 1;
 for (int now=0; now<N; now++) {
     for (int next=now+1; next<=min(N, now+2); next++) {
         if(oks[next]) {
             dp[next] += dp[now];
             dp[next]%=mod;
         }
     }
 }

 cout << dp[N] << endl;
 
  

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <cmath>
#include <cstring>
#include <climits>
#include <iomanip>
using namespace std;

#define FORN(i, j, k) for(int i=j;i<k;i++)
#define FORR(i, j, k) for(int i=j;i>=k;i--)
#define REP(i, n) FORN(i, 0, n)
#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl '\n'

const int MODO = 1e+9 + 7;
const int INF = 1e18L;

string k;
int d,n;
int dp[100001][101][2];

int apply_mod(int a){
		if(a>=MODO){
				a -= MODO;
		}
		return a;
}

int solve(int idx, int sum, bool prev_smaller){
	if(idx == n){
		return sum == 0;
	}
	
	if(dp[idx][sum][prev_smaller] != -1){
		return dp[idx][sum][prev_smaller];
	}
	
	int digit = prev_smaller ? 9 : (k[idx]-'0');
	
	int res = 0;
	REP(i, digit+1){
		res += solve(idx+1, (sum + i)%d, (prev_smaller || (i<digit && !prev_smaller)));
		res = apply_mod(res);
	}
	return dp[idx][sum][prev_smaller] = res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k;
	cin >> d;
	n = k.length();
	memset(dp, -1, sizeof(dp));
	cout << apply_mod(solve(0, 0, false) + MODO - 1) << endl;
	return 0;
}


Measured memory_bytes: 162300
#include<stdio.h>

int main()
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a % b;
	f =  1.0*a / b;
	printf("%d %d %lf\n",d,r,f);
	
	return 0;
}


Measured memory_bytes: 2120
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define INF 1e+8
struct Data {
	int cost,time;
	Data(){}
	Data(int cost, int time):cost(cost),time(time){}
};
int main() {
	int n,m;
	while(scanf("%d%d",&n,&m),(n|m)) {
		Data d[101][101];
		for(int i = 0; i < 101; i++) {
			for(int j = 0; j < 101; j++) {
				d[i][j] = Data(INF,INF);
			}
		}
		for(int i = 0; i < n; i++) {
			int a,b,cost,time;
			scanf("%d%d%d%d",&a,&b,&cost,&time);
			a--;b--;
			d[a][b] = Data(cost,time);
			d[b][a] = Data(cost,time);
		}
		for(int k = 0; k < m; k++) {
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < m; j++) {
					d[i][j].cost = min(d[i][j].cost,d[i][k].cost + d[k][j].cost);		
					d[j][i].cost = min(d[j][i].cost,d[j][k].cost + d[k][i].cost);		
					d[i][j].time = min(d[i][j].time,d[i][k].time + d[k][j].time);		
					d[j][i].time = min(d[j][i].time,d[j][k].time + d[k][i].time);		
				}
			}
		}
		int k;
		scanf("%d",&k);
		for(int i = 0; i < k; i++) {
			int p,q,r;
			scanf("%d%d%d",&p,&q,&r);
			p--;q--;
			if(r == 0)
				printf("%d\n",d[p][q].cost);
			else 
				printf("%d\n",d[p][q].time);
		}
	}
	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 6666,mo=1e9+7;
int n,k,a[N],res;
int main() {
	read(n);read(k);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)rep(j,1,n)if(a[i]>a[j])
		if(i<j)res=(res+1LL*k*(k+1)/2)%mo;
		else res=(res+1LL*k*(k-1)/2)%mo;
	cout<<res;
	return 0;
}


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

def main():
    H, W = map(int,input().split())
    sth, stw = 0, 0
    glh, glw = H-1, W-1

    INF = 10000
    Gmap = [list(input()) for _ in range(H)]
    Dist = [[INF]*W for _ in range(H)]
    direc = {(1,0), (0,1)}

    if Gmap[0][0]=='#':
        Dist[0][0]=1
    else:
        Dist[0][0]=0

    for h in range(H):
        for w in range(W):
            nw = Gmap[h][w]
            for d in direc:
                hs, ws = h + d[0], w + d[1]
                if 0<=hs<H and 0<=ws<W:
                    cr = Gmap[hs][ws]
                    Dist[hs][ws] = min(Dist[hs][ws], Dist[h][w] + (cr=='#' and nw=='.'))
    print(Dist[glh][glw])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9356
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  public static void solve() {
    int n = scanner.nextInt();
    int[] heights = new int[n];
    for (int i = 0; i < n; i++) {
      heights[i] = scanner.nextInt();
    }
    int[] dp = new int[n];
    dp[0] = 0; // first stone
    for (int i = 1; i < n; i++) {
      if (i == 1) {
        dp[i] = Math.abs(heights[i] - heights[i - 1]);
      } else {
        dp[i] = Math.min(
            dp[i - 1] + Math.abs(heights[i] - heights[i - 1]),
            dp[i - 2] + Math.abs(heights[i] - heights[i - 2])
        );
      }
    }
    printer.println(dp[n - 1]);
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 31848
D = int(input())
C = list(map(int, input().split()))

S = []
for _ in range(D):
  S.append(list(map(int, input().split())))

def solve():
  LastD = [0] * 26
  sc = 0
  for i in range(D):
    t = 0
    wk = -10000000000
    for tx in range(26):
      scwk = S[i][tx] + C[tx] * (i+1 - LastD[tx])
      if wk < scwk:
        wk = scwk
        t = tx
    sc += S[i][t]
    LastD[t] = i+1
    for j in range(26):
      sc -= C[j] * (i+1 - LastD[j])
    print(t+1)
  return sc
    
solve()


Measured memory_bytes: 9360
#-*-coding:utf-8-*-
import itertools

def main():
    s = list(input())
    string = []
    for i in s:
        string.append(i)
        string.append('')
    position = [x for x in range(1, len(string)-1, 2)]
    ans = 0

    for i in range(len(s)):
        places = list(itertools.combinations(position, i))
        for place in places:
            string_cp = string[:]
            for p in place:
                string_cp[p] = '+'
            ans += eval(''.join(string_cp))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N;cin >> N;
    string S;cin >> S;
    int count = 0;
    for(int i = 0;i < N - 1;++i){
        if(S[i] != S[i + 1])++count;
    }
    cout << count + 1 << endl;
}


Measured memory_bytes: 512
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<lint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
template <class typ> struct BIT{
	vector<typ> x;
	BIT(int n):x(n,0){}
	typ sum(int a,int b){
		if(a==0){
			typ s=0;
			for(int i=b;i>=0;i=(i&(i+1))-1) s+=x[i];
			return s;
		}
		else return sum(0,b)-sum(0,a-1);
	}
	void add(int ind,typ f){
		for(int i=ind;i<x.size();i|=i+1) x[i]+=f;
	}
};
lint a[114514],out[114514];
map<lint,int> de;
vector<lint> v;
int main()
{
	int n,m,ma=0;
	cin>>n;
	rep(i,n){
		cin>>a[i];v.pb(a[i]);
	}
	v.pb(0);
	sort(All(v));v.erase(unique(All(v)),v.end());
	//cout<<v<<endl;
	m=v.size();rep(i,m) de[v[i]]=i;
	BIT<lint> bi1(m+10),bi2(m+10);
	rep(i,n){
		int p=de[a[i]];
		bi1.add(p,a[i]);bi2.add(p,1);
	}
	rep(i,n){
		int p=de[a[i]],q=de[ma];
		bi1.add(p,-a[i]);bi2.add(p,-1);
		if(ma>=a[i]) continue;
		lint x=bi1.sum(p,m+5)-bi2.sum(p,m+5)*a[i],y=bi1.sum(q,m+5)-bi2.sum(q,m+5)*ma;
		out[i]=y-x;
		out[i]+=a[i]-ma;
		ma=a[i];
	}
	rep(i,n) cout<<out[i]<<endl;
}


Measured memory_bytes: 11252
#include <iostream>
using namespace std;
int main() {
    int x;
    cin>>x;
    long long max=0;
    long long arr[x];
    for (int i = 0; i <x ; ++i) {
        cin>>arr[i];
    }
    for (int i = 0; i <x-1 ; ++i) {
        long long temp=0;
        for (int j = i; j <x ; ++j) {

            if(arr[j]>=arr[j+1]){
                temp++;
            }
            else{
                if(temp>max){
                   
                    max=temp;}
                i=j;
                break;
            }
        }
    }
    cout<<max;
}

Measured memory_bytes: 1024
module Main where
import Data.List

int = read :: String -> Int

main = interact $ printer . solver . parser

printer = unlines . (:[]) . show

parser = map int . tail . words

solver :: [Int] -> Int
solver is = counter tf 
  where
    tf = zipWith (==) is [1..]
    counter [] = 0
    counter (True:[]) = 1
    counter (False:[]) = 0
    counter (True:True:tfs) = 1 + counter tfs
    counter (False:True:tfs) = counter (True:tfs)
    counter (True:False:tfs) = 1 + counter tfs
    counter (False:False:tfs) = counter tfs


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;
string s;


bool isYYMM() {
    string b;
    b = b + s[2];
    b = b + s[3];
    int num = std::atoi(b.c_str());

    if(num > 12 || num == 0) {
        return false;
    }
    return true;
}

bool isMMYY() {
    string b;
    b = b + s[0];
    b = b + s[1];
    int num = std::atoi(b.c_str());
    if(num > 12 || num == 0) {
        return false;
    }
    return true;
}

int main() {
    cin >> s;

    if(isYYMM() && isMMYY()) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if(isYYMM()) {
        cout << "YYMM" << endl;
        return 0;
    }

    if( isMMYY()) {
        cout << "MMYY" << endl;
        return 0;
    }

    cout << "NA" << endl;


}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	ll a,b,c;
    	cin>>a>>b>>c;
    	swap(a,b);
    	swap(a,c);
    	cout<<a<<" "<<b<<" "<<c;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
static const int MAX = 1e4;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0] = GRAY;

  while(!PQ.empty()){
    pair<int,int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    //最小値を取り出し、それが最短でなければ無視
    if(d[u] < f.first * (-1)) continue;

    for(int j=0;j<adj[u].size();j++){
      int v = adj[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second){
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i]==INFTY ? -1 : d[i]) << endl;
  }
}

int main(){
  int k,u,v,c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
}



Measured memory_bytes: 8096
#include<iostream> 
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#define INF 1<<29
#define MAX 3000
using namespace std;int cost[MAX][MAX],V,d[MAX];bool used[MAX];void dijkstra(int);int main(){int m,s,g1,g2,b1,b2,c;while(true){cin >> V >> m >> s >> g1 >> g2;if(V == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0)break;for(int i=1;i<=V;i++){for(int j=1;j<=V;j++){cost[i][j]=INF;}}for(int i=0;i<m;i++){cin >> b1 >> b2 >> c;cost[b1][b2]=c;}dijkstra(s);int ans = d[g1]+d[g2];int dr[MAX];for(int i=1;i<=V;i++)dr[i]=d[i];for(int i=1;i<=V;i++){if(i == s)continue;dijkstra(i);ans = min(ans,dr[i]+d[g1]+d[g2]);}cout << ans << endl;}}void dijkstra(int s){for(int i=1;i<=V;i++){d[i]=INF;used[i]=false;}d[s] = 0;while(true){int v=-1;for(int u=1;u<=V;u++){if(!used[u] && (v == -1 || d[u] < d[v]))v = u;}if(v == -1)break;used[v]=true;for(int u=1;u<=V;u++){d[u]=min(d[u],d[v]+cost[v][u]);}}}

Measured memory_bytes: 0
"""
回転した後に得られる点数 = 上と下を向いている面以外の面に書かれている数
6→5→6→...と選んでいけばよさそう。
"""
X = int(input())
if X <= 6:
    print(1)
elif X <= 11:
    print(2)
else:
    cnt = X // 11
    X -= cnt * 11
    if X == 0:
        print(cnt * 2)
    elif X <= 6:
        print(cnt * 2 + 1)
    else:
        print(cnt * 2 + 2)


Measured memory_bytes: 61876
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long a[100005],ans;
struct point{
	int so;
	int numb;
};
bool cmp(int x,int y){
	return x<y;
}
bool cmp1(point x,point y){
	return x.numb>y.numb;
}
point b[100005];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i].so>>b[i].numb;
	}
	sort(a,a+n,cmp);
	sort(b,b+m,cmp1);
	long long i=0,j=0,timeses=0,ans=0;
	for(i=0;i<n;){
		if(timeses==b[j].so){
			j++;
			timeses=0;
			continue;
		}
		if(a[i]<b[j].numb){
			ans+=b[j].numb;
			timeses++;
		}
		else ans+=a[i];
		i++;
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, i, k;
    scanf("%d", &n);
    int a[n+1];
    for(i=0; i<n; i++){
		scanf("%d", &a[i]);
    }
	k=-100;
	for(i=0; i<n; i++){
		if(k <= a[i]-1){
			k=a[i]-1;
		}
		else if(k <= a[i]) k=a[i];
		else{
			printf("No");
			return 0;
		}
	}
	printf("Yes");

    return 0;
}


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

int main() {
long long n;
cin>>n;
long long a[n];

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

long long dp[n];

dp[0]=0;
dp[1]=abs(a[0]-a[1]);

for(long long i=2;i<n;i++){
	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
}

cout<<dp[n-1];
return 0;
}

Measured memory_bytes: 1792
def main():
    N, K = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        cnt = 0
        while n < K:
            n = n << 1
            cnt += 1
        ans += (1 / N) * (0.5**cnt)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
	int n, m ;
	while(cin >> n >> m , n){
		long double table[100][100];
		long double dp[2][100] = {{0.0}};
		
		
		rep(i,n)rep(j,n)cin >> table[i][j];
		rep(i,n)dp[0][i] = 1.0;
		bool sw = false;
		
		rep(i,m-1){ // kaisu 
			rep(j,n){ // chokuzen 
				rep(k,n){ // current
					dp[sw^1][k] = max(dp[sw^1][k] , dp[sw][j] * table[j][k]);
				}
			}
			sw ^= 1;
		}
		long double ret = 0;
		rep(i,n){
			ret = max(ret,dp[sw][i]);
		}
		printf("%.2Lf\n",ret);
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
    int n, b, f, r, v, a[4][3][10] = {}, i, j, k;
    char c;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%c", &c);
        scanf("%d%d%d%d", &b, &f, &r, &v);
        a[b - 1][f - 1][r - 1] += v;
    }

    for(i = 0; i < 4; i++) {
        if(i != 0) printf("####################\n");
        for(j = 0; j < 3; j++) {
            for(k = 0; k < 10; k++) {
                printf(" %d", a[i][j][k]);
            }
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2040
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

bool isprime(ll n){
  	if(n==1) return false;
	if(n==2) return true;
 	else if(n%2 == 0) return false;
  	else{
    	ll rn = floor(sqrt(n));
      	for(int i = 3; i <= rn; i += 2){
        	if(n%i == 0) return false;
        }
    }
  	return true;
}

void Main()
{
	ll X;
  	cin >> X;
  	ll ans;
  	rep3(i, X, 2*X){
		 if(isprime(i)) {
           ans = i;
           break;
         }   
    }
    cout << ans << endl;       
	return;
}

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

Measured memory_bytes: 256
import bisect
from collections import deque
N = int(input())
nums = deque([])

for i in range(N):
    num = int(input())
    if i == 0:
        nums.append(num)
    else:
        if nums[-1] < num:
            nums[-1] = num
        else:
            insert_index = bisect.bisect_left(nums, num)
            if insert_index == 0:
                nums.appendleft(num)
            else:
                nums[insert_index - 1] = num
#     print(nums)
# print(nums)
print(len(nums))


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

int main() {
    int k, n; cin >> k >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    int dis = 0;
    for (int i = 0; i < n - 1; ++i) {
        dis = max(dis, abs(a[i] - a[i + 1]));
    }

    dis = max(dis, a.front() + (k - a.back()));
    cout << k - dis << endl;
}



Measured memory_bytes: 4040
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    string s; cin >> s;
    set<char> st;
    for(auto i : s){
      st.insert(i);
    }
    if(st.count('N')^st.count('S')==0&&st.count('E')^st.count('W')==0){
      cout << "Yes";
    }
    else cout << "No";
}


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

int main() {
    int h, w;
    while(true) {
        cin >> h >> w;
        if(h == 0 && w == 0) break;

        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(i == 0 || i == h - 1) {
                    cout << "#";
                } else {
                    if(j == 0 || j == w - 1) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll keta(ll i){
    ll t=0;
    while(i){
        i/=10;
        t++;
    }
    return t;
}
int main(){
    int n,ans=0;cin>>n;
    For1(i,n+1){
        if(keta(i)%2==1){
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if (b + c <= a) ans = 0;
    else ans = c - (a - b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll n;
ll a[100005];
ll b[100005];

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

        if (i % 2 == 0) {
            b[0] += a[i];
        }
        else {
            b[0] -= a[i];
        }
    }

    for (ll i = 1; i < n; i++) {
        b[i] = 2 * (a[i - 1] - (b[i - 1] / 2));
    }

    _Bool f = 0;
    for (ll i = 0; i < n; i++) {
        if (f) putchar(' ');
        printf("%lld", b[i]);
        f = 1;
    }

    putchar('\n');

    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define fir first
#define sec second
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define maxd 1000000007
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,m,a[100100],tmp[100100],d[100100],ans[100100];
ll k;
double f[100100];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	rep(i,1,n) 
	{
		a[i]=read();d[i]=i;ans[i]=i;
	}
	m=read();scanf("%lld",&k);
	rep(i,1,m)
	{
		int x=read();
		swap(d[x],d[x+1]);
	}
	while (k)
	{
		if (k&1)
		{
			rep(i,1,n) tmp[i]=ans[d[i]];
			rep(i,1,n) ans[i]=tmp[i];
		}
		k>>=1;
		rep(i,1,n) tmp[i]=d[d[i]];
		rep(i,1,n) d[i]=tmp[i];
	}
	rep(i,1,n) f[i]=a[ans[i]]-a[ans[i]-1];
	rep(i,1,n) f[i]+=f[i-1];
	rep(i,1,n) printf("%.1lf\n",f[i]);
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  if(K>(N-1)*(N-2)/2){
    cout<<-1<<endl;
    return 0;
  }
  cout<<N-1+((N-1)*(N-2)/2-K)<<endl;
  REP(i,N-1)cout<<"1 "<<2+i<<endl;
  int i=2;
  int j=3;
  REP(k,(N-1)*(N-2)/2-K){
    cout<<i<<" "<<j<<endl;
    j++;
    if(j>N){
      i++;
      j=i+1;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n,k,*h=map(int,open(0).read().split());
dp=[0]*n;
for i in range(1,n):
    dp[i]=min(dp[j+max(i-k,0)]+abs(a-h[i])for j,a in enumerate(h[max(i-k,0):i]));
print(dp[-1])

Measured memory_bytes: 59948
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int N,M;
    cin >> N >> M;
    char A[N][N];
    char B[M][M];
    REP(i,N){
        REP(j,N){
            cin >> A[i][j];
        }
    }
    REP(i,M){
        REP(j,M){
            cin >> B[i][j];
        }
    }
    int dx[N-M+1],dy[N-M+1];
    REP(i,N-M+1){
        dx[i] = i;
        dy[i] = i;
    }
    bool flag;
    REP(i,N-M+1){
        REP(j,N-M+1){
            flag = true;
            REP(k,M){
                REP(l,M){
                    if(B[k][l]==A[k+dx[i]][l+dy[j]]){
                        flag = true&&flag;
                    }else{
                        flag = false;
                        break;
                    }
                }
            }
            if(flag){
                break;
            }
        }
        if(flag){
            break;
        }
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

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

	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i],a[i]/=2;
	// for(int i=0;i<n;i++) cout<<a[i]<<" ";
	int cnt2=0;
	for(int i=0;i<n;i++)
	{
		int x=a[i];
		int cnt=0;
		while(x%2==0) cnt++,x/=2;
		cnt2=max(cnt2,cnt);
	}
	for(int i=0;i<n;i++)
	{
			int cnt=0;
			int x=a[i];
			while(x%2==0) cnt++,x/=2;
			if(cnt2!=cnt)
			{
				cout<<"0";
				return 0;
			}
	}
	int an=1;
	int prev=a[0];
	for(int i=1;i<n;i++)
	{
		int x=a[i];
		int gcd=__gcd(x,prev);
		x/=gcd;
		if(x*prev>m)
		{
			cout<<"0\n";
			return 0;
		}
		prev=x*prev;
	}
	// for(auto x:ma) cout<<x.fi<<" "<<x.se<<"\n";
	// cout<<an;
	an=prev;
	int o=m/an;
	if(o%2==0)
	{
		o/=2;
	}
	else{
		o/=2;
		o++;
	}
	cout<<o;
}  
// I never lose. I either win or I learn

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
using namespace std;

int B();

int main(){
    int a,b;
    cin >> a >> b;
    int temp = a;
    int count = 1;
    while(temp < b){
        count++;
        temp += a-1;
    }
    if(b == 1) cout << 0 << endl;
    else cout << count << endl;
}

int B(){
    double a,b;
    cin >> a >> b;
    //a口のをつかってｂにしたい
    if(a >= b) cout << 1;
    else{
    double temp1 = b - a;// cout << temp1 << endl;
    double temp2 = a - 1;// cout << temp2 << endl;
    int temp = (int)ceil(temp1/temp2) + 1;
    cout <<  temp << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;

int main() {
    int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3,y3,x4,y4;
    x3 = x2 - dy, y3 = y2 + dx;
    x4 = x3 - dx, y4 = y3 - dy;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int a;
	cin>>a;
	V<int> b(a);
	fo(i,a){
		cin>>b[i];
	}
	Sort(b);
	cout<<b[a-1]-b[0]<<endl;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n;
    cin >> n;
    map<int,int> e;
    map<int,int> o;
    int t;
    for(int i = 0; i < n; i++) {
        cin >> t;
        if(i%2==0) e[t]++;
        else       o[t]++;
    }
    vector<pair<int,int>> ape;
    vector<pair<int,int>> apo;
    pair<int,int> tmp;
    for(auto itr = e.begin(); itr != e.end(); itr++) {
        tmp.first=itr->second;
        tmp.second=itr->first;
        ape.emplace_back(tmp);
    }
    for(auto itr = o.begin(); itr != o.end(); itr++) {
        tmp.first=itr->second;
        tmp.second=itr->first;
        apo.emplace_back(tmp);
    }
    sort(ape.rbegin(),ape.rend());
    sort(apo.rbegin(),apo.rend());
    int ans;

    if(ape[0].second!=apo[0].second) ans=n-apo[0].first-ape[0].first;
    else{
        if(ape[0].first+apo[1].first > apo[0].first+ape[1].first){
            ans=n-ape[0].first-apo[1].first;
        }
        else{
            ans=n-apo[0].first-ape[1].first;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6136
n, x = map(int, input().split())

if x == 1:
    print("No")
elif x == 2*n-1:
    print("No")
else:
    print("Yes")
    result = [i for i in range(1, 2*n)]
    result = result+result+result
    p = n-x
    for i in result[2*n-1-p:2*n-1-p+2*n-1]:
        print(i)

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

int main() {
    string o, e;
    cin >> o >> e;

    rep(i, o.size()) {
        cout << o[i];
        if (i < e.size()) cout << e[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

int GCD(int a, int b) {
	if(a % b == 0){
		return b;
	} else {
		return GCD(b, a % b);
	}
}

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N + 1);
    for(int i = 0; i <= N; i++)cin >> A[i];
    sort(A.begin(), A.end());
    long long ans = abs(A[1] - A[0]);
    for(int i = 1; i < N; i++){
        long long dis = abs(A[i + 1] - A[i]);
        ans = GCD(ans, dis);
        if(ans == 1)break;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
<?php
$in = explode(" ", trim(fgets(STDIN)));
$a = $in[0];
$b = $in[1];
$c = $in[2];

$count = 0;
for($i = $a; $i <= $b; $i++)
{
    if($c % $i == 0)
    {
        $count += 1;
    }
}
echo $count . "\n";

Measured memory_bytes: 15308
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()


for i in range(0, 10**7):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 40172