akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n;
    cin >> n;
    vector<int> v((int)('z'-'a')+1, 0);
    REP(i, n){
        string s;
        cin >> s;

        if(i==0){
            REP(j, s.length()){
                v[s[j]-'a']++;
            }
        }
        else{
            vector<int> t((int)('z'-'a')+1, 0);
            REP(j, s.length()){
                t[s[j]-'a']++;
            }
            REP(j, (int)('z'-'a')+1){
                v[j]=min(v[j], t[j]);
            }
        }
    }
    

    string str="";
    REP(i, (int)('z'-'a')+1){
        REP(j, v[i]){
            str+=(char)('a'+i);
        }
    }

    cout << str << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var HN = RInts();
        int H = HN[0], N = HN[1];
        var AB = new int[N][];
        for (int i = 0; i < N; i++)
        {
            AB[i] = RInts();
        }
        var dp = Enumerable.Repeat(int.MaxValue, H + 1).ToArray();
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < H; j++)
            {
                if (dp[j] == int.MaxValue) continue;
                int k = j + AB[i][0];
                k = Min(H, k);
                dp[k] = Min(dp[k], dp[j] + AB[i][1]);
            }
        }
        WriteLine(dp[H]);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

}

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

void solve() {
    int N, C;
    cin >> N >> C;
    vector<int> s(N), t(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i) >> t.at(i) >> c.at(i);
    }
    vector<vector<int>> use(C, vector<int>(200000));
    for (int i = 0; i < N; i++) {
        //cout << i << endl;
        for (int j = s.at(i) * 2 - 1; j < t.at(i) * 2; j++) {
            use.at(c.at(i) - 1).at(j) = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < 200000; i++) {
        //cout << i << endl;
        int s = 0;
        for (int j = 0; j < C; j++) {
            s += use.at(j).at(i);
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 25728
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


int main() {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll ans = -1e18;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
vector<int> adj[50];
int power[50];
bool used[50];
int ans, rest, sum;
int N;
vector<int> per;
void dfs(int k_){
  if(k_ == N){
    ans = max(ans,  sum);
    return ;
  }
  int k = per[k_];
  //printf("%d:%d %d %d\n", k,sum , rest, ans);
  if(sum + rest <= ans){
    return;
  }
  bool usedtmp[50];
  memcpy(usedtmp, used, sizeof(used));
  int sumtmp = sum;
  int resttmp = rest;
  if(!used[k]){
    used[k] = true;
    sum += power[k];
    rest -= power[k];
    FORIT(it, adj[k])if(!used[*it]){
      rest -= power[*it];
      used[*it] = true;
    }
    dfs(k_ + 1);
    memcpy(used, usedtmp, sizeof(used));
    sum = sumtmp;
    rest = resttmp;
  }
  if(k != 0){
    if(!used[k])rest -= power[k];
    used[k] = true;
    dfs(k_ + 1);
  }
}

typedef pair<int, int> P;
int main(){
  while(cin>>N && N){
    ans = 0, rest = 0, sum = 0;
    REP(i, 50) adj[i].clear();
    memset(used, 0, sizeof(used));
    map<string, int> id;
    vector<string> adjstr[50];
    REP(i, N){
      string s; cin>>s; id[s] = i;
      cin>>power[i];
      rest += power[i];
      int k; cin>>k;
      while(k--){
        string str; cin>>str;
        adjstr[i].push_back(str);
      }
    }
    REP(i, N){
      REP(j, adjstr[i].size()){
        adj[i].push_back(id[adjstr[i][j]]);
      }
    }
    vector<P> ps(N-1);
    REP(i, N-1)ps[i] = P(-power[i+1], i+1);
    sort(ps.begin(), ps.end());
    per = vector<int>(N, 0);
    REP(i, N-1) per[i+1] = ps[i].second;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct Sieve {
	int n;
	vector<int> f, primes;
	Sieve(int n=1):n(n), f(n+1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i*i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x) { return f[x] == x;}
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res;
		int pre= -1;
		for (int p : fl) {
			if (pre == p) {
				res.back().second++;
			} else {
				res.emplace_back(p, 1);
			}
			pre=p;
		}
		return res;
	}
};


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

	Sieve si(200000);
	auto it=lower_bound(si.primes.begin(), si.primes.end(), x);

	cout<<(*it)<<endl;
	return 0;
}


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

int n,k;

signed main() {
  cin >> n >> k;
  double ans = 0;
  for(int i=1; i<=n; i++) {
    double d = 1.0 / n;
    for(int c = i; c<k; c*=2) d *= 0.5;
    ans += d;
  }
  cout << fixed << setprecision(10)<< ans << endl;
}


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

int main() {
        int n;
        cin >> n;
        int sum = 0;
        int i = 1;
        while (sum < n) {
                sum += i;
                i ++;
        }
        int limit = i - 1;
        int ex = sum - n;
        for (int i = 1; i <= limit; i ++) {
                if (i != ex) cout << i << endl;
        }
        return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
int main(){
	int n,i,a,min,max;
	long long sum=0;
	std::cin >> n;
	for(i=0;i<n;i++){
		std::cin >> a;
		if(i==0){
			min=a;
			max=a;
			}
		if(min>a) min=a;
		if(max<a) max=a;
			sum=sum+a;
		}
		std::cout << min << " " << max << " " << sum <<std::endl;
	return 0;
}

Measured memory_bytes: 1168
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W;
char CHAR[256];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H>>W;
	for (int32_t i = 0; i < H; i++)
	{
		std::string s; in >> s;
		for (auto& c : s) {
			CHAR[c]++;
		}
	}

	if ((H & 1) == 0 && (W & 1) == 0) {
		for (auto& v : CHAR) {
			if (v % 4 != 0) {
				out << "No" << endl;
				return 0;
			}
		}
		out << "Yes" << endl;
		return 0;
	}

	{
		bool is_odd_ok = (H & 1) && (W & 1);

		for (auto& v : CHAR) {
			if (v % 2 != 0) {
				if (is_odd_ok) {
					is_odd_ok = false;
					--v;
				}
				else {
					out << "No" << endl;
					return 0;
				}
			}
		}
	}

	int32_t num2 = 0;
	if ((H & 1))
	{
		num2 += W/2;
	}
	if((W & 1))
	{
		num2 += H/2;
	}

	for (auto& v : CHAR) {
		if (v % 4 != 0) {
			if (num2 > 0) {
				--num2;
			}
			else {
				out << "No" << endl;
				return 0;
			}
		}
	}

	out << "Yes" << endl;
	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N,M,K;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M>>K;
	for (int32_t i = 0; i <= N; i++)
	{
		for (int32_t j = 0; j <= M; j++)
		{
			int32_t res = i*M + j*N - i*j*2;

			if (res == K) {
				out << "Yes" << endl; return 0;
			}
		}
	}
	out << "No" << endl; return 0;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(s.length()<=k){
        cout << s << endl;
    }else{
        string ss = s.substr(0,k);
        cout << ss << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
n   = gets.to_i     #入力数
str = Array.new
n.times {
     str << gets.chomp.delete('\"').to_s #文字列を格納
}

# 1.group_by(&:itself):同じ要素でまとめる(この時点で連想配列になる)
    #p m = str.group_by(&:itself) 
# 2.map()ですべての要素に対して[key] [Value.count]で要素名と数にまとめて mm に格納
    mm = str.group_by(&:itself).map{ |k, v| [k, v.count] }
# 3.辞書順に並べ替え
    mm.sort!()
    #p mm
# 4.max[1]で最大値をとる配列を得る
    mmm = mm.max_by{ |k,v| v }[1]
    #p mmm
mm.each { |k,v|
    if v == mmm then
         print("#{k}\n")
    end
}

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

const int mxn = 1e5+500;
int a[mxn];
int dp[mxn];
int n,k;

int solve(){

	fo(i,n) dp[i]  = INT_MAX;
	dp[0] = 0;
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k;j++){
			if(j<n) dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}

	return dp[n-1];
}

int main(){
	NINJA;

	cin >> n >> k;
	fo(i,n) cin >> a[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
n,l=map(int,input().split())
a=[l+i-1 for i in range(1,n+1)]
pura=sorted([i for i in a if i>=0])
mai=sorted([i for i in a if i<0])[::-1]
if pura==[]:
    print(sum(mai[1:]))
elif mai==[]:
    print(sum(pura[1:]))
elif abs(pura[0])>=abs(mai[0]):
    print(sum(pura)+sum(mai[1:]))
else:
    print(sum(pura[1:])+sum(mai))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b and a != c) {
        Yes();
    }else if(a == c and a != b){
        Yes();
    }else if(b == c and a != b){
        Yes();
    }else{
        No();
    }

    
    
    return 0;
}  


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
   int i,h,m,s;
   cin >> i;
   h = i / 3600;
   m = i/60-h*60;
   s = i-h*3600-m*60;
   cout << h <<":"<<m<<":"<<s<< endl; 
   
   return 0;
}
   //comments for human
   //1 minute = 60 seconds
   //1 hour = 60 minutes = 3600 seconds


Measured memory_bytes: 3128
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
struct ge{
	string name;
	int time;
}a[55];
bool ok = 0;
string s; 
int n , ans;
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i].name;
		scanf("%d" , &a[i].time);
	}
	cin >> s;
	for(int i = 1 ; i <= n ; i++){
		if(ok){
			ans += a[i].time;
		}
		if(a[i].name == s){
			ok = 1;
		}
	}
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 256
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	int n, tmp, ans;
	tmp = 0;
	ans = 0;
	int h[100001], now;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];

	for (int i = 0; i < n - 1; i++) {
		if (h[i] >= h[i + 1]) tmp += 1;
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);

	cout << ans << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
char s[15];
long long ans=0;
long long len=0;
void dfs(long long x,long long a,long long b)
{
	if(x>=len)
	{
		ans+=a+b;
		return ;
	}
	dfs(x+1,a,b*10+s[x]-'0');
	if(x!=0)
	dfs(x+1,a+b,s[x]-'0');
}
int main()
{
	scanf("%s",s);
	len=strlen(s);
	dfs(0,0,0);
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
N = int(input())
WL = list(map(int, input().split()))
Aw = sum(WL)
Ow = 0
AL = []
for i in range(N):
    Ow += WL[i]
    ans = abs(Ow - (Aw -Ow))
    AL.append(ans)
print(min(AL))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
using namespace std;
typedef long long ll;
using pii = pair<ll, ll>;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for(int s=0; s<(1 << (S.size()-1)); s++){
        string now = "";
        now += S[0];
        for(int i=0; i < (S.size()-1); i++){
            //S[i]とS[i+1]の間に　+　を入れるか
            if(s & (1<<i)) now += "+";
            now += S[i+1];
        }
        ll sum = 0;
        int pos = 0; // 数値の始まる位置
        while(now.find("+",pos) != string::npos){
            // + の位置
            int nextpos = now.find("+",pos);
            sum += stoll(now.substr(pos, nextpos - pos));
            pos = nextpos + 1;
        }
        sum += stoll(now.substr(pos));
        ans += sum;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
ll sub(string A, string B){
	ll ans =0;
	urep(i,A.size()-1,0){
		if(i!=A.size()-1){
			if(A[i]!=B[i]){
				return 1000;
			}
		}else{
			if(A[i]>=B[i]){
				ans=A[i]-B[i];
			}else{
				A[i-1]--;
				ans=A[i]-B[i]+10;
			}
		}
	}
	return ans;
}
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	string n;
	cin>>n;
	ll N = n.size();
	vector<ll> yakusuu;
	rep(i,1,N){
		if(N%i ==0)
			yakusuu.push_back(i);
	}
	ll ans=8;
	rep(i,0,yakusuu.size()){
		string minnum;
		string maxnum;
		rep(j,0,N/yakusuu[i]){
			string num;
			rep(k,0,yakusuu[i]){
				num.push_back(n[j*yakusuu[i]+k]);
				//cerr<<num<<endl;
			}
			if(minnum.empty()){
				minnum=num;
				maxnum=num;
			}
			minnum=min(minnum,num);
			maxnum=max(maxnum,num);
			//cerr<<maxnum<<endl<<minnum<<endl;
		}
		ans = min(ans,sub(maxnum,minnum));
		//cerr<<maxnum<<"-"<<minnum<<"="<<sub(maxnum,minnum)<<endl;
	}
	if(N==2){
		cout<<ans<<endl;
		return 0;
	}
	ll minnum=INF;
	ll maxnum=0;
	rep(i,0,N){
		ll num;
		if(n[i]=='1'){
			if(i==N-1){
				minnum=1;
				break;
			}
			num=(n[i]-'0')*10+(n[i+1]-'0');
			i++;
		}else{
			num=n[i]-'0';
		}
		minnum=min(minnum,num);
		maxnum=max(maxnum,num);
	}
	//cerr<<maxnum<<"-"<<minnum<<endl;
	ans = min(maxnum-minnum,ans);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3412
#include <iostream>

using namespace std;

int main()
{
    int L, N;
    cin >> L >> N;
    cout << N << endl;
    for (int i = 0; i < N; i++) {
        int x, w;
        cin >> x >> w;
        cout << -x << " " << w << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9+7;
auto l = string();
ll n,k;
ll nsize;
ll dfs(string num){
	if(num.size()>nsize+1) return INF;
	if(num[0]=='0') return INF; 	
	ll ans =INF;
	for(auto i:l){
		if(num!=""&&stoll(num)>=n){
			ans=min(stoll(num),dfs(num+i));
		}else{
			ans=min(ans,dfs(num+i));
		}
	}
	return ans;
}
int main(){
	cin >> n >> k;
	nsize=log10(n)+1;
	auto d = vector<int>(k,0);
	for(int i=0;i<k;i++){
		cin >>d[i];
	}
	for(int i=0;i<=9;i++){
		if(find(d.begin(),d.end(),i)==d.end()){
			l.push_back(i+'0');
		}
	}
	sort(l.begin(),l.end());
	cout << dfs("");
	return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}

string solve() {
  int a = read<int>();
  int b = read<int>();
  if (a == b) return "Draw";
  if (a == 1) return "Alice";
  if (b == 1) return "Bob";
  if (a > b) return "Alice";
  return "Bob";
  
}
void Main() { cout << solve() << endl; }
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define MOD 998244353
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define INF 100000000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int a[N];
int vis[N]={0};
int vis2[N];
signed main()
{
    
    speed
    int n,k;cin>>n>>k;
    rep(i,1,n)cin>>a[i];
    vector <int> xd;
    int j=a[1];
    xd.pb(1);
    int time=0;
    int repeat=-1;
    vis[1]=0;
    int left=0;
    int st=-1;
    while(1){
        time++;
        if(vis[j]){
            repeat=(time-vis[j]);
            left=vis[j];
            st=j;
            break;
        }
        vis[j]=time;
        xd.pb(j);
        j=a[j];
    }
    if(k<left){
        rep(i,1,n){
            if(vis[i]==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    else{
        k-=left;
        time=0;
        j=a[st];
        vector <int>lol;
        lol.pb(st);
        while(j!=st){
            lol.pb(j);
            j=a[j];
        }
        k=k%(lol.size());
        cout<<lol[k]<<endl;


    }


    


   





    return 0;
}

Measured memory_bytes: 10728
H,W = map(int, input().split())

S = [list(input()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            continue

        cnt = 0
        for dy in [-1,1]:
            if 0 <= i + dy < H:
                if S[i+dy][j] == '#':
                        cnt += 1
        for dx in [-1,1]:
            if 0 <= j + dx < W:
                if S[i][j+dx] == '#':
                    cnt += 1
        if cnt == 0:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, k;
    cin >> n >> k;
    // nHr(n, k) = nCr(n+k-1, n-1);
    vector<ll> dp(k+1, 0);
    dp[0] = 1;
    int ai = 0;
    ll mod = 1e9 + 7;
    for(int i = 0; i < n; i++) {
        cin >> ai;
        // use prefix sum
        vector<ll> pre(k+2, 0);
        for(int j = 0; j <= k; j++) {
            pre[j+1] = (pre[j] + dp[j]) % mod;
        }
        for(int j = k; j >= 0; j--) {
            // range sum (max(0, j-delta) .... j
            dp[j] = (pre[j+1] - pre[max(0, j-ai)] + mod*2) % mod;
            // printf("i = %d, dp[%d] = %lld\n", ai,  j, dp[j]);
            /*
            for(int delta = ai; delta > 0; delta--) {
                if (j - delta >= 0) {
                    dp[j] += dp[j-delta];
                    dp[j] %= mod;
                }
            }*/
        }
    }
    cout << dp[k] << endl;
    return 0;
}



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

vector<ll> factors(ll n) {
	vector<ll> f;
	
	for (ll d = 2; d * d <= n; d++) {
		if (n % d != 0) {
			continue;
		}

		f.push_back(d);
        while (n % d == 0) {
            n /= d;
        }
    }
    if (n > 1) {
        f.push_back(n);
	}

	return f;
}

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

	vector<ll> f = factors(n);
	queue<pair<ll, ll>> q;
	for (ll fi : f) {
		q.push({fi, fi});
	}

	ll k = 0;
	while (n > 1 && !q.empty()) {
		pair<ll, ll> t = q.front();
		q.pop();
		if (n % t.first != 0) {
			continue;
		}

		n /= t.first;
		q.push({t.first * t.second, t.second});

		++k;
	}

	cout << k;
	
	return 0;
}
	

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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }


int main(){
    ll a,b,n;
    ll ans=0;
    cin>>a>>b>>n;
    if(n<b) ans=floor((a*n)/b)-a*floor(n/b);
    else if(n==b) ans=floor((a*(n-1))/b)-a*floor((n-1)/b);
    else ans=floor((a*(b-1))/b)-a*floor((b-1)/b);
    cout<<ans;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x)
{
  while (x->left != NIL)
    x = x->left;
  return x;
}

Node *treeSuccessor(Node *x)
{
  if (x->right != NIL)
    return treeMinimum(x->right);
  Node *y = x->parent;
  while (y != NIL && x == y->right)
  {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z)
{
  Node *y;
  Node *x;

  if (z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if (y->left != NIL)
  {
    x = y->left;
  }
  else
  {
    x = y->right;
  }
  if (x != NIL)
  {
    x->parent = y->parent;
  }
  if (y->parent == NIL)
  {
    root = x;
  }
  else
  {
    if (y == y->parent->left)
    {
      y->parent->left = x;
    }
    else
    {
      y->parent->right = x;
    }
  }
  if (y != z)
  {
    z->key = y->key;
  }
  free(y);
}

Node *find(Node *u, int k)
{
  while (u != NIL && k != u->key)
  {
    if (k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return u;
}

void insert(int k)
{
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL)
  {
    y = x;
    if (z->key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL)
  {
    root = z;
  }
  else
  {
    if (z->key < y->key)
    {
      y->left = z;
    }
    else
    {
      y->right = z;
    }
  }
}

void inorder(Node *u)
{
  if (u == NIL)
    return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if (u == NIL)
    return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++)
  {
    cin >> com;
    if (com[0] == 'f')
    {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL)
        printf("yes\n");
      else
        printf("no\n");
    }
    else if (com == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if (com == "print")
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (com == "delete")
    {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }
  return 0;
}


Measured memory_bytes: 21952
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int A[] = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
		}
		int changeCount = 0;
		scanner.close();

		//降順に並べるバブルソート
		for(int i = 0; i < A.length; i++) {
			//昇順に並ぶ隣接要素が存在する時にtrue
			boolean flag = true;
			while(flag) {
				flag = false;
				for(int j = A.length - 1; j > 0; j--) {
					if(A[j - 1] > A[j]) {
						//A[j]とA{j - 1]を交換
						int tmp = A[j];
						A[j] = A[j - 1];
						A[j - 1] = tmp;
						flag = true;
						changeCount++;
					}
				}
			}
		}
		System.out.println(Arrays.toString(A).replaceAll("[,\\[\\]]", ""));
		System.out.println(changeCount);
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

char str[200010];
int arr[30];
int main() {
    //freopen("hi.txt", "r", stdin);
    int n;
    scanf("%s",str);
    n=strlen(str);
    for(int i=0;i<n;i++){
        arr[str[i]-'a']++;
    }
    ll ans=(ll)n*(n-1)/2+1;
    for(int i=0;i<26;i++){
        ans-=(ll)arr[i]*(arr[i]-1)/2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 384
nums = [int(i) for i in input()]
operators = []
for i in range(2):
    op = []
    for j in range(2):
        for k in range(2):
            operators.append([i, j, k])

correct = False
while not correct:
    for current_operators in operators:
        res = nums[0]
        ans = str(nums[0])
        for index, op in enumerate(current_operators):
            if op:
                ans = '{}+{}'.format(ans, nums[index + 1])
                res += nums[index + 1]
            else:
                ans = '{}-{}'.format(ans, nums[index + 1])
                res -= nums[index + 1]
        if res == 7:
            print('{}=7'.format(ans))
            correct = True
            break

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N;
vector<ll> A;
vector<ll> B;
vector<ll> C;

map<ll, ll> ANum;  // サイズ i のパーツ A の数
map<ll, ll> BNum;  // サイズ B より小さいパーツ A の数

int main()
{
    cin >> N;
    REP(i, N) {
        ll tmp;
        scanf("%lld", &tmp);
        A.push_back(tmp);
        ANum[tmp]++;
    }
    REP(i, N) {
        ll tmp;
        scanf("%lld", &tmp);
        B.push_back(tmp);
    }
    REP(i, N) {
        ll tmp;
        scanf("%lld", &tmp);
        C.push_back(tmp);
    }
    SORT(A);
    SORT(B);
    SORT(C);
    ll ind = 0;
    for(auto& b : B) {
        for(; A[ind] < b && ind < N; ++ind) {}
        BNum[b] = ind;
        DBG("BNum[%lld] = %lld\n", b, ind);
    }
    ll ans = 0;
    ind = 0;
    ll prev = 0;
    for(auto& c : C) {
        DBG("c: %lld\n", c);
        ll cur = 0;
        for(; B[ind] < c && ind < N; ++ind) { cur += BNum[B[ind]]; }
        DBG("cur: %lld\n", cur);
        ans += (prev + cur);
        prev += cur;
    }
    printf("%lld\n", ans);

    return 0;
}


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

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool why = false;
  bool finished = false;
  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < 27; j++) {
      if (N == (4 * i) + (7 * j)) {
        why = true;
        break;
      }
    }
  }
  if (why) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
s = input()
s = s[::-1]

L = [0]
cnt = 1
for i in range(len(s)):
    L.append((L[-1]+(int(s[i])*cnt))%2019)
    cnt *= 10
    cnt %= 2019

D = dict()
for j in L:
    if j in D:
        D[j] += 1
    else:
        D[j] = 1
ans = 0
for k in D.values():
    ans += k * (k-1) //2

print(ans)

Measured memory_bytes: 16392
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  rep(i,3){
    if(s[i]=='7'){
      cout<<"Yes"<<endl;
      return(0);
    }
  }
  cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 3596
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val k = sc.nextInt
  val s = sc.nextInt

  val res =
    (0 to k).foldLeft(0) { (c1, x) =>
      (0 to k).foldLeft(c1) { (c2, y) =>
        val z = s - x - y
        c2 + (if (0 <= z && z <= k) 1 else 0)
      }
    }

  println(res)
}


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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, ans = 0;
   string A, B, C;
   cin >> N >> A >> B >> C;

   for (int i = 0; i < N; i++) {
     if (A.at(i) != B.at(i) && B.at(i) != C.at(i) && C.at(i) != A.at(i)) ans += 2;
     else if (A.at(i) != B.at(i) || B.at(i) != C.at(i) || C.at(i) != A.at(i)) ans++;
   }

   cout << ans << endl;
  }


Measured memory_bytes: 256
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int main() {
  FASTIO();

  ll n, a, b;
  cin >> n >> a >> b;

  cout << fixed << (ll)floor((f80)n / (a + b)) * a + min(a, n % (a + b));
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

// Returns LCM of |a| and |b|
i64 LCM(i64 a, i64 b)  // {{{
{
    return abs(a) / __gcd(a, b) * abs(b);
}  // }}}

i64 f(i64 n) {
    int cnt = 0;
    while (n > 0 && n % 2 == 0) n /= 2, ++cnt;
    return cnt;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, N, M);
    vector<i64> a(N);
    read(a);

    {
        const i64 d = f(a[0]);
        rep(i, 1, N) if (f(a[i]) != d) {
            print(0);
            return 0;
        }
    }

    M *= 2;

    i64 X = 1;
    rep(i, 0, N) {
        X = LCM(X, a[i]);
        if (X > M) {
            print(0);
            return 0;
        }
    }

    print((M + X) / (2 * X));

    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))

result = 1
L = 2
current = A[0]
visited = [0] * N
visited_loop_cnt = 1
flag = True

while L < K:
    if visited[current - 1] == 3:
        J = K - L
        J %= visited_loop_cnt
        K = L + J
    elif visited[current - 1] == 2 and flag:
        visited[current - 1] += 1
        visited_loop_cnt = 1
        flag = False
    else:
        visited[current - 1] += 1
        visited_loop_cnt += 1
    current = A[current - 1]
    L += 1

print(A[current - 1])


# 同じところに来た場合、そのループ分だけ減らす必要がある。
# 1 6 2 5 3 2 5 3 2 5


Measured memory_bytes: 32372
#include <stdio.h>

int main(void){
    int a, b, c, x;

    scanf("%d %d %d %d", &a, &b, &c, &x);

    int cnt = 0;
    for(int i = 0;i <= a;++i){
        for(int j = 0;j <= b;++j){
            for(int k = 0;k <= c;++k){
                if((500 * i) + (100 * j) + (50 * k) == x) cnt++;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 1676
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nck = scanner.nextLine().split(" ");

        int N = Integer.parseInt(nck[0]);
        int C = Integer.parseInt(nck[1]);
        int K = Integer.parseInt(nck[2]);

        List<Integer> passengers = new ArrayList<>();

        for(int i = 0; i < N; i++) {
            passengers.add(Integer.parseInt(scanner.nextLine()));
        }

        passengers.sort(Collections.reverseOrder());
        int bus = 0;

        int current = 0;
        int firstPassenger = 0;
        for (Integer passenger: passengers) {
            if (current == 0) {
                current = 1;
                firstPassenger = passenger;
            } else if ((firstPassenger - passenger) > K) {
                bus++;
                current = 1;
                firstPassenger = passenger;
            } else {
                current++;
            }

            // 乗客=キャパで発車
            if (current == C) {
                bus++;
                current = 0;
                firstPassenger = 0;
            }
        }

        if (current > 0) {
            bus++;
        }

        System.out.println(bus);
    }
}

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

namespace ComparingStrings
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            int leftString = int.Parse(input[0]);
            int rightString = int.Parse(input[1]);

            List<int> leftStringList = new List<int>();
            List<int> rightStringList = new List<int>();

            for (int i = 0; i < rightString; i++)
            {
                leftStringList.Add(leftString);
            }

            for (int i = 0; i < leftString; i++)
            {
                rightStringList.Add(rightString);
            }

            if (leftStringList[0] > rightStringList[0])
            {
                string outputPrint = string.Join("", rightStringList.ToArray());
                Console.WriteLine(outputPrint);
            }

            if (rightStringList[0] > leftStringList[0])
            {
                string outputPrint = string.Join("", leftStringList.ToArray());
                Console.WriteLine(outputPrint);
            }
            if (rightStringList[0] == leftStringList[0])
            {
                string outputPrint = string.Join("", leftStringList.ToArray());
                Console.WriteLine(outputPrint);
            }
        }
    }
}

Measured memory_bytes: 13524
N=int(input())
S=input()
count=[0]*N
countnum=0
for i in range(N):
    if S[i]=="I":
        countnum += 1
        count.append(countnum)
    elif S[i]=="D":
        countnum -= 1
        count.append(countnum)

print(max(count))
        


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll N; cin >> N;
  map<ll, ll> counter; 
  REP(i, N) {
    ll a;
    cin >> a;
    counter[a]++;
  }
  ll l1 = 0, l2 = 0;
  for (auto e = counter.rbegin() ; e != counter.rend() ; e++){
    if(e->second < 2) continue;
    if(l1 == 0) {
      l1 = e->first;
      if(e->second >= 4) l2 = e->first;
    }
    else if (l2 == 0) l2 = e->first;
  }
  cout << l1 * l2 << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int n,m,j,k,i;
struct Passages{
    int x,y;
};
Passages p[400050];
int ans[200050];
bool b[100500];
bool cmp(Passages a,Passages b){
    if(a.x==b.x)
        return a.y<b.y;
    else return a.x<b.x;
}

int main()
{
    int count[100500];
    count[0]=0;
    cin>>n>>m;
    queue<int>q;
    b[1]=false;
    for(int i=2;i<=n;i++)
        b[i]=true;
    int v=1;
    for(i=0;i<m;i++){
        scanf("%d%d",&j,&k);
        p[2*i].x=j;
        p[2*i].y=k;
        p[2*i+1].y=j;
        p[2*i+1].x=k;
        if(j==1){
            q.push(k);
            ans[k]=1;
            b[k]=false;
            v++;
        }
        if(k==1){
            q.push(j);
            ans[j]=1;
            b[j]= false;
            v++;
        }
    }
    sort(p,p+2*m,cmp);
    for(i=0;i<2*m;i++)
        count[p[i].x] = i;
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(i=count[now-1]+1;i<=count[now];i++){
            if(b[p[i].y]){
                ans[p[i].y]=now;
                b[p[i].y]=false;
                q.push(p[i].y);
                v++;
            }
        }
    }
    if(v<n)
        printf("No\n");
    else{
        cout<<"Yes"<<endl;
        for (i = 2; i <= n; i++)
            cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7808