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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int res = 0;
    for (int i = 1; ; i++) {
        int need = i * y + (i + 1) * z;
        if (need > x) break;
        res = i;
    }
    cout << res << endl;
}

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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];

  // sort(all(A), greater<ll>());
  // sort(all(B), greater<ll>());
  // sort(all(C), greater<ll>());
  sort(all(A));
  sort(all(B));
  sort(all(C));
  ll ans = 0;
  ll j = 0;
  ll k = 0;
  vector<ll> dp(N+1);
  dp[0] = 0;
  rep(i, N) {
    while(B[j] < C[i] && j < N) {
      while(A[k] < B[j] && k < N) {
        k++;
      }
      dp[j+1] = dp[j] + k;
      j++;
    }
    // cerr << i <<" "<< j <<" "<< k <<" "<<  dp[j] << endl;
    ans += dp[j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159;
int main()
{
    long long int n,m,a=0,b,i;
    cin>>n;
    map<long long int,long long int>mp;
    for(i=0; i<n-1; i++)
    {
        cin>>b;
        mp[b]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 16132
var
	s:string;
function check():boolean;
var	i,j,p:longint;
begin
	p:=0;
	for i:=1 to length(s) do 
	begin
		if s[i]='C' then 
		begin
			p:=i;
			break;
		end;
	end;
	if (p <> 0) then 
	begin
		for j:=p to length(s) do if s[j] = 'F' then exit(true);
	end;
	exit(false);
end;
begin
	readln(s);
	if (check) then writeln('Yes')
	else writeln('No');
end.

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

using namespace std;

int N;
vector<long long> dp;
vector<bool> broke;
const int mod = 1e9 + 7;

long long dfs(int pos)
{
  long long& res = dp[pos];
  if (res >= 0) return res;
  if (broke[pos]) return res = 0;
  return res = (dfs(pos+1) + dfs(pos+2)) % mod;
}

int main()
{
  int M;
  cin >> N >> M;
  dp.resize(N+2, -1);
  broke.resize(N+1, false);
  dp[N] = 1;
  dp[N+1] = 0;
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    broke[t] = true;
  }
  long long res = dfs(0);

  cout << res << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素因数分解 (連想配列)
template<typename T>
T prime_fact(ll n) {
	T mp;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		ll cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		mp[i] = cnt;
	}
	if (n > 1) mp[n] = 1;
	return mp;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	map<ll, ll> mp = prime_fact<map<ll, ll>>(n);

	ll ans = 0;
	for (auto i : mp) {
		ll x = i.second, y = 1;
		while (x >= y) {
			ans++;
			x -= y;
			y++;
		}
	}

	cout << ans << endl;
}


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

/* */

int main(){
    // 入力スタンダード
    int k;
    cin >> k;

    int s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << s[k-1] << endl;

    return 0;
}

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

int main(){
  int r[200000],n,maxv,minv,i;

  scanf("%d",&n);
  if(n<2||200000< n) exit(8); 

  for(i=0;i<n;i++){
    scanf("%d",&r[i]);
  }
  
  maxv=r[1]-r[0];
  minv=r[0];
  
  for(i=1;i<n;i++){
    if(maxv<r[i]-minv) maxv=r[i]-minv;
    if(minv>r[i]) minv=r[i];
  }

  printf("%d\n",maxv);

  return 0;
}
  
	 

Measured memory_bytes: 3536
#include <cstdio>
#include <cstring>
#include <algorithm>
const long long MOD  = 1e9+7;
using namespace std;
typedef long long LL;
int main()
{
	LL n;
	scanf("%lld",&n);
	LL ans = 1;	
	for(int i = 1 ;i<=n;i++)
	{
		ans = ((ans % MOD)* i)%MOD;
	}
	printf("%lld\n",ans);
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll m,n,i,j,k,p=1000000007,count=0,flag=0,temp1=0,temp2=0;
  string s;
        
   cin>>n;
   double temp=(double)n/3;

   temp*=temp*temp; 

   cout<<fixed<<setprecision(9)<<temp<<endl;

return 0; 
 
 
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int a[N], ans[N];
vector<int> g[N];
multiset<int> S;

void dfs(int x, int p = -1) {
    S.insert(a[x]);
    auto it = next(S.lower_bound(a[x]));
    bool deleted = 0;
    int deleted_val = 0;
    
    if (it != S.end()) {
        deleted = 1;
        deleted_val = *it;
        S.erase(it);
    }
    ans[x] = S.size();
    
    for (int y: g[x]) {
        if (y == p) continue;
        dfs(y, x);
    }
    
    if (deleted) S.insert(deleted_val);
    S.erase(S.find(a[x]));
}

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

    int n;
    cin >> n;

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

    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(1);

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

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

using namespace std;

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

  long long x, y;
  cin >> x >> y;
  // x * 2^n <= y
  long long i;
  y /= x; 
  for (i = 1; ((long long)(1)<<i) <= y; ++i);
  cout << i << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int>ans;
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        ans[s]++;
    }
    cout<<"AC x "<<ans["AC"]<<endl;
    cout<<"WA x "<<ans["WA"]<<endl;
    cout<<"TLE x "<<ans["TLE"]<<endl;
    cout<<"RE x "<<ans["RE"]<<endl;
}


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



int main() {
    int n, k;
    cin >> n >> k;
    
    int cnt = 0;
    while(n > 0) {
        n /= k;
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}




Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
    int w, h, n, a, b, c, d;
    cin>>w>>h>>n;
    a =0, b = w, c =0, d = h;
    while( n--)
    {
        int x, y, m;
        cin>>x>>y>>m;
        if( m ==1) a = max( a, x );
        if( m ==2) b = min( b, x );
        if( m ==3) c = max( c, y );
        if( m ==4) d = min( d, y );
    }
    w =(b-a<0?0:b-a);
    h =(d-c<0?0:d-c);
    cout<<w*h<<endl;
    return 0;
}

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

using namespace std;

typedef long long int lli;


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

	lli dp[3] = {0,0,0};
	for(lli day=0; day<n; day++)
	{
		lli c[3];
		lli temp_dp[3] = {0,0,0};
		for(int i=0; i<3; i++) cin >> c[i];
 
        /* dp[i] is the maximum value of happiness when last day 
           ith activity was performed */

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<3; j++)
			{
				if(i!=j)  temp_dp[j] = max(temp_dp[j], dp[i]+c[j]);
			}
		}	

		for(int i=0; i<3; i++)  dp[i] = temp_dp[i];

	}
    
    cout << max(dp[0], max(dp[1], dp[2])) << endl;


	

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		int n=gInt(),x=gInt();
		int[]c=INTS(n).sorted().toArray();
		x-=Arrays.stream(c).sum();
		System.err.println(x);
		System.out.println(n+x/c[0]);
	}
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
//    ll res = 1;      
//    x = x % p;   
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) % p;
//        y = y >> 1; 
//        x = (x * x) % p;
//    }
//    return res;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

// ll gcd(ll a, ll b){
// 	if (a == 0)
// 		return b;
// 	else
// 		return gcd(b % a, a);
// }

int main()
{
// #ifndef ONLINE_JUDGE   
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	string a,b;
	cin>>a>>b;
	ll x=0,y=0;
	cin>>x>>y;
	string t;
	cin>>t;
	if(t==a)
		--x;
	else
		--y;
	cout<<x<<" "<<y;

	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int cnt = 0;
            for (int i = 0; i < N - 2; i++)
            {
                if (a[i] < a[i + 1] && a[i + 1] < a[i + 2]) cnt++;
                if (a[i] > a[i + 1] && a[i + 1] > a[i + 2]) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}



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

typedef long long ll;
ll P, Q, A, N;

ll DFS(ll p, ll q, ll n, ll m)
{
    if(P * q == p * Q)return 1;
    if(P * q < p * Q)return 0;
    if(n == N)return 0;

    ll ret = 0;
    for(ll i = m; q * i <= A; i++)
    {
        ret += DFS(p * i + q, q * i, n + 1, i);
    }
    return ret;
}

int main()
{
    while(scanf("%lld%lld%lld%lld", &P, &Q, &A, &N))
    {
        if(P == 0 && Q == 0 && A == 0 && N == 0)return 0;
        printf("%lld\n", DFS(0, 1, 0, 1));
    }

    return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
int main(){int n,l,s;scanf("%d",&n);while(n--){int i[3];scanf("%d %d %d",&i[0],&i[1],&i[2]);l=2;while(l--){if(i[l+1]>i[l]){s=i[l+1];i[l+1]=i[l];i[l]=s;}}printf("%s\n",i[2]*i[2]+i[1]*i[1]==i[0]*i[0]?"YES":"NO");}return 0;}

Measured memory_bytes: 1008
// 解题常用步骤：转化 找性质 推式子
// 本题第一步转化起到了简化的作用
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 5e5 + 10, inf = 0x3f3f3f3f;
int n, K, a[N], x, ans[N];
int mn[N << 2], deg[N];
priority_queue<int, vector<int>, greater<int> >q;  // 用 pq 来求最小拓扑序
vector<int> e[N];

void upd(int x) { mn[x] = min(mn[x << 1], mn[x << 1 | 1]); }

void modify(int x, int l, int r, int pos, int v) {
    if (l == r) { mn[x] = v; return; }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(x << 1, l, mid, pos, v);
    else modify(x << 1 | 1, mid + 1, r, pos, v);
    upd(x);
}

int query(int x, int l, int r, int lx, int rx) {
    if (rx < l || lx > r) return inf;
    if (lx <= l && r <= rx) return mn[x];
    int mid = (l + r) >> 1;
    return min(query(x << 1, l, mid, lx, rx), query(x << 1 | 1, mid + 1, r, lx, rx));
}

int main() {
    cin >> n >> K;
    rep(i, 1, n) scanf("%d", &x), a[x] = i;
    memset(mn, 0x3f, sizeof(mn));
    for (int i = n, j; i >= 1; i--) {
        if ((j = query(1, 1, n, a[i] + 1, a[i] + K - 1)) != inf)
            ++deg[a[j]], e[a[i]].push_back(a[j]);
        if ((j = query(1, 1, n, a[i] - K + 1, a[i] - 1)) != inf)
            ++deg[a[j]], e[a[i]].push_back(a[j]);
        modify(1, 1, n, a[i], i);
    }
    rep(i, 1, n) if (!deg[i]) q.push(i);
    int tot = 0;
    while (q.size()) {
        int x = q.top(); q.pop();
        a[++tot] = x;
        for (int i = 0; i < e[x].size(); i++) {
            int y = e[x][i];
            if (!(--deg[y])) q.push(y);
        }
    }
    rep(i, 1, n) ans[a[i]] = i;
    rep(i, 1, n) printf("%d\n", ans[i]);
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    ll a,b,c;
    cin>>a>>b>>c;

    string ans="Yes";
    if(a+b>c)ans="No";
    else if(4*a*b>=(c-a-b)*(c-a-b))ans="No";

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int K;
    cin >> K;
    vector<long long> A(K);
    for ( int i = 0; i < K; i++ ) {
        cin >> A[i];
    }
    
    reverse( A.begin(), A.end() );
    
    
    long long l = 2,r = 2;
    for ( int i = 0; i < K; i++ ) {
        
        l = A[i] * ( ( l/A[i] ) + ( (l%A[i]) ? 1 : 0  ) );
        r = A[i] * ( r/A[i] ) + A[i]-1;
        
        if ( l > r ) { cout << -1 << endl; return 0; }
    }
    
    
    
    
    cout << l << endl;
    cout << r << endl;
    
    
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 500;

int n, h;
int in[N], out[N], fa[N];
bool self[N];

inline int getf(int x) {
  return fa[x] ? fa[x] = getf(fa[x]) : x;
}

inline void link(int x, int y) {
  x = getf(x); y = getf(y);
  if (x != y) fa[x] = y;
}

int main() {
  scanf("%d%d", &n, &h);
  for (int i = 1, a, b, c, d, p, q; i <= n; i ++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (!c) p = h + a;
    else p = h - c;
    if (!d) q = h - b;
    else q = h + d;
    link(p, q);
    out[p] ++; in[q] ++;
    if (p == q) self[p] = 1;
    // cerr << p << " "<< q << endl;
  }
  for (int i = 0; i <= h + h; i ++) {
    if (i > h && in[i] > out[i]) return 0 * puts("NO");
    if (i < h && in[i] < out[i]) return 0 * puts("NO");
    bool fd = 0, fri = self[i];
    for (int j = 0; j <= h + h && !fd; j ++)
      if (getf(j) == getf(i)) {
        if (i != j) fri = 1;
        if (in[j] != out[j]) fd = 1;
      }
  if (!fd && fri) return 0 * puts("NO");
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 256
import bisect
import math
N, H = map(int, input().split())
a, b = [], []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
ma = max(a)
b.sort()
b = list(reversed(b[bisect.bisect_left(b, ma):]))
# print(b)
ans = 0
for i in range(len(b)):
    ans += 1
    H -= b[i]
    if H <= 0:
        print(ans)
        exit()
print(ans + math.ceil(H / ma))
# print(bisect.bisect_left(b, ma), ma, b)


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

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

    int S[13];
    int H[13];
    int C[13];
    int D[13];
    for(int i=0;i<13;i++){
        S[i]=0;
        H[i]=0;
        C[i]=0;
        D[i]=0;
    }

    for(int i=0;i<n;i++){
        char t;
        int num;
        cin>>t>>num;
        
        if(t=='S')S[num-1]=1;
        if(t=='H')H[num-1]=1;
        if(t=='C')C[num-1]=1;
        if(t=='D')D[num-1]=1;
    }

    for(int i=0;i<13;i++){
        if(S[i]==0)cout<<"S "<<i+1<<endl;

    }

    for(int i=0;i<13;i++){
        if(H[i]==0)cout<<"H "<<i+1<<endl;
    }

    for(int i=0;i<13;i++){
        if(C[i]==0)cout<<"C "<<i+1<<endl;
    }

    for(int i=0;i<13;i++){
        if(D[i]==0)cout<<"D "<<i+1<<endl;
    }


    return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>
int main()
{
  int N,i,s[11],k,b,a;
  char c;
  while(1){
    for(k=0;k<11;k++){
      s[k]=0;
    }
    b=0;
    scanf("%d",&N);
    scanf("%c",&c);
    if(N==0)break;
    for(i=0;i<100;i++){
      scanf("%c",&c);
      for(k=0;k<N;k++){
	if(i%N==k){
	  if(c=='M')s[k]=s[k]+1;
	  else if(c=='S'){
	    b=b+s[k]+1;
	    s[k]=0;
	  }
	  else if(c=='L'){
	    s[k]=s[k]+b+1;
	    b=0;
	  }
	}
      }
    }
    for(k=1;k<N;k++){
      for(i=1;i<N;i++){
	if(s[i]<s[i-1]){
	  a=s[i];
	  s[i]=s[i-1];
	  s[i-1]=a;
	}
      }
    }
    for(k=0;k<N;k++){
      printf("%d ",s[k]);
    }
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

struct rest{
    int no;
    string place;
    int point;

    rest(int inputted_no,string inputted_place,int inputted_point){
        no = inputted_no;
        place = inputted_place;
        point = inputted_point;
    }
};

bool cmp(const rest & a,const rest &b){
    if(a.place==b.place){
        return a.point>b.point;
    }
    return a.place<b.place;
}

int main(){
    
    int N,P;
    string S;
    vector<rest> Rest;
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> S>>P;    
        Rest.push_back(rest(i+1,S,P));
    }

    sort(Rest.begin(),Rest.end(),cmp);

    for(int i=0;i<N;i++){
        cout << Rest[i].no<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    arc059c()
}

fun arc059c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val answer = (aList.min()!!..aList.max()!!)
        .map { a -> aList.map { (it - a) * (it - a) }.sum() }.min()

    println(answer)
}


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int pre[1000001],bj[100001];
int find(int x) {
	return pre[x]==x?x:pre[x]=find(pre[x]);
}
main() {
	int n=read(),m=read();
	for(int i=1; i<=n; i++)
		pre[i]=i;
	for(int i=1; i<=m; i++) {
		int x=read(),y=read(),z=read();
		int fx=find(x),fy=find(y);
		if(fx!=fy) pre[fx]=fy;
	}
	for(int i=1; i<=n; i++)
		bj[find(i)]=1;
	int ans=0;
	for(int i=1; i<=n; i++)
		if(bj[i]) ans++;
	cout<<ans;
}


Measured memory_bytes: 1152
#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>;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()) {
    if (s[i] == t[i]) ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int M = 1e5 + 50;
int a[M]; 
int main(){
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	int minn = a[n-1];
	int f = 0;
	for(int i = n-2;i>=0;i--){
		if(a[i]>minn+1){
			f = 1;
			break;
		}
		else{
			minn = min(minn,a[i]);
		}
	}
	if(f == 1)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	return 0;
}

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

ll x, y;
int ans;

int main()
{
    scanf("%lld %lld", &x, &y);
    while (x <= y)
    {
        ans++;
        x *= 2LL;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 2005;

int dp[N][N][2];

int a[N],n,x,y;

int f(int i,int j,int k){
    if(dp[i][j][k] != -1) return dp[i][j][k];
    if(i == n  || j == n )
        return abs(a[i] - a[j]);
    if(k)
        return dp[i][j][k] = max(f(i , j + 1, k), f(j + 1 , j , !k));
    else
        return dp[i][j][k] = min(f(i + 1, j, k), f(i + 1, i, !k));
}

int main(){
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d",&n,&x,&y);
    a[0] = y;
    for(int i = 1;i<=n;i++)
        scanf("%d",a+i);
    printf("%d\n",f(0 , 1 , 1));
}


Measured memory_bytes: 31872
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
bool vis[200005];
vector<int> a[200005];
int dfs(int n)
{
    int ans=0;
    if(!vis[n])
    {
        vis[n]=true;
        ++ans;
        for(int i=0;i<a[n].size();i++)
        {
            ans+=dfs(a[n][i]);
        }
    }
    return ans;
}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    memset(vis,false,n);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        --x,--y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
           ans=max(ans,dfs(i));
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 20904
from fractions import gcd


class SegTree():
    # ここでは操作の都合上根元のindexを1とする
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*2**(self.K+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)


# gcd on blackboard
# セグ木（区間gcd) verify
N = int(input())
A = list(map(int, input().split()))
seg = SegTree(A, gcd, 0)
ans = 1
for i in range(-1, N):
    v = gcd(seg.query(0, i), seg.query(i+1, N))
    ans = max(v, ans)
print(ans)

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end


int main(){
   int n; cin>>n;
   vector<string> a(n);
   rep(i,0,n)cin>>a[i];
   vector<int> mi(n,0),add(n);
   int sum=0;
   rep(i,0,n){
      rep(j,0,a[i].size()){
         if(a[i][j]=='(')add[i]++;
         else add[i]--;
         chmin(mi[i],add[i]);
      } sum+=add[i];
   }
   vector<int> ord(n); iota(ALL(ord),0);
   sort(ALL(ord),[&](int i,int j){
      if(add[i]>=0 and add[j]<0)return true;
      if(add[i]<0 and add[j]>=0)return false;
      if(add[i]>=0){
         return mi[i]>mi[j];
      }
      else{
         return add[i]-mi[i]>add[j]-mi[j];
      }
   });
   for(int i:ord){
      if(sum+mi[i]<0){
         puts("No"); return 0;
      }
      sum+=add[i];
   }
   if(sum==0)puts("Yes"); else puts("No");
   return 0;
}


Measured memory_bytes: 46280
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int main(){
	int n,before=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		ans+=max(0,x-before);
		before=x;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x;
    cin>>x;
    x=x-1;
    while(true){
        x++;
        int m=0;
        for(int i=1;i<=x;i++)
            if(x%i==0)
                m++;
        if(m==2)
            break;
    }
    cout<<x;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(i){float s[2];int d[2][4]={};while(scanf("%f%f",&s[0],&s[1])!=EOF){for(i=0;i<2;i++){if(s[i]<0.2)d[i][3]++;else if(s[i]<0.6)d[i][2]++;else if(s[i]<1.1)d[i][1]++;else d[i][0]++;}}for(i=0;i<4;i++)printf("%d %d\n",d[0][i],d[1][i]);return 0;}

Measured memory_bytes: 0
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }


long long computeXOR(long long n) {
  switch (n % 4) {
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
  }
}
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  
  long long A, B;
  cin >> A >> B;
  long long firstResult = computeXOR(A - 1);
  long long secondResult = computeXOR(B);
  long long result = secondResult ^ firstResult;
  cout << result << '\n';   
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
int x, y, a, b, c, p[100005], q[100005], r[100005];
ll ans, c1, c2, c3;
bool cmp(int a, int b) { return a > b; }
int main() {
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    for (int i = 1; i <= a; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= b; i++) scanf("%d", &q[i]);
    for (int i = 1; i <= c; i++) scanf("%d", &r[i]);
    sort(p + 1, p + a + 1, cmp);
    sort(q + 1, q + b + 1, cmp);
    sort(r + 1, r + c + 1, cmp);
    int nowi = 1, nowj = 1, nowk = 1;
    for (int i = 1; i <= x + y; i++) {
        if (r[nowk] >= p[nowi] && r[nowk] >= q[nowj]) {
            ans += r[nowk];
            nowk++;
            continue;
        }
        if (p[nowi] > q[nowj]) {
            if (nowi <= x) {
                ans += p[nowi];
                nowi++;
            } else {
                if (r[nowk] >= q[nowj]) {
                    ans += r[nowk];
                    nowk++;
                } else {
                    ans += q[nowj];
                    nowj++;
                }
            }
        } else {
            if (nowj <= y) {
                ans += q[nowj];
                nowj++;
            } else {
                if (r[nowk] >= p[nowi]) {
                    ans += r[nowk];
                    nowk++;
                } else {
                    ans += p[nowi];
                    nowi++;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanln(&A, &B)

	if A == 1 {
		A = 100
	}
	if B == 1 {
		B = 100
	}
	if A > B {
		fmt.Println("Alice")
	} else if A < B {
		fmt.Println("Bob")
	} else {
		fmt.Println("Draw")
	}

}

Measured memory_bytes: 512
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    D = list(input())
    dic = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
    ans = []
    for d in D:
        ans.append(dic[d])
    print(''.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8960
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int n,q;
  vector<int> s,t;
  int ans = 0;

  cin >> n;
  s.resize(n);
  for( int i = 0; i < n; ++i){
    cin >> s[i];
  }
  cin >> q;
  t.resize(q);
  for( int i = 0; i < q; ++i){
    cin >> t[i];
  }

  for( int i = 0; i < q; ++i){
    for( int j = 0; j < n; ++j){
      if( t[i] == s[j]){
        ++ans;
        break;
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3088
#include<stdio.h>
int calc(int X){
    int N=0;
  while(X%100==0){
    X/=100;
    N++;
  }
  return N;
}

int main(void){
  int a,b,count=0,num=1;
  scanf("%d %d",&a,&b);
  while(count<b){
    if(calc(num)==a){
      count++;
    }
    ++num;
  }
  printf("%d\n",num-1);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> v(n,k-q);
  for(int i = 0; i < q; i++){
    int a;
    cin>>a;
    a--;
    v[a]++;
  }
  for(int i = 0; i < n; i++){
    if(v[i]<=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl; 
  }
  return 0;
}


Measured memory_bytes: 1024
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans= min(n*a, b);
	cout<<ans;
    return 0;
}























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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


using Graph = vector<vector<int>>;

struct Diameter {
    vector<int> prev;

    pii DiameterDFS(const Graph &G, int v, int p) {
        pii res(v, 0);
        for (int i = 0; i < (int)G[v].size(); ++i) {
            if (G[v][i] == p) continue;
            pii tmp = DiameterDFS(G, G[v][i], v);
            tmp.second++;
            if (tmp.second > res.second) res = tmp, prev[G[v][i]] = v;
        }
        return res;
    }

    vector<int> solve(const vector<vector<int> > &G) {
        prev.assign((int)G.size(), -1);
        pii leaf = DiameterDFS(G, 0, -1);

        prev.assign((int)G.size(), -1);
        pii t = DiameterDFS(G, leaf.first, -1);
        vector<int> res;
        int cur = t.first;
        while (cur != -1) res.push_back(cur), cur = prev[cur];
        return res;
    }
};

int N;
Graph G(200005, vi());

int main() {
    cin >> N;
    rep(i, N - 1) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    Diameter diam;
    vi res = diam.solve(G);
    int x = res.size();

    cout << (x % 3 == 2 ? "Second" : "First") << endl;

}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll x[10001], y[10001], w, h, n, result = 0;
  cin >> w >> h >> n;
  rep(i, n) cin >> x[i] >> y[i];
  for(int i = 1; i < n; i++) {
    ll xx = abs(x[i] - x[i - 1]);
    ll yy = abs(y[i] - y[i - 1]);
    if((x[i] >= x[i - 1] && y[i] >= y[i - 1]) || (x[i] <= x[i - 1] && y[i] <= y[i - 1])) {
      result += max(xx, yy);
    } else {
      result += (xx + yy);
    }
  }
  cout << result << endl;
	return 0;
}


Measured memory_bytes: 3140
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
P = [K - Q]* N

for i in range(Q):
  P[A[i] - 1] += 1

for p in P:
  if p > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 10472
#include <iostream> 
#include <math.h> 
#include <iomanip> 
using namespace std;  
  
int main()  
{  
int num,a,b,c;
cin >> num;
for(int i=1;i<=num;i++)
{cin >> a >> b >> c;
if(a <= b && b <= c && a*a+b*b==c*c)
{cout << "YES" << endl;}
else if(a <= c && c <= b && a*a+c*c==b*b)
{cout << "YES" << endl;}
else if(b <= a && a <= c && a*a+b*b==c*c)
{cout << "YES" << endl;}
else if(c <= a && a <= b && a*a+c*c==b*b)
{cout << "YES" << endl;}
else if(b <= c && c <= a && b*b+c*c==a*a)
{cout << "YES" << endl;}
else if(c <= b && b <= a && b*b+c*c==a*a)
{cout << "YES" << endl;}
else
{cout << "NO" << endl;}
}
} 



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

int main(){
    //K-1,K-1,K-1,...,K-1,K-1,Kで覆えれば良い
    int K, N;
    cin >> N >> K;
    if(K==2){
        cout << N-1 << endl; return 0;
    }
    int a = N/(K-1);
    int b = N%(K-1);
    if(b==0 || b==1) cout << a << endl;
    else cout << a+1 << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
py = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
  py[i].append(i)
py.sort()
city=py[0][0]
cnt=0
for i in range(m):
  if py[i][0] == city:
    cnt+=1
    py[i].append(cnt)
  else:
    city=py[i][0]
    cnt=1
    py[i].append(cnt)
for i in range(m):
  num=str(py[i][0]).zfill(6)+str(py[i][3]).zfill(6)
  py[i].append(num)
py.sort(key=lambda x:x[2])
for i in range(m):
  print(py[i][4])

Measured memory_bytes: 41740
n = int(input())
x = [0] * n
u = [0] * n

r = 380000.0

for i in range(0, n):
    sx, su = [i for i in input().split(" ")]
    x[i], u[i] = [float(sx), su]

y = [x[i] if u[i] == "JPY" else x[i] * r for i in range(0, n)]
print(sum(y))

Measured memory_bytes: 3064
//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+6;

ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set


int32_t main()
{
IOS

    
    int n,m;
    cin>>n>>m;
    int a[n+1];
    for(int i=1;i<=n;++i)
        cin>>a[i],a[i]/=2;
    sort(a+1,a+n+1);
    // for(int i=1;i<=n;++i)
    // {
    //     if(a[i]%2==0)
    //     {
    //         cout<<0;
    //         return 0;
    //     }
    // }
    int te=a[1],l=a[1];
    for(int i=2;i<=n;++i)
    {
        te=__gcd(l,a[i]);

        l=(l*a[i])/te;
        //cout<<l<<" "<<a[i]<<endl;
        if(l>m)
        {
            cout<<0;
            return 0;
        }
    }
    if(l%2==0)
    {
        int x=0;
        for(int i=1;i<=n;++i)
            x=__gcd(x,a[i]);
        for(int i=1;i<=n;++i)
        {
            a[i]/=x;
            if(a[i]%2==0)
            {
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<(m/l+1)/2<<endl;
        return 0;
        
    }


   // cout<<l<<endl;
    cout<<(m/l+1)/2<<endl;

}    


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr int INF = INT_MAX;
constexpr int MAX_N = 100010;

struct edge {
    int to;
    int cost;
};

vector<edge> G[MAX_N];

void bfs(int v, vector<int> &costs, bool &good, int cost) {
    if (costs[v] != INF) {
        if (costs[v] != cost) good = false;
        return;
    }
    costs[v] = cost;
    for (int i = 0; i < G[v].size(); i++) {
        int to = G[v][i].to;
        bfs(to, costs, good, cost + G[v][i].cost);
    }
}

int main() {

    int N, M;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    vector<int> costs(N, INF);
    bool good = true;

    for (int i = 0; i < N; i++) {
        if (costs[i] == INF) {
            bfs(i, costs, good, 0);
        }
    }

    if(good) cout << "Yes";
    else cout << "No";

    return 0;
}

















































Measured memory_bytes: 12928
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

Int f(pair<Int, Int> a, Int s) {
    return a.first + a.second * s;
}

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

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

    vector<vector<pair<Int, Int>>> dp(n + 5, vector<pair<Int, Int>>(2, {1000, 0}));
    dp[0][0] = {1000 % a[0], 1000 / a[0]};
    for (int i = 0; i < n; i++) {
        if (f(dp[i][0], a[i]) < f(dp[i][1], a[i])) {
            dp[i + 1][0].second = dp[i][1].first / a[i];
            dp[i + 1][0].first = dp[i][1].first % a[i];
        } else {
            dp[i + 1][0] = dp[i][0];
        }

        if (f(dp[i][1], a[i]) < f(dp[i][0], a[i])) {
            dp[i + 1][1].first = dp[i][0].first + dp[i][0].second * a[i];
            dp[i + 1][1].second = 0;
        } else {
            dp[i + 1][1] = dp[i][1];
        }
    }

    Int ans = 0;
    for (int i = 0; i < 2; i++) {
        ans = max(ans, dp[n - 1][i].first + dp[n - 1][i].second * a.back());
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <set>
#include <cmath>
#include <algorithm>
// F - Fork in the Road

#define EPS 1e-9
#define INF 1e9 + 5

using namespace std;

bool adj[605][605];
int deg[605];
double dp1[605],dp2[605],chance[605];

int main() {
    int N,M,i,j,s,t,mx,nxt;
    double ans;

    scanf("%d%d",&N,&M);
    for (i = 0;i < M;i++) {
        scanf("%d%d",&s,&t);
        adj[s][t] = true;
        deg[s]++;
    }

    for (i = N - 1;i > 0;i--) {
        for (nxt = 1;nxt <= N;nxt++) {
            if (adj[i][nxt])
                dp1[i] += dp1[nxt];
        }
        dp1[i] /= deg[i];
        dp1[i]++;
    }

    ans = INF;
    for (i = 1;i < N;i++) {
        mx = N + 1;
        for (nxt = 1;nxt <= N;nxt++) {
            if (adj[i][nxt] && dp1[nxt] > dp1[mx])
                mx = nxt;
        }

        if (mx <= N) {
            adj[i][mx] = false;
            deg[i]--;

            for (j = N - 1;j > 0;j--) {
                for (nxt = 1;nxt <= N;nxt++) {
                    if (adj[j][nxt])
                        dp2[j] += dp2[nxt];
                }
                dp2[j] /= deg[j];
                dp2[j]++;
            }

            chance[1] = 1;
            for (j = 1;j < N;j++) {
                for (nxt = 1;nxt <= N;nxt++) {
                    if (adj[j][nxt])
                        chance[nxt] += chance[j] / deg[j];
                }
            }

            if (abs(chance[N] - 1) <= EPS)
                ans = min(ans,dp2[1]);

            adj[i][mx] = true;
            deg[i]++;
            for (j = 1;j <= N;j++) {
                dp2[j] = 0;
                chance[j] = 0;
            }
        }
    }

    if (ans > 1e9)
        printf("%.10f\n",dp1[1]);
    else
        printf("%.10f\n",min(dp1[1],ans));

    return 0;
}

Measured memory_bytes: 512
const teststr = 
"""
100 2
"""

function lines()
  Channel{String}(32) do ch
    ll = readlines()
    lines = isempty(ll) ? split(teststr, "\n") : ll
    for s in lines
      put!(ch, s)
    end
  end
end

quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

function main()
  ch = lines()
  S,W = in_a(ch)
  println(S <= W ? "unsafe" : "safe")
end

main()


Measured memory_bytes: 186712
#include <algorithm>
#include <iostream>
#include <deque>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    string s; cin >> s;
    deque<char> q;
    for (char c : s) q.push_back(c);

    bool flip = false;
    int n; cin >> n;

    REP(i, n) {
        int t; cin >> t;
        if (t == 1) flip = !flip;
        else {
            int f;
            char c;
            cin >> f >> c;
            if (flip) f = 3 - f;
            if (f == 1) q.push_front(c);
            else q.push_back(c);
        }
    }

    if (flip) reverse(q.begin(), q.end());
    string ans;
    for (char c : q) ans += c;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1368
import java.util.*;

public class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        String str = sc.nextLine();
        String ans = "";
      
        
        for(int i = 0; i < str.length(); ++i) {
            ans += 'x';
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 21844